/**
  * Short description of method check
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return common_configuration_Report
  */
 public function check()
 {
     $returnValue = null;
     $report = parent::check();
     $name = $this->getName();
     if ($report->getStatus() == common_configuration_Report::VALID) {
         $report->setMessage("Database Driver '{$name}' is available.");
     } else {
         $report->setMessage("Database Driver '{$name}' could not be found or is unavailable.");
     }
     $returnValue = $report;
     return $returnValue;
 }
Example #2
0
 function testPHPExtension()
 {
     // Testing PHPExtension existence and version is quite hard to do. Indeed,
     // it depends what the installed extensions are on the computers running the tests.
     // Thus, I decided to use the DOM extension as a test. I've never seen a PHP installation
     // without the DOM extension. It comes built-in except if you compile PHP with the
     // --disable-dom directive.
     // core tests.
     $ext = new common_configuration_PHPExtension(null, null, 'dom');
     $this->assertEquals($ext->getMin(), null);
     $this->assertEquals($ext->getMax(), null);
     $this->assertEquals($ext->getName(), 'dom');
     $this->assertEquals($ext->isOptional(), false);
     $ext->setMin('1.0');
     $this->assertEquals($ext->getMin(), '1.0');
     $ext->setMax('2.0');
     $this->assertEquals($ext->getMax(), '2.0');
     $ext->setName('foobar');
     $this->assertEquals($ext->getName(), 'foobar');
     // test with an extension that has no version information (hash) that
     // contains hash functions such as md5().
     // We consider that if there is no version information but the extension
     // is loaded, the report is always valid even if min and/or max version(s)
     // are specified.
     $ext = new common_configuration_PHPExtension(null, null, 'hash');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $ext->setMin('1.0');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $ext->setMax('2.0');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $ext->setMin(null);
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     // test with the dom extension that has version information.
     $ext = new common_configuration_PHPExtension('19851127', '20090601', 'dom');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $ext->setMin('20050112');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::INVALID);
     $ext->setMin(null);
     $ext->setMax('20020423');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::INVALID);
     $ext->setMin('20010731');
     $ext->setMax(null);
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     // Unexisting extension.
     $ext = new common_configuration_PHPExtension('1.0', '1.4', 'foobar');
     $report = $ext->check();
     $this->assertEquals($report->getStatus(), common_configuration_Report::UNKNOWN);
 }