示例#1
0
 public function configureDi(AbstractTestCase $testCase)
 {
     if (!$this->testCaseConfigurationObject instanceof TestCaseConfiguration) {
         if ($testCase->getDi() instanceof Di) {
             $testCaseConfiguration = $testCase->get($this->testCaseConfiguration);
             if ($testCaseConfiguration instanceof TestCaseConfiguration) {
                 $this->testCaseConfigurationObject = $testCaseConfiguration;
             }
         } else {
             $this->testCaseConfigurationObject = new $this->testCaseConfiguration($this->configurationProvider, new DefaultPropertyCollector());
         }
     }
     if ($testCase->getDi() instanceof Di) {
         return;
     }
     /* @var $configuration TestCaseConfiguration */
     $configArray = $this->getDefaultConfiguration();
     $count = 0;
     $path = realpath(__DIR__ . '/../');
     while ($count++ < 5) {
         $dir = "{$path}/configuration/";
         if (is_dir($dir)) {
             foreach (glob($dir . '*.php') as $file) {
                 $configArray = array_merge_recursive($configArray, include $file);
             }
             break;
         }
         $path .= '/../';
     }
     $configArray = $this->testCaseConfigurationObject->reprocessConfiguration($configArray);
     $configuration = new Config($configArray);
     $di = new Di();
     $configuration->configure($di);
     $testCase->setDi($di);
     $di->instanceManager()->addSharedInstance($di, Di::class);
     $this->setConfigurationProvider($testCase);
 }