-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Feature/zend test load module #3942
Feature/zend test load module #3942
Conversation
@Ocramius can read this PR ? thank you :) |
use Zend\ServiceManager\ServiceManager; | ||
use Zend\Stdlib\Exception; | ||
|
||
abstract class ModuleLoader extends PHPUnit_Framework_TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why abstract? And why extending a PHPUnit_Framework_TestCase
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look my unit test, the goal was provide a "loadModule" method with direct assertion without usage of "new"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blanchonvincent perfectly clear what the intent was, I think that isn't an optimal approach (especially since it's an util, not a test case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius agree with you, it was just a draft :) i will change that
@blanchonvincent the idea looks good so far, BUT there's way too much public API in my opinion. You should probably have something like:
No other public API is needed in my opinion (that's already probably too much) :) Usage would be: class MyTest extends PHPUnit_Framework_TestCase
{
public function testFoo()
{
$moduleLoader = new \Zend\Test\PHPUnit\Util\ModuleLoader(array(
'modules' => array('Application')
));
$this->assertInstanceOf(
'Zend\ServiceManager\ServiceLocatorInterface',
$moduleLoader->getServiceManager()
);
$this->assertInstanceOf(
'Zend\ModuleManager\ModuleManager',
$moduleLoader->getModuleManager()
);
$this->assertInstanceOf(
'Zend\Mvc\ApplicationInterface',
$moduleLoader->getApplication()
);
}
} |
@Ocramius I did not know if I had to make a external class (like you) or internal class with PHPUnit_Framework_TestCase integrated (like me). |
@blanchonvincent it's not really about ease of use... I'm mainly thinking of something that doesn't enforce inheritance from another test case (we got so many already :( ) |
@Ocramius yeah, you are right |
@blanchonvincent ping again once you think you've sorted it out, and thank you for picking this =) |
@Ocramius second draft, look better, i will add unit tests again later |
} | ||
$configuration = array( | ||
'module_listener_options' => array( | ||
'module_paths' => $modulesPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before: if a module is provided as name => path
, then the module manager should already be able to handle that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius if you write in your config :
'modules' => array(
'Foo' => '/path/to/my/foo',
),
?
Currently in "modules" key, only name is accepted : https://github.com/zendframework/zf2/blob/master/library/Zend/ModuleManager/ModuleManager.php#L80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EvanDotPro ping?
Looks much better, thank you! :) |
@blanchonvincent I tried merging, but I'm missing the file |
@weierophinney you must only create the "cache" directory in "tests/ZendTest/Test/_files/". I add the directory in the versioning. |
@blanchonvincent Do not write files inside the tests directory; write them to the system temporary directory. (We need to do this in part to allow developers to run the test suite when installed via their system package manager; if we write inside the tests directory, they may not have permissions. Plus, it's cleaner.) |
@weierophinney sorry, i changed with the system temporary directory. |
@blanchonvincent I ran into issues running the test suite multiple times, as the test suite is not cleaning out the cache files. Interestingly, when I implemented that logic... a new test started failing consistently, |
…module Feature/zend test load module
- Clears module cache files on setup and teardown
- trailing whitespace, braces
Tracked it down, and all tests are running. Thanks, @blanchonvincent -- merged to develop for release with 2.2.0. |
👍! |
@weierophinney @Ocramius Thank you both for your work |
…ent/feature/zend-test-load-module Feature/zend test load module
- Clears module cache files on setup and teardown
- trailing whitespace, braces
The goal is to have an helper for write unit tests on module :
Zend\Test
service manager bootstrapper #3845