public function testInit() { $container = new Container(); $dao = new Dao($container); $this->assertInstanceOf('Phrozn\\Registry\\Container', $container); $this->assertSame($container, $dao->getContainer()); // test project path setting $this->assertNull($dao->getProjectPath()); $projectPath = dirname(__FILE__) . '/../project/'; $dao->setProjectPath($projectPath); $this->assertSame(realpath($projectPath . '/.phrozn'), $dao->getProjectPath()); // test output file $this->assertSame('.registry', $dao->getOutputFile()); $this->assertSame('.bundles', $dao->setOutputFile('.bundles')->getOutputfile()); }
public function testSave() { $dao = new Dao(); $path = dirname(__FILE__) . '/project'; $dao->setProjectPath($path); $this->assertSame($path . '/.phrozn', $dao->getProjectPath()); $container = new Container($dao); $this->assertSame($dao, $container->getDao()); $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($dao); $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')); }