-
-
Save tawfekov/4708316 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$additionalNamespaces = null; | |
$rootPath = realpath(dirname(__DIR__)); | |
$testsPath = "$rootPath/tests"; | |
if (is_readable($testsPath . '/TestConfiguration.php')) { | |
require_once $testsPath . '/TestConfiguration.php'; | |
} else { | |
require_once $testsPath . '/TestConfiguration.php.dist'; | |
} | |
$path = array( | |
ZF2_PATH, | |
get_include_path(), | |
); | |
set_include_path(implode(PATH_SEPARATOR, $path)); | |
use Zend\Loader\AutoloaderFactory; | |
use Zend\Loader\StandardAutoloader; | |
require_once 'Zend/Loader/AutoloaderFactory.php'; | |
require_once 'Zend/Loader/StandardAutoloader.php'; | |
// setup autoloader | |
AutoloaderFactory::factory( | |
array( | |
'Zend\Loader\StandardAutoloader' => array( | |
StandardAutoloader::AUTOREGISTER_ZF => true, | |
StandardAutoloader::ACT_AS_FALLBACK => false, | |
StandardAutoloader::LOAD_NS => $additionalNamespaces, | |
) | |
) | |
); | |
$appConfig = include $rootPath . '/config/application.config.php'; | |
$appConfig['module_listener_options']['config_cache_enabled'] = false; | |
Zend\Loader\AutoloaderFactory::factory($appConfig['autoloaders']); | |
$modules = array( | |
'ModuleB', | |
); | |
$vendorModules = array( | |
'VendorModuleA', | |
); | |
foreach (array_merge($modules, $vendorModules) as $moduleName) { | |
$moduleTestCaseClassname = '\\'.$moduleName.'Test\\Framework\\TestCase'; | |
$listenerOptions = new Zend\ModuleManager\Listener\ListenerOptions($appConfig['module_listener_options']); | |
$defaultListeners = new Zend\ModuleManager\Listener\DefaultListenerAggregate($listenerOptions); | |
$moduleManager = new \Zend\ModuleManager\ModuleManager(array($moduleName)); | |
$moduleManager->getEventManager()->attachAggregate($defaultListeners); | |
$moduleManager->loadModules(); | |
if (method_exists($moduleTestCaseClassname, 'setLocator')) { | |
$config = $defaultListeners->getConfigListener()->getMergedConfig(); | |
$di = new \Zend\Di\Di; | |
$di->instanceManager()->addTypePreference('Zend\Di\LocatorInterface', $di); | |
$diConfig = new \Zend\Di\Configuration($config['di']); | |
$diConfig->configure($di); | |
$routerDiConfig = new \Zend\Di\Configuration( | |
array( | |
'definition' => array( | |
'class' => array( | |
'Zend\Mvc\Router\RouteStackInterface' => array( | |
'instantiator' => array( | |
'Zend\Mvc\Router\Http\TreeRouteStack', | |
'factory' | |
), | |
), | |
), | |
), | |
) | |
); | |
$routerDiConfig->configure($di); | |
call_user_func_array($moduleTestCaseClassname.'::setLocator', array($di)); | |
} | |
// When this is in global scope, PHPUnit catches exception: | |
// Exception: Zend\Stdlib\PriorityQueue::serialize() must return a string or NULL | |
unset($moduleManager); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<phpunit verbose="true" bootstrap="tests/bootstrap.php"> | |
<logging> | |
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/> | |
</logging> | |
<filter> | |
<blacklist> | |
<directory>vendor/ZendFramework</directory> | |
<directory>vendor/ZfcBase</directory> | |
<directory>vendor/ZfcUser</directory> | |
<directory suffix=".phtml">module</directory> | |
</blacklist> | |
</filter> | |
<testsuites> | |
<testsuite name="VendorModuleA"> | |
<directory>vendor/VendorModuleA/tests/VendorModuleA</directory> | |
</testsuite> | |
<testsuite name="ModuleB"> | |
<directory>module/ModuleB/tests</directory> | |
</testsuite> | |
</testsuites> | |
</phpunit> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('ZF2_PATH', realpath(__DIR__ . '/../vendor/ZendFramework/library')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment