/** * Skip the test if a MySQL adapter configuration is unavailable and preload test data. */ public function skip() { $this->skipIf(!MySql::enabled(), 'MySQL Extension is not loaded'); $dbConfig = Connections::get('test', array('config' => true)); $hasDb = isset($dbConfig['adapter']) && $dbConfig['adapter'] == 'MySql'; $message = 'Test database is either unavailable, or not using a MySQL adapter'; $this->skipIf(!$hasDb, $message); $this->db = new MySql($dbConfig); }
public function testEnabledFeatures() { $supported = array('booleans', 'schema', 'relationships', 'sources'); $notSupported = array('arrays', 'transactions'); foreach ($supported as $feature) { $this->assertTrue(MySql::enabled($feature)); } foreach ($notSupported as $feature) { $this->assertFalse(MySql::enabled($feature)); } $this->assertNull(MySql::enabled('unexisting')); }
public function testConnectionGetAndReset() { Connections::add('conn-test', $this->config); Connections::add('conn-test-2', $this->config); $this->assertEqual(array('conn-test', 'conn-test-2'), Connections::get()); $this->skipIf(!MySql::enabled(), 'MySql is not enabled'); $this->skipIf(!$this->_canConnect('localhost', 3306), 'Cannot connect to localhost:3306'); $expected = $this->config + array('type' => 'database', 'filters' => array()); $this->assertEqual($expected, Connections::get('conn-test', array('config' => true))); $this->assertNull(Connections::reset()); $this->assertFalse(Connections::get()); $this->assertTrue(is_array(Connections::get())); }
public function testConnectionAutoInstantiation() { Connections::add('conn-test', $this->config); Connections::add('conn-test-2', $this->config); $this->skipIf(!MySql::enabled(), 'MySql is not enabled'); $this->skipIf(!$this->_canConnect('localhost', 3306), 'Cannot connect to localhost:3306'); $this->expectException('/mysql_get_server_info/'); $this->expectException('/mysql_select_db/'); $this->expectException('/mysql_pconnect/'); $result = Connections::get('conn-test'); $this->assertTrue($result instanceof MySql); $result = Connections::get('conn-test'); $this->assertTrue($result instanceof MySql); $this->assertNull(Connections::get('conn-test-2', array('autoCreate' => false))); }
/** * Skip the test if a MySQL or PostgreSQL adapter configuration is unavailable and * preload test data. */ public function skip() { $enabled = MySql::enabled() || PostgreSql::enabled(); $this->skipIf(!$enabled, 'MySQL or PostgreSQL Extension is not loaded'); $dbConfig = Connections::get('test', array('config' => true)); $validAdapter = in_array($dbConfig['adapter'], array('MySql', 'PostgreSql')); $hasDb = isset($dbConfig['adapter']) && $validAdapter; $message = 'Test database is either unavailable, or not using a MySQL/PostgreSQL adapter'; $this->skipIf(!$hasDb, $message); switch ($dbConfig['adapter']) { case "MySql": $this->db = new MySql($dbConfig); $this->mockPrefix = 'mysql'; break; case "PostgreSql": $this->db = new PostgreSql($dbConfig); $this->mockPrefix = 'postgresql'; break; } }
public function testConnectionGetAndReset() { Connections::add('conn-test', $this->config); Connections::add('conn-test-2', $this->config); $this->assertEqual(array('conn-test', 'conn-test-2'), Connections::get()); $enabled = MySql::enabled() || PostgreSql::enabled(); $this->skipIf(!$enabled, 'MySql or PostgreSQL is not enabled'); if (MySql::enabled()) { $this->_port = 3306; } if (PostgreSql::enabled()) { $this->_port = 5432; } $msg = "Cannot connect to localhost:{$this->_port}"; $this->skipIf(!$this->_canConnect('localhost', $this->_port), $msg); $expected = $this->config + array('type' => 'database', 'filters' => array()); $this->assertEqual($expected, Connections::get('conn-test', array('config' => true))); $this->assertNull(Connections::reset()); $this->assertFalse(Connections::get()); $this->assertTrue(is_array(Connections::get())); }
public function testEnabledFeatures() { $this->assertTrue(MySql::enabled()); $this->assertTrue(MySql::enabled('relationships')); $this->assertFalse(MySql::enabled('arrays')); }