save() public method

Persist current instance
public save ( ) : Container
return Container
Example #1
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'));
 }