Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContainerHelper: Added tests #44

Merged
merged 1 commit into from
Jan 10, 2016
Merged

ContainerHelper: Added tests #44

merged 1 commit into from
Jan 10, 2016

Conversation

juniwalk
Copy link
Contributor

@juniwalk juniwalk commented Jan 9, 2016

I must say, working with PHPUnit seems so much easier to me.

Anyway here is a draft of a tests, let's see how it goes.

$container = $this->prepareConfigurator()->createContainer();

/** @var Kdyby\Console\Application $app */
$app = $container->getByType('Kdyby\Console\Application');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to compile the container and run the app to test that those three new methods work. Unit test would suffice perfectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand correctly you want me to test just the ContainerHelper with some sort of Container mock? (newbie to testing)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't even have to mock the container, just use new Nette\DI\Container() and pass some arguments and the do asserts on the helper

@juniwalk
Copy link
Contributor Author

Alright, is it better now? Shall I add test for getByType while I am at it?

public function testParameters()
{
Debugger::$logDirectory = TEMP_DIR . '/log';
Tester\Helpers::purge(Debugger::$logDirectory);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are theese two lines for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beats me, I had some weird errors before I rewrote that test, I will try to remove them.

@juniwalk juniwalk changed the title ContainerHelper: Added tests for parameters ContainerHelper: Added tests Jan 10, 2016
@juniwalk
Copy link
Contributor Author

Okay it works now, was probably because I was building container before.

@fprochazka
Copy link
Member

Cool, thanks 👍

fprochazka added a commit that referenced this pull request Jan 10, 2016
@fprochazka fprochazka merged commit d4f6edd into Kdyby:master Jan 10, 2016
@juniwalk juniwalk deleted the di-params-tests branch January 10, 2016 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants