Ejemplo n.º 1
0
 /**
  * Before executing an it() spec it should be setup like a test case.
  *
  * @param Spec $spec
  */
 public function beforeSpec(Spec $spec)
 {
     self::$testCase->setUp();
     self::$result->startTest(self::$test);
     /** @var Closure $closure */
     $closure = self::$testCase->getProperty($spec, 'closure');
     // This will not be set for incomplete specs.
     if (!$closure) {
         return;
     }
     $suite = self::$testCase->getProperty($spec, 'suite');
     $newSuite = new ProxySuite($spec->getTitle(), $closure, $suite);
     $reflection = new \ReflectionClass($suite);
     foreach ($reflection->getProperties() as $property) {
         $v = self::$testCase->getProperty($suite, $property->getName());
         self::$testCase->setProperty($newSuite, $property->getName(), $v);
     }
     /** @noinspection PhpUndefinedMethodInspection */
     $closure = $closure->bindTo($newSuite);
     self::$testCase->setProperty($spec, 'closure', $closure);
 }