Example #1
0
 /**
  * Get the static instance of this factory.
  *
  * @return StubFactory The static factory.
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self(Sequencer::sequence('stub-label'), MatcherFactory::instance(), MatcherVerifier::instance(), Invoker::instance(), InvocableInspector::instance(), EmptyValueFactory::instance(), GeneratorAnswerBuilderFactory::instance());
     }
     return self::$instance;
 }
Example #2
0
 /**
  * Construct a new facade driver.
  *
  * @param AssertionRecorder $assertionRecorder The assertion recorder to use.
  */
 protected function __construct(AssertionRecorder $assertionRecorder)
 {
     $this->sequences = array();
     $anyMatcher = new AnyMatcher();
     $objectIdSequence = Sequencer::sequence('exporter-object-id');
     $invocableInspector = new InvocableInspector();
     $exporter = new InlineExporter(1, $objectIdSequence, $invocableInspector);
     $featureDetector = new FeatureDetector();
     $invoker = new Invoker();
     $matcherVerifier = new MatcherVerifier();
     if ($featureDetector->isSupported('runtime.hhvm')) {
         // @codeCoverageIgnoreStart
         $functionSignatureInspector = new HhvmFunctionSignatureInspector($invocableInspector, $featureDetector);
         // @codeCoverageIgnoreEnd
     } else {
         $functionSignatureInspector = new PhpFunctionSignatureInspector($invocableInspector, $featureDetector);
     }
     $mockClassLabelSequence = Sequencer::sequence('mock-class-label');
     $this->sequences[] = $mockClassLabelSequence;
     $mockGenerator = new MockGenerator($mockClassLabelSequence, $functionSignatureInspector, $featureDetector);
     $wildcardMatcher = new WildcardMatcher($anyMatcher, 0, null);
     $matcherFactory = new MatcherFactory($anyMatcher, $wildcardMatcher, $exporter);
     $matcherFactory->addMatcherDriver(new HamcrestMatcherDriver());
     $matcherFactory->addMatcherDriver(new CounterpartMatcherDriver());
     $matcherFactory->addMatcherDriver(new PhpunitMatcherDriver());
     $matcherFactory->addMatcherDriver(new SimpletestMatcherDriver());
     $matcherFactory->addMatcherDriver(new PhakeMatcherDriver($wildcardMatcher));
     $matcherFactory->addMatcherDriver(new ProphecyMatcherDriver($wildcardMatcher));
     $matcherFactory->addMatcherDriver(new MockeryMatcherDriver());
     $emptyValueFactory = new EmptyValueFactory();
     $generatorAnswerBuilderFactory = new GeneratorAnswerBuilderFactory($invocableInspector, $invoker, $featureDetector);
     $stubLabelSequence = Sequencer::sequence('stub-label');
     $this->sequences[] = $stubLabelSequence;
     $stubFactory = new StubFactory($stubLabelSequence, $matcherFactory, $matcherVerifier, $invoker, $invocableInspector, $emptyValueFactory, $generatorAnswerBuilderFactory);
     $clock = new SystemClock('microtime');
     $eventSequence = Sequencer::sequence('event-sequence-number');
     $this->sequences[] = $eventSequence;
     $eventFactory = new CallEventFactory($eventSequence, $clock);
     $callFactory = new CallFactory($eventFactory, $invoker);
     $generatorSpyFactory = new GeneratorSpyFactory($eventFactory, $featureDetector);
     $iterableSpyFactory = new IterableSpyFactory($eventFactory);
     $spyLabelSequence = Sequencer::sequence('spy-label');
     $this->sequences[] = $spyLabelSequence;
     $spyFactory = new SpyFactory($spyLabelSequence, $callFactory, $invoker, $generatorSpyFactory, $iterableSpyFactory);
     $differenceEngine = new DifferenceEngine($featureDetector);
     $assertionRenderer = new AssertionRenderer($matcherVerifier, $exporter, $differenceEngine, $featureDetector);
     $generatorVerifierFactory = new GeneratorVerifierFactory($matcherFactory, $assertionRecorder, $assertionRenderer);
     $iterableVerifierFactory = new IterableVerifierFactory($matcherFactory, $assertionRecorder, $assertionRenderer);
     $callVerifierFactory = new CallVerifierFactory($matcherFactory, $matcherVerifier, $generatorVerifierFactory, $iterableVerifierFactory, $assertionRecorder, $assertionRenderer);
     $assertionRecorder->setCallVerifierFactory($callVerifierFactory);
     $functionHookGenerator = new FunctionHookGenerator();
     $functionHookManager = new FunctionHookManager($functionSignatureInspector, $functionHookGenerator);
     $stubVerifierFactory = new StubVerifierFactory($stubFactory, $spyFactory, $matcherFactory, $matcherVerifier, $generatorVerifierFactory, $iterableVerifierFactory, $callVerifierFactory, $assertionRecorder, $assertionRenderer, $generatorAnswerBuilderFactory, $functionHookManager);
     $handleFactory = new HandleFactory($stubFactory, $stubVerifierFactory, $assertionRenderer, $assertionRecorder, $invoker);
     $mockLabelSequence = Sequencer::sequence('mock-label');
     $this->sequences[] = $mockLabelSequence;
     $mockFactory = new MockFactory($mockLabelSequence, $mockGenerator, $handleFactory, $featureDetector);
     $mockBuilderFactory = new MockBuilderFactory($mockFactory, $handleFactory, $invocableInspector, $featureDetector);
     $spyVerifierFactory = new SpyVerifierFactory($spyFactory, $matcherFactory, $matcherVerifier, $generatorVerifierFactory, $iterableVerifierFactory, $callVerifierFactory, $assertionRecorder, $assertionRenderer, $functionHookManager);
     $eventOrderVerifier = new EventOrderVerifier($assertionRecorder, $assertionRenderer);
     $emptyValueFactory->setStubVerifierFactory($stubVerifierFactory);
     $emptyValueFactory->setMockBuilderFactory($mockBuilderFactory);
     $generatorVerifierFactory->setCallVerifierFactory($callVerifierFactory);
     $iterableVerifierFactory->setCallVerifierFactory($callVerifierFactory);
     $this->mockBuilderFactory = $mockBuilderFactory;
     $this->handleFactory = $handleFactory;
     $this->spyVerifierFactory = $spyVerifierFactory;
     $this->stubVerifierFactory = $stubVerifierFactory;
     $this->functionHookManager = $functionHookManager;
     $this->eventOrderVerifier = $eventOrderVerifier;
     $this->matcherFactory = $matcherFactory;
     $this->exporter = $exporter;
     $this->assertionRenderer = $assertionRenderer;
     $this->differenceEngine = $differenceEngine;
 }