enabled() public static method

Check for required PHP extension, or supported database feature.
public static enabled ( string $feature = null ) : boolean
$feature string Test for support for a specific feature, i.e. `"transactions"` or `"arrays"`.
return boolean Returns `true` if the particular feature (or if PostgreSQL) support is enabled, otherwise `false`.
Example #1
0
 public function testEnabledFeatures()
 {
     $supported = array('booleans', 'schema', 'relationships', 'sources', 'transactions');
     $notSupported = array('arrays');
     foreach ($supported as $feature) {
         $this->assertTrue(PostgreSql::enabled($feature));
     }
     foreach ($notSupported as $feature) {
         $this->assertFalse(PostgreSql::enabled($feature));
     }
     $this->assertNull(PostgreSql::enabled('unexisting'));
 }
 /**
  * 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(PostgreSql::enabled());
     $this->assertTrue(PostgreSql::enabled('relationships'));
     $this->assertFalse(PostgreSql::enabled('arrays'));
 }