Skip to content

Instantly share code, notes, and snippets.

@stefanotorresi
Last active August 29, 2015 14:23
Show Gist options
  • Save stefanotorresi/1efd762fd1ad05f70559 to your computer and use it in GitHub Desktop.
Save stefanotorresi/1efd762fd1ad05f70559 to your computer and use it in GitHub Desktop.
Functional test on a ZF2 application
<?php
use Zend\Test\PHPUnit\Controller\AbstractControllerTestCase as TestCase;
abstract class AbstractFunctionalTestCase extends TestCase
{
public function setUp()
{
// assumes cwd is project root
$config = include 'config/application.config.php';
$config['config_cache_enabled'] = false;
// loads *test.php files from `config/autoload`
$config['module_listener_options']['config_glob_paths'] = [
'config/autoload/{,*.}{global,test}.php',
];
$this->setApplicationConfig($config);
parent::setUp();
}
}
<?php
class SomeServiceFunctionalTest extends AbstractFunctionalTestCase
{
public fucntion testFunctionalDI()
{
$dependency = $this->getApplicationServiceLocator()->get('ConcreteDependency');
$someService = new SomeService($dependency);
// run assertions on $someService;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment