getClassName() public method

public getClassName ( ) : string
return string
Beispiel #1
0
 /**
  * @return mixed
  */
 public function duringInstantiation()
 {
     if ($factoryMethod = $this->wrappedObject->getFactoryMethod()) {
         $method = is_array($factoryMethod) ? $factoryMethod[1] : $factoryMethod;
     } else {
         $method = '__construct';
     }
     $instantiator = new Instantiator();
     $object = $instantiator->instantiate($this->wrappedObject->getClassName());
     return $this->runDuring($object, $method, $this->wrappedObject->getArguments());
 }
 /**
  * @param string        $alias
  * @param mixed         $subject
  * @param array         $arguments
  * @param WrappedObject $wrappedObject
  *
  * @return boolean
  *
  * @throws \Exception
  * @throws \PhpSpec\Exception\Example\ErrorException
  * @throws \Exception
  * @throws \PhpSpec\Exception\Fracture\FractureException
  */
 public function match($alias, $subject, array $arguments = array(), WrappedObject $wrappedObject = null)
 {
     try {
         $wrapped = $subject->getWrappedObject();
     } catch (ErrorException $e) {
         throw $e;
     } catch (FractureException $e) {
         throw $e;
     } catch (Exception $e) {
         if (null !== $wrappedObject && $wrappedObject->getClassName()) {
             $instantiator = new Instantiator();
             $wrapped = $instantiator->instantiate($wrappedObject->getClassName());
         }
     }
     return $this->getExpectation()->match($alias, $wrapped, $arguments);
 }
Beispiel #3
0
 function it_passes_the_created_subject_to_expectation(WrappedObject $wrappedObject, ExpectationFactory $expectationFactory, Expectation $expectation)
 {
     $expectation->match(Argument::cetera())->willReturn(true);
     $wrappedObject->getClassName()->willReturn('spec\\PhpSpec\\Wrapper\\Everything');
     $expectationFactory->create(Argument::cetera())->willReturn($expectation);
     $this->callOnWrappedObject('shouldBeAlright');
     $expectationFactory->create(Argument::any(), Argument::type('spec\\PhpSpec\\Wrapper\\Everything'), Argument::any())->shouldHaveBeenCalled();
 }
 function it_delegates_throwing_method_not_visible_exception(WrappedObject $wrappedObject, ExceptionFactory $exceptions)
 {
     $obj = new ExampleClass();
     $wrappedObject->isInstantiated()->willReturn(true);
     $wrappedObject->getInstance()->willReturn($obj);
     $wrappedObject->getClassName()->willReturn('spec\\PhpSpec\\Wrapper\\Subject\\ExampleClass');
     $exceptions->methodNotVisible('spec\\PhpSpec\\Wrapper\\Subject\\ExampleClass', 'privateMethod', array())->willReturn(new \PhpSpec\Exception\Fracture\MethodNotVisibleException('Method "privateMethod" not visible.', $obj, '"ExampleClass::privateMethod"', array()))->shouldBeCalled();
     $this->shouldThrow('\\PhpSpec\\Exception\\Fracture\\MethodNotVisibleException')->duringCall('privateMethod');
 }
Beispiel #5
0
 /**
  * @param string $property
  * @return bool
  */
 public function constantDefined($property)
 {
     return defined($this->wrappedObject->getClassName() . '::' . $property);
 }
 function it_ignores_any_other_exception(Subject $subject, WrappedObject $wrapped)
 {
     $subject->callOnWrappedObject('getWrappedObject', array())->willThrow('\\Exception');
     $wrapped->getClassName()->willReturn('\\stdClass');
     $this->shouldNotThrow('\\Exception')->duringMatch('be', $subject, array(), $wrapped);
 }
Beispiel #7
0
 /**
  * @return object
  */
 private function makeSureWeHaveASubject()
 {
     if (null === $this->subject && $this->wrappedObject->getClassName()) {
         $instantiator = new Instantiator();
         return $instantiator->instantiate($this->wrappedObject->getClassName());
     }
     return $this->subject;
 }