/** * Get storage * * @return Storage */ public function getStorage() { if (!$this->storage instanceof Storage) { $this->storage = Manager::getStorage($this->getConnectionName()); } return $this->storage; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { Manager::addDefaultConnectionConfig('sqlite', ':memory:', null, null, '127.0.0.1', null, array(PDO::ATTR_PERSISTENT => true)); Manager::setModelPath(dirname(__FILE__) . '/_testdata/'); $storage = Manager::getStorage(); $storage->getConnection()->exec(file_get_contents(dirname(__FILE__) . '/_testdata/schema.sql')); $storage->getConnection()->exec(file_get_contents(dirname(__FILE__) . '/_testdata/fixture.sql')); }
/** * Test * * @test * * @return void */ public function getConnection() { $this->assertTrue(Manager::getStorage() instanceof Storage); $this->assertTrue(Manager::getStorage() instanceof MongoStorage); }
/** * Test * * @tests * @expectedException InvalidArgumentException * * @return void */ public function throwsExceptionOnWrongName() { Manager::getStorage("qwe"); }