Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function tearDown(Environment $env, SpecificationIterator $iterator, $skip, TestResult $result)
 {
     $teardown = $this->baseTester->tearDown($env, $iterator, $skip, $result);
     if ($skip) {
         return $teardown;
     }
     $scope = new AfterSuiteScope($env, $iterator, $result);
     $hookCallResults = $this->hookDispatcher->dispatchScopeHooks($scope);
     return new HookedTeardown($teardown, $hookCallResults);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function tearDown(Environment $env, FeatureNode $feature, Scenario $scenario, $skip, TestResult $result)
 {
     $teardown = $this->baseTester->tearDown($env, $feature, $scenario, $skip, $result);
     if ($skip) {
         return $teardown;
     }
     $scope = new AfterScenarioScope($env, $feature, $scenario, $result);
     $hookCallResults = $this->hookDispatcher->dispatchScopeHooks($scope);
     return new HookedTeardown($teardown, $hookCallResults);
 }
Exemplo n.º 3
0
 /**
  * Helper function to create a term.
  *
  * @return object
  *   The created term.
  */
 public function termCreate($term)
 {
     // @todo this doesn't properly throw exceptions.
     $this->dispatcher->dispatchScopeHooks(new BeforeTermCreateScope($this->getDrupal()->getEnvironment(), $this, $term));
     $saved = $this->getDriver()->createTerm($term);
     $this->dispatcher->dispatchScopeHooks(new AfterTermCreateScope($this->getDrupal()->getEnvironment(), $this, $saved));
     $this->terms[] = $saved;
     return $saved;
 }
 public function test(Environment $env, $feature, $skip)
 {
     $results = array();
     foreach ($feature->getScenarios() as $scenario) {
         $isolatedEnvironment = $this->envManager->isolateEnvironment($env, $scenario);
         $block = new AroundHookScenarioBlock($scenario, $isolatedEnvironment, $feature, $skip, $this->scenarioTester, $this->outlineTester, $this->envManager);
         $scope = new AroundScenarioScope($isolatedEnvironment, $feature, $scenario, $block);
         $hookCallResults = $this->hookDispatcher->dispatchScopeHooks($scope);
         foreach ($hookCallResults as $callResult) {
             echo $callResult->getStdOut();
             if ($callResult->hasException()) {
                 throw $callResult->getException();
             }
         }
         if (count($hookCallResults) == 0) {
             $block->call();
         }
         $results = array_merge($results, $block->getResults());
     }
     return new TestResults($results);
 }
 /**
  * Dispatch scope hooks.
  *
  * @param string $scope
  *   The entity scope to dispatch.
  * @param stdClass $entity
  *   The entity.
  */
 protected function dispatchHooks($scopeType, \stdClass $entity)
 {
     $fullScopeClass = 'Drupal\\DrupalExtension\\Hook\\Scope\\' . $scopeType;
     $scope = new $fullScopeClass($this->getDrupal()->getEnvironment(), $this, $entity);
     $callResults = $this->dispatcher->dispatchScopeHooks($scope);
     // The dispatcher suppresses exceptions, throw them here if there are any.
     foreach ($callResults as $result) {
         if ($result->hasException()) {
             $exception = $result->getException();
             throw $exception;
         }
     }
 }