コード例 #1
0
 public function setup()
 {
     $cache = new \Prismic\Cache\ApcCache();
     $cache->clear();
     $sl = bootstrap::getServiceManager();
     $this->context = $sl->get('NetgluePrismic\\Context');
 }
コード例 #2
0
 public function testInstance()
 {
     $sl = bootstrap::getServiceManager();
     $service = $sl->get('NetgluePrismic\\Service\\Sitemap');
     $this->assertInstanceOf('NetgluePrismic\\Service\\Sitemap', $service);
     return $service;
 }
コード例 #3
0
 public function getServiceManager()
 {
     $services = bootstrap::getServiceManager();
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('ApplicationConfig', $services->get('ApplicationConfig'));
     $serviceManager->get('ModuleManager')->loadModules();
     return $serviceManager;
 }
コード例 #4
0
 public function testGetViewHelper()
 {
     $services = bootstrap::getServiceManager();
     $manager = $services->get('ViewHelperManager');
     $helper = $manager->create('NetgluePrismic\\View\\Helper\\Finder');
     $this->assertInstanceOf('NetgluePrismic\\View\\Helper\\Finder', $helper);
     $this->assertInstanceOf('NetgluePrismic\\Context', $helper->getContext());
     return $helper;
 }
コード例 #5
0
 public function testSetGetDocument()
 {
     $services = bootstrap::getServiceManager();
     $manager = $services->get('ViewHelperManager');
     $helper = $manager->get('NetgluePrismic\\View\\Helper\\EditAtPrismic');
     $this->assertNull($helper->getDocument());
     $helper->setDocument($this->document);
     $this->assertSame($this->document, $helper->getDocument());
     return $helper;
 }
コード例 #6
0
 /**
  * @depends testSetGetController
  */
 public function testMockParams(Prismic $plugin)
 {
     $mockParams = $this->getMock('\\Zend\\Mvc\\Controller\\Plugin\\Params');
     $mockParams->expects($this->any())->method('fromRoute')->will($this->returnValue('unit-test-bookmark'));
     $this->mockParams = $mockParams;
     $services = bootstrap::getServiceManager();
     $manager = $services->get('ControllerPluginManager');
     $manager->setService('params', $mockParams);
     $this->assertSame('unit-test-bookmark', $plugin->getBookmarkNameFromRoute());
     $document = $plugin->getDocument();
     $this->assertInstanceOf('Prismic\\Document', $document);
     return $document;
 }
コード例 #7
0
 public function getContainer()
 {
     $services = bootstrap::getServiceManager();
     return $services->get('NetgluePrismic\\Session\\PrismicContainer');
 }
コード例 #8
0
 public function getHelper()
 {
     $services = bootstrap::getServiceManager();
     $manager = $services->get('ViewHelperManager');
     return $manager->get('NetgluePrismic\\View\\Helper\\Prismic');
 }
コード例 #9
0
 public function setUp()
 {
     $services = bootstrap::getServiceManager();
     $this->context = $services->get('Prismic\\Context');
     $this->context->getPrismicApi()->getCache()->clear();
 }
コード例 #10
0
    }
    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();
コード例 #11
0
 public function setUp()
 {
     $services = bootstrap::getServiceManager();
     $this->api = $services->get('Prismic\\Api');
 }