Beispiel #1
0
 /**
  * Get the ComponentCollection corresponding to the distribution. It
  * the configuration checks to perform for all extensions involved in the
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param array $extensionIds
  * @return common_configuration_ComponentCollection
  */
 public static function getConfigChecker($extensionIds)
 {
     $returnValue = new common_configuration_ComponentCollection();
     $checkArray = array();
     // resolve dependencies
     foreach (self::getRawChecks($extensionIds) as $c) {
         $checkArray[] = $c;
         $comp = common_configuration_ComponentFactory::buildFromArray($c);
         if (!empty($c['value']['id'])) {
             $componentArray[$c['value']['id']] = $comp;
         }
         $returnValue->addComponent($comp);
         if (!empty($c['value']['silent']) && $c['value']['silent'] == true) {
             $returnValue->silent($comp);
         }
     }
     // Deal with the dependencies.
     foreach ($checkArray as $config) {
         if (!empty($config['value']['dependsOn']) && is_array($config['value']['dependsOn'])) {
             foreach ($config['value']['dependsOn'] as $d) {
                 // Find the component it depends on and tell the ComponentCollection.
                 if (!empty($componentArray[$config['value']['id']]) && !empty($componentArray[$d])) {
                     $returnValue->addDependency($componentArray[$config['value']['id']], $componentArray[$d]);
                 }
             }
         }
     }
     return $returnValue;
 }
 public static function buildComponent(tao_install_services_Data $data)
 {
     $content = json_decode($data->getContent(), true);
     $extensionName = $content['value']['name'];
     if (isset($content['value']['optional'])) {
         $optional = $content['value']['optional'];
     } else {
         $optional = false;
     }
     return common_configuration_ComponentFactory::buildPHPDatabaseDriver($extensionName, $optional);
 }
 public static function buildComponent(tao_install_services_Data $data)
 {
     $content = json_decode($data->getContent(), true);
     $min = $content['value']['min'];
     $max = isset($content['value']['max']) ? $content['value']['max'] : null;
     if (isset($content['value']['optional'])) {
         $optional = $content['value']['optional'];
     } else {
         $optional = false;
     }
     return common_configuration_ComponentFactory::buildPHPRuntime($min, $max, $optional);
 }
 private static function getAvailableDrivers()
 {
     $compatibleDrivers = array('pdo_mysql', 'pdo_pgsql', 'pdo_sqlsrv', 'pdo_oci');
     $availableDrivers = array();
     foreach ($compatibleDrivers as $cD) {
         $check = common_configuration_ComponentFactory::buildPHPDatabaseDriver($cD);
         $report = $check->check();
         if ($report->getStatus() == common_configuration_Report::VALID) {
             $availableDrivers[] = $cD;
         }
     }
     return $availableDrivers;
 }
 public function check()
 {
     // One of these drivers must be found.
     $drivers = array('pdo_mysql', 'pdo_pgsql', 'pdo_sqlsrv', 'pdo_oci');
     foreach ($drivers as $d) {
         $dbCheck = common_configuration_ComponentFactory::buildPHPDatabaseDriver($d);
         $dbReport = $dbCheck->check();
         if ($dbReport->getStatus() == common_configuration_Report::VALID) {
             return new common_configuration_Report($dbReport->getStatus(), "A suitable database driver is available.", $this);
         }
     }
     return new common_configuration_Report(common_configuration_Report::INVALID, "No suitable database driver detected. Drivers supported by TAO are: " . implode(', ', $drivers) . '.', $this);
 }
Beispiel #6
0
 public function testComponentFactory()
 {
     $component = common_configuration_ComponentFactory::buildPHPRuntime('5.0', '7.0.x', true);
     $this->assertIsA($component, 'common_configuration_PHPRuntime');
     $this->assertEquals($component->getMin(), '5.0');
     // 5.5.x will be replaced internally
     //$this->assertEquals($component->getMax(), '5.5.x');
     $this->assertTrue($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $component = common_configuration_ComponentFactory::buildPHPExtension('spl');
     $this->assertIsA($component, 'common_configuration_PHPExtension');
     $this->assertNull($component->getMin());
     $this->assertNull($component->getMax());
     $this->assertEquals($component->getName(), 'spl');
     $this->assertFalse($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $component = common_configuration_ComponentFactory::buildPHPExtension('spl', null, null, true);
     $this->assertIsA($component, 'common_configuration_PHPExtension');
     $this->assertEquals($component->getName(), 'spl');
     $this->assertTrue($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $component = common_configuration_ComponentFactory::buildPHPINIValue('magic_quotes_gpc', '0');
     $this->assertIsA($component, 'common_configuration_PHPINIValue');
     $this->assertEquals($component->getName(), 'magic_quotes_gpc');
     $this->assertFalse($component->isOptional());
     $component = common_configuration_ComponentFactory::buildPHPDatabaseDriver('pdo_mysql', true);
     $this->assertIsA($component, 'common_configuration_PHPDatabaseDriver');
     $this->assertEquals($component->getName(), 'pdo_mysql');
     $this->assertTrue($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $location = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ConfigurationTest.php';
     $component = common_configuration_ComponentFactory::buildFileSystemComponent($location, 'r');
     $this->assertIsA($component, 'common_configuration_FileSystemComponent');
     $this->assertFalse($component->isOptional());
     $this->assertEquals($component->getLocation(), $location);
     $this->assertEquals($component->getExpectedRights(), 'r');
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     // TAO Dependency
     /*$component = common_configuration_ComponentFactory::buildCustom('database_drivers', 'tao', false);
      	$this->assertIsA($component, 'common_configuration_Component');
      	$this->assertEquals($component->getName(), 'custom_tao_DatabaseDrivers');
      	$this->assertFalse($component->isOptional());*/
     $array = array('type' => 'PHPRuntime', 'value' => array('min' => '5.0', 'max' => '7.0.x', 'optional' => true));
     $component = common_configuration_ComponentFactory::buildFromArray($array);
     $this->assertIsA($component, 'common_configuration_PHPRuntime');
     $this->assertEquals($component->getMin(), '5.0');
     // 5.5.x will be replaced internally
     // $this->assertEquals($component->getMax(), '5.5');
     $this->assertTrue($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $array = array('type' => 'PHPExtension', 'value' => array('name' => 'spl'));
     $component = common_configuration_ComponentFactory::buildFromArray($array);
     $this->assertIsA($component, 'common_configuration_PHPExtension');
     $this->assertEquals($component->getName(), 'spl');
     $this->assertFalse($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     // 'Check' before the Component type is accepted.
     $array = array('type' => 'CheckPHPINIValue', 'value' => array('name' => 'magic_quotes_gpc', 'value' => '0'));
     $component = common_configuration_ComponentFactory::buildFromArray($array);
     $this->assertIsA($component, 'common_configuration_PHPINIValue');
     $this->assertEquals($component->getName(), 'magic_quotes_gpc');
     $this->assertFalse($component->isOptional());
     $array = array('type' => 'PHPDatabaseDriver', 'value' => array('name' => 'pdo_mysql', 'optional' => true));
     $component = common_configuration_ComponentFactory::buildFromArray($array);
     $this->assertIsA($component, 'common_configuration_PHPDatabaseDriver');
     $this->assertEquals($component->getName(), 'pdo_mysql');
     $this->assertTrue($component->isOptional());
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     $array = array('type' => 'FileSystemComponent', 'value' => array('location' => $location, 'rights' => 'r'));
     $component = common_configuration_ComponentFactory::buildFromArray($array);
     $this->assertIsA($component, 'common_configuration_FileSystemComponent');
     $this->assertFalse($component->isOptional());
     $this->assertEquals($component->getLocation(), $location);
     $this->assertEquals($component->getExpectedRights(), 'r');
     $report = $component->check();
     $this->assertIsA($report, 'common_configuration_Report');
     $this->assertEquals($report->getStatus(), common_configuration_Report::VALID);
     // TAO Dependency
     /*
     $array = array('type' => 'Custom', 'value' => array('name' => 'database_drivers', 'extension' => 'tao', 'optional' => false));
     $component = common_configuration_ComponentFactory::buildFromArray($array);
     $this->assertIsA($component, 'common_configuration_Component');
     $this->assertEquals($component->getName(), 'custom_tao_DatabaseDrivers');
     $this->assertFalse($component->isOptional());
     
     try{
     	$array = array('type' => 'Custom', 'value' => array('name' => 'mod_rewrite'));
     	$component = common_configuration_ComponentFactory::buildFromArray($array);
     	$this->assertTrue(false, 'An exception should be raised because mod_rewrite check does not exist for default extension generis.');
     }
     catch (common_configuration_ComponentFactoryException $e){
     	$this->assertTrue(true);
     }
     */
     try {
         $array = array('type' => 'PHPINIValue', 'value' => array());
         $component = common_configuration_ComponentFactory::buildFromArray($array);
         $this->assertTrue(false, 'An exception should be raised because of missing attributes.');
     } catch (common_configuration_ComponentFactoryException $e) {
         $this->assertTrue(true);
     }
 }
 public static function buildComponent(tao_install_services_Data $data)
 {
     $content = json_decode($data->getContent(), true);
     $location = $content['value']['location'];
     $rights = $content['value']['rights'];
     $recursive = isset($content['value']['recursive']) && (bool) $content['value']['recursive'];
     if (isset($content['value']['optional'])) {
         $optional = $content['value']['optional'];
     } else {
         $optional = false;
     }
     return common_configuration_ComponentFactory::buildFileSystemComponent($location, $rights, $optional, $recursive);
 }
 public static function buildComponent(tao_install_services_Data $data)
 {
     $content = json_decode($data->getContent(), true);
     $name = $content['value']['name'];
     if (isset($content['value']['optional'])) {
         $optional = $content['value']['optional'];
     } else {
         $optional = false;
     }
     $extension = $content['value']['extension'];
     try {
         return common_configuration_ComponentFactory::buildCustom($name, $extension, $optional);
     } catch (common_configuration_ComponentFactoryException $e) {
         return null;
     }
 }
 /**
  * Short description of method setMockCount
  *
  * @access private
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  int mockCount
  * @return void
  */
 private static function setMockCount($mockCount)
 {
     self::$mockCount = $mockCount;
 }
 public static function buildComponent(tao_install_services_Data $data)
 {
     $content = json_decode($data->getContent(), true);
     $driver = $content['value']['driver'];
     if (isset($content['value']['optional'])) {
         $optional = $content['value']['optional'];
     } else {
         $optional = false;
     }
     // Try such a driver. Because the provided driver name should
     // comply with a PHP Extension name (e.g. mysql, pgsql), we test its
     // existence.
     return common_configuration_ComponentFactory::buildPHPDatabaseDriver($driver, $optional);
 }