/**
  * Tests JsFeatureLoader->loadFeatures()
  */
 public function testLoadFeatures()
 {
     $registry = new GadgetFeatureRegistry('');
     if (file_put_contents($this->FeatureScript, $this->JsFeaturesFileContent)) {
         if (file_exists($this->FeatureScript) && is_readable($this->FeatureScript)) {
             $features = $this->JsFeatureLoader->loadFeatures($this->FeatureScript, $registry);
             foreach ($features as $feature) {
                 $this->assertTrue($feature->name == $this->FeatureName);
             }
         }
     } else {
         $this->fail('Error creating the dummie fail');
     }
 }
예제 #2
0
 public function registerFeatures($featurePath)
 {
     if (empty($featurePath) || $featurePath == null) {
         return;
     }
     $loader = new JsFeatureLoader();
     $jsFeatures = $loader->loadFeatures($featurePath, $this);
     if (!$this->coreDone) {
         foreach ($jsFeatures as $entry) {
             if (strtolower(substr($entry->name, 0, strlen('core'))) == 'core') {
                 $this->core[$entry->name] = $entry->name;
             }
         }
         // Make sure non-core features depend on core.
         foreach ($jsFeatures as $entry) {
             if (strtolower(substr($entry->name, 0, strlen('core'))) != 'core') {
                 $entry->deps = array_merge($entry->deps, $this->core);
             }
         }
         $this->coreDone = true;
     }
 }