Zend Framework 2 using CodeCeption
Found this in the codeception docs: http://codeception.com/docs/modules/ZF2
This github project has an example: https://github.com/Danielss89/zf2-codeception
source to share
I solved this problem using PHPUnit. I have followed the Zend PHPUnit tutorial, http://framework.zend.com/manual/current/en/tutorials/unittesting.html , that just got to me. But I was able to load Zend using phpunit.xml file and point to _bootstrap.php. Codeception can also load my tests using the _bootstrap.php file. So now I can run my tests using both:
phpunit --bootstrap tests / unit / _bootstrap.php
and
php / bin / codecept block provider
I was surprised to see how few examples there are for this. I wrote tests for a job queue client. Here's a bit of my test:
protected function setUp()
{
$this->serviceManager = new ServiceManager(new ServiceManagerConfig());
$config = Bootstrap::getConfig();
$this->serviceManager->setService('ApplicationConfig', $config);
$this->serviceManager->get('ModuleManager')->loadModules();
$this->client = $this->serviceManager->get('jobclient');
$this->client->addServers(array(array('ip' => '127.0.0.1', 'port' => '666')));
}
public function testServiceCreateSuccess() {
$this->client->setQueue($this->testData['queue']);
$this->assertEquals($this->client->getQueue(), $this->testData['queue'], 'We get the expected queue');
}
I made fun of the job client and had a local configuration. My _bootstrap.php file looks basically the same as the Zend example, except that I use the factories defined in the service configuration to manage some of the objects. So, I have implemented the setService method in the test setup, not in the bootsrap initialization.
source to share