Author: Victor Farazdagi
Inheritance: implements Serializable, implements ArrayAccess, implements Phrozn\Registry\Has\Dao, implements Phrozn\Registry\Has\Values
Exemple #1
0
 public function testNoRegistryFile()
 {
     $container = new Container();
     $arr = array(1, 2, 3);
     $container->set('template', $arr);
     $dao = new Dao($container);
     $dao->setOutputFile('not-found');
     $this->assertSame($arr, $container->get('template'));
     $dao->read();
     $this->assertNull($container->getValues());
     $this->assertNull($container->get('template'));
 }
Exemple #2
0
 public function testBundleInstall()
 {
     // container is inited with default values
     $this->assertSame(array(), $this->container->get('installed'));
     $this->assertFalse($this->container->isInstalled('test.bundle'));
     $this->container->markAsInstalled('test.bundle', array());
     $this->assertTrue($this->container->isInstalled('test.bundle'));
     $container = new Container();
     $path = dirname(__FILE__) . '/../project';
     $container->getDao()->setProjectPath($path);
     $this->assertSame(array(), $container->get('installed'));
     $container->read();
     $this->assertSame(array('test.bundle'), $container->get('installed'));
 }
Exemple #3
0
 /**
  * Get registry container
  *
  * @return \Phrozn\Registry\Container
  */
 public function getRegistryContainer()
 {
     if (null === $this->registryContainer) {
         $dao = new RegistryDao();
         $dao->setProjectPath($this->getProjectPath())->setOutputFile('.bundles');
         $this->registryContainer = new RegistryContainer($dao);
         $this->registryContainer->read();
         //(re)read container values
     } else {
         // update project path
         $this->registryContainer->getDao()->setProjectPath($this->getProjectPath());
     }
     return $this->registryContainer;
 }
Exemple #4
0
 /**
  * (Re)read current container from DAO
  *
  * @return \Phrozn\Registry\Container
  */
 public function read()
 {
     parent::read();
     $this->init();
     // re-initialize container
     return $this;
 }
Exemple #5
0
 public function testSaveWithImplicitDao()
 {
     $path = dirname(__FILE__) . '/project';
     $container = new Container();
     $this->assertInstanceOf('Phrozn\\Registry\\Dao', $container->getDao());
     $container->getDao()->setProjectPath($path);
     $this->assertSame($path . '/.phrozn', $container->getDao()->getProjectPath());
     $container->set('bundle', 'test.me')->set('template', array(1, 2, 3));
     @unlink($path . '/.phrozn/.registry');
     $this->assertFalse(file_exists($path . '/.phrozn/.registry'));
     $container->save();
     $this->assertTrue(file_exists($path . '/.phrozn/.registry'));
     $this->assertSame(file_get_contents($path . '/registry.serialized'), file_get_contents($path . '/.phrozn/.registry'));
     unset($container);
     $container = new Container();
     $container->getDao()->setProjectPath($path);
     $this->assertNull($container->get('bundle'));
     $this->assertNull($container->get('template'));
     $container->read();
     $this->assertSame('test.me', $container->get('bundle'));
     $this->assertSame(array(1, 2, 3), $container->get('template'));
 }