/** * 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::setModelPath(dirname(__FILE__) . '/_testdata/'); Manager::addDefaultConnectionConfig('sqlite', ':memory:', null, null, '127.0.0.1', null, array(PDO::ATTR_PERSISTENT => true)); $dbPath = dirname(__FILE__) . '/_testdata/test.sqlite'; touch($dbPath); Manager::addConnectionConfig('tick_connection', 'sqlite', $dbPath); $storage = Manager::getStorage(); $storage->getConnection()->exec(file_get_contents(dirname(__FILE__) . '/_testdata/schema.sql')); $storage = Manager::getStorage("tick_connection"); $storage->getConnection()->exec(file_get_contents(dirname(__FILE__) . '/_testdata/schema.sql')); }
/** * Test * * @test * * @return void */ public function removeAllConnectionsBoth() { Manager::addConnectionConfig('my_connection', 'sqlite', ':memory:'); Manager::getStorage("my_connection"); Manager::addDefaultConnectionConfig('sqlite', ':memory:'); Manager::getStorage(); $this->assertNotNull($GLOBALS["TickConnection:my_connection"]); $this->assertNotNull($GLOBALS["TickConnection:default"]); Manager::removeAllConnections(); $this->assertFalse(key_exists("TickConnection:my_connection", $GLOBALS)); $this->assertFalse(key_exists("TickConnection:default", $GLOBALS)); }