Open papayasoft opened 13 years ago
Some really good ideas there. I like your thinking, with optimisation & separation.
Looking at it more closely, I see that the controller based tests - tests that actually dispatch a request - do need to do a full bootstrap on each setUp()
. So, those tests should extends this BaseTestCase
which contains that required app bootstrapping. Still, tests that don't use a full dispatch cycle - like the config tests and perhaps others - should probably only extend the standard PHPUnit_Framework_TestCase
.
But we should still look at the other two aspects:
BaseTestCase
reside in an external file APPLICATION_ENV
'sI'll try to take a look at that.
Thanks for keeping us posted with your progress & what you find. Afterwards it will be more efficient and have a better code coverage of each mode. :)
So I see that
phpunit.xml
points to the bootstrap scripttests/bootstrap.php
, which contains an inline definition of aBaseTestCase
.Several questions:
BaseTestCase
reside in it's own external file, probably somewhere in thetests
folder?BaseTestCase::setUp()
performs a complete Doctrine bootstrap by calling$this->doctrine()
. Do we need to perform a complete Doctrine bootstrap for eachtestXXX()
? Or is it sufficient to simply bootstrap Doctrine a single time when we start the test run? I gotta figure it would at least speed up the tests.Along the same lines, can't we point to the common app
Bootstrap
class and then inbootstrap.php
simply call something like:$application->bootstrap('autoloader') ->bootstrap('doctrine) // etc.
Even if there are slight differences between the
Bootstrap
for production and for testing - I seem to see a different argument to$config->newDefaultAnnotationDriver()
, couldn't we share code and implement those differences in the config? At worst, we could change the config keybootstrap.path
to point to a distinct testing Bootstrap that resides within thetests
folder.Just thinking out loud.