public function setUp() { parent::setUp(); $this->service = Bootstrap::getServiceManager()->get('ConVarnish\\Service\\VarnishService'); $this->adapter = new Test(); $this->service->getClient()->setAdapter($this->adapter); }
public function testInvoke() { $renderer = new PhpRenderer(); /* @var $url Url */ $url = $renderer->plugin('url'); $url->setRouter(Bootstrap::getServiceManager()->get('HttpRouter')); $esiUrl = new EsiUrl(); $esiUrl->setView($renderer); $this->assertEquals('/esi/my-block', call_user_func($esiUrl, 'my-block')); $this->assertEquals('/esi/my-block?handles%5B0%5D=handle1&handles%5B1%5D=handle2', call_user_func($esiUrl, 'my-block', ['handle1', 'handle2'])); }
public function testOnBootstrap() { $event = new MvcEvent(); $application = new Application([], Bootstrap::getServiceManager()); $em = new EventManager(); $application->setEventManager($em); $event->setApplication($application); $isConsole = Console::isConsole(); Console::overrideIsConsole(false); $this->module->onBootstrap($event); Console::overrideIsConsole($isConsole); $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_DISPATCH)); $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_RENDER)); }
} protected static function initAutoloader() { $vendorPath = static::findParentPath('vendor'); if (is_readable($vendorPath . '/autoload.php')) { $loader = (include $vendorPath . '/autoload.php'); } else { $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false)); if (!$zf2Path) { throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; } AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__)))); } protected static function findParentPath($path) { $dir = __DIR__; $previousDir = '.'; while (!is_dir($dir . '/' . $path)) { $dir = dirname($dir); if ($previousDir === $dir) { return false; } $previousDir = $dir; } return $dir . '/' . $path; } } Bootstrap::init();