/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->object = new Layout(); $this->object->setViewPath(__DIR__ . '/layouts'); $this->object->setScriptName("layout.phtml"); }
$app->setControllerPath(__DIR__ . '/../app/controllers'); $classLoader = new \Doctrine\Common\ClassLoader('Wdm', __DIR__ . '/../app/models'); $classLoader->register(); $app->bootstrap("config", function () { $config = new Config(); $config->load(__DIR__ . '/../app/configs/application.ini'); return $config; }); $app->bootstrap("view", function () { $view = new View(); $view->setViewPath(__DIR__ . '/../app/views'); return $view; }); $app->bootstrap("layout", function () { $layout = new Layout(); $layout->setViewPath(__DIR__ . '/../app/layouts'); return $layout; }); $app->bootstrap("entityManager", function () use($app) { $config = new \Doctrine\ORM\Configuration(); // (2) // Proxy Configuration $config->setProxyDir(__DIR__ . '/../app/models/Wdm/Proxies'); $config->setProxyNamespace('Wdm\\Proxies'); $config->setAutoGenerateProxyClasses(APPLICATION_ENV == "development"); // Mapping Configuration $driverImpl = $config->newDefaultAnnotationDriver(__DIR__); $config->setMetadataDriverImpl($driverImpl); $entityManager = \Doctrine\ORM\EntityManager::create($app->getBootstrap()->getResource("config")->database()->toArray(), $config); return $entityManager; });
public function testLayoutViewHelpersPass() { $this->object->bootstrap('layout', function () { $l = new Layout(); $l->setScriptName("title-helper.phtml"); $l->setViewPath(__DIR__ . '/layouts'); return $l; }); $this->object->bootstrap('view', function () { $v = new View(); $v->setViewPath(__DIR__ . '/views'); $v->addHelper("title", function ($part = false) { static $parts = array(); static $delimiter = ' :: '; return $part === false ? implode($delimiter, $parts) : ($parts[] = $part); }); return $v; }); ob_start(); $this->object->run(new Request("/general/title-helper")); $content = ob_get_contents(); ob_end_clean(); $this->assertEquals("<title>the title helper :: second</title>", $content); }