Re: [fw-general] Bootstrapping modules and testing
Davout wrote: When I run phpunit in the tests directory I get Fatal error: Class 'Zend_Application_Bootstrap_Bootstrap' not found in C:\code\myApp\application\Bootstrap.php on line 3 Ok I got past that problem, but now Running MAMP/bin/php5/bin/phpunit --configuration phpunit.xml --verbose doesn't produce any output. I have application/modules/order/models/OrderRepository.php ?php class Order_Model_OrderRepository { ... } - I have tests/ModelTestCase.php ?php require_once 'Zend/Application.php'; abstract class ModelTestCase extends PHPUnit_Framework_TestCase { public $application; public function setUp() { $this-application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $this-bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this-application-bootstrap(); } } I have tests/application/modules/order/models/OrderRepository.php ?php class Order_Model_OrderRepositoryTest extends ModelTestCase { protected function setUp(){ parent::setUp(); } public function testFind() { $orderRepos = new Order_Model_OrderRepository(); $this-assertEquals(1, 2); // should produce failure! } } Any ideas? Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758618.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
One correction. I previously posted tests/application/modules/order/models/OrderRepository.php the filename is actually OrderRepositoryTest.php One other thing in tests/application/controllers I have IndexControllerTest.php ?php class IndexControllerTest extends ControllerTestCase { public function testIndexAction() { $this-dispatch('/'); $this-assertController('index'); $this-assertAction('index'); } public function testErrorURL() { $this-dispatch('foo'); $this-assertController('error'); $this-assertAction('error'); } } If I remove tests/application/modules/order/models/OrderRepositoryTest.php then IndexControllerTest produces output. I put OrderRepositoryTest.php back, no output from any tests. Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758620.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
Never mind. I got it to work. Apparently, at some point in the hierarchy I have to extend Zend_Test_PHPUnit_ControllerTestCase class Order_Model_OrderRepositoryTest extends ControllerTestCase class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758621.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Bootstrapping modules and testing
Daniel Latter wrote: I don't think you need to extend Zend_Test_PHPUnit_ControllerTestCase for your models. As far as I understand this class is there to provide controllers with methods to make them easily testable. Models should be independant and therefore easily testable anyway. Hope this males sense. On 22 Nov 2009, at 10:04, Davout davout1...@gmail.com wrote: Never mind. I got it to work. Apparently, at some point in the hierarchy I have to extend Zend_Test_PHPUnit_ControllerTestCase class Order_Model_OrderRepositoryTest extends ControllerTestCase class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758621.html Sent from the Zend Framework mailing list archive at Nabble.com. Daniel, Thanks for the feedback. It makes perfect sense. And that's how I would think it should work. I created ModelTestCase.php ?php require_once 'Zend/Application.php'; abstract class ModelTestCase extends PHPUnit_Framework_TestCase { public $application; public function setUp() { $this-application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $this-bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this-application-bootstrap(); } } And had my test extend that. However, running test does not generate any output. But now I find out even if I use the ControllerTestCase if my test class implements its own setUp protected function setUp(){ parent::setUp(); } No output is generated. Obviously something in my setup is not correct. Any ideas? Thanks. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p758689.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Bootstrapping modules and testing
Hi, I'm having problems running phpunit tests for my Zend application. I'm wondering if anyone could correct what I'm doing wrong. I've setup my application based on http://akrabat.com/2009/07/08/bootstrapping-modules-in-zf-1-8/ Rob Allen's Bootstrapping Modules blog post. Note: right now I'm not trying to test controllers, just model classes In my tests directory I have phpunit.xml and TestHelper.php phpunit.xml phpunit bootstrap=./TestHelper.php colors=true testsuite name=Zend Framework Unit Testing directory./directory /testsuite filter whitelist directory suffix=.php../library/directory directory suffix=.php../application/directory exclude directory suffix=.phtml../application/directory /exclude /whitelist /filter /phpunit TestHelper.php ?php /** * Set the environment to be testing. */ define('APPLICATION_ENVIRONMENT', 'testing'); /** * Sets the application path constant for file inclusion. */ define('APPLICATION_PATH', realpath(dirname(dirname(__FILE__)) . '/application/')); /** * Make the library/ sub-folder an include path. */ set_include_path( APPLICATION_PATH . '/../library' . PATH_SEPARATOR . get_include_path() ); echo get_include_path(); /** * Include the bootstrap file for testing - this is the same file used when * running the actual application. */ require_once '../application/bootstrap.php'; ? My Bootstrap.php in application/ ?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAutoload() { $moduleLoader = new Zend_Application_Module_Autoloader(array( 'namespace' = '', 'basePath' = APPLICATION_PATH)); return $moduleLoader; } } ? When I run phpunit in the tests directory I get Fatal error: Class 'Zend_Application_Bootstrap_Bootstrap' not found in C:\code\myApp\application\Bootstrap.php on line 3 The include path echoed is: C:\code\myApp\application/../library;.;C:\xampp\php\pear\ Thanks for any help. -- View this message in context: http://n4.nabble.com/Bootstrapping-modules-and-testing-tp680333p680333.html Sent from the Zend Framework mailing list archive at Nabble.com.