Пример #1
0
 public function testDoesNothingWhenMethodExpected()
 {
     $expectationComponent = Doubles::fromClass('\\Doubles\\Expectation\\ExpectationComponent');
     $expectationComponent->stub('isMethodExpected', true);
     $component = new PartialComponent($expectationComponent);
     $this->assertNull($component->whenMethodCalled('foo', array()));
 }
Пример #2
0
 /**
  * @return \Doubles\Interceptor\IInterceptor
  */
 public static function partial($object)
 {
     $subject = Core\Subject::fromInstance($object);
     $testDouble = new Core\TestDouble();
     $testDouble->addComponent(new Spy\SpyComponent());
     $expectationComponent = new ExpectationComponent();
     $stubComponent = new StubComponent();
     $mockComponent = new Mock\MockComponent();
     $interceptorComponent = new InterceptorComponent($object);
     $expectationComponent->addExpecter($stubComponent);
     $expectationComponent->addExpecter($mockComponent);
     $expectationComponent->addExpecter($interceptorComponent);
     $testDouble->addComponent(new PartialComponent($expectationComponent));
     $testDouble->addComponent($expectationComponent);
     $testDouble->addComponent($stubComponent);
     $testDouble->addComponent($mockComponent);
     $testDouble->addComponent($interceptorComponent);
     $partial = Core\TestDoubleFactory::create($subject, $testDouble, 'Partial%s');
     PartialComponent::mergeSubjectToPartial($object, $partial);
     return $partial;
 }