public function testClassLoader()
 {
     $classLoader = new ClassLoader('ClassLoaderTest');
     $classLoader->setIncludePath(__DIR__);
     $classLoader->setFileExtension('.class.php');
     $classLoader->setNamespaceSeparator('_');
     $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true);
     $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true);
     $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true);
 }
Exemple #2
0
 public function testMultipleAutoloadRequestsWillProduceSameResult()
 {
     $classLoader = new ClassLoader();
     $classLoader->setIncludePath(__DIR__);
     $classLoader->setFileExtension('.class.php');
     $classLoader->setNamespaceSeparator('_');
     $this->assertTrue($classLoader->loadClass('ClassLoaderTest_ClassA'));
     $this->assertTrue($classLoader->loadClass('ClassLoaderTest_ClassA'));
 }
Exemple #3
0
 protected function _initDoctrine()
 {
     $appDoctrineConfig = $this->getOption('doctrine');
     $classLoader = new DoctrineClassLoader('Doctrine');
     $classLoader->setIncludePath(realpath(APPLICATION_PATH . '/../library'));
     $classLoader->register();
     $config = new DoctrineConfiguration();
     if (isset($appDoctrineConfig['cache'])) {
         switch ($appDoctrineConfig['cache']) {
             case 'array':
                 $cache = new DoctrineArrayCache();
                 break;
             case 'apc':
                 $cache = new DoctrineApcCache();
                 break;
         }
         $config->setQueryCacheImpl($cache);
         $config->setMetadataCacheImpl($cache);
     }
     $proxyDir = empty($appDoctrineConfig['proxyDir']) ? APPLICATION_PATH . '/../library/Orm/Proxies' : $appDoctrineConfig['proxyDir'];
     $config->setProxyDir(realpath($proxyDir));
     $config->setProxyNamespace('Orm\\Proxies');
     $config->setAutoGenerateProxyClasses(false);
     $config->setEntityNamespaces(array('Orm\\Entity'));
     $config->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\StaticPHPDriver(realpath(APPLICATION_PATH . '/../library/Orm/Entity')));
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $config->setSQLLogger(null);
     $db = $this->getResource('db');
     $dbConfig = $db->getConfig();
     $connectionOptions = array('pdo' => $db->getConnection(), 'dbname' => $dbConfig['dbname']);
     $entityManager = DoctrineEntityManager::create($connectionOptions, $config);
     $entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
     Registry::setEntityManager($entityManager);
     return $entityManager;
 }