public function testRegisterContainerConfiguration()
 {
     $containerConfigurator = new MockeryCallableMock();
     $kernel = $this->build(array('container_configurator' => $containerConfigurator));
     $loader = \Mockery::mock('Symfony\\Component\\Config\\Loader\\LoaderInterface');
     $containerConfigurator->should()->with($loader)->once();
     $kernel->registerContainerConfiguration($loader);
 }
Ejemplo n.º 2
0
 public function testMapIterator()
 {
     $callback = new MockeryCallableMock();
     $iterator = new ArrayIterator(['key' => 'value', 'second' => 'monkey', 'third']);
     $mapIterator = new MapIterator($iterator, $callback);
     $callback->shouldBeCalled()->with('value', 'key', $iterator)->andReturn('modified');
     $callback->shouldBeCalled()->with('monkey', 'second', $iterator)->andReturn('fish');
     $callback->shouldBeCalled()->with('third', 0, $iterator)->andReturn('cake');
     $results = iterator_to_array($mapIterator, true);
     static::assertEquals(['key' => 'modified', 'second' => 'fish', 'cake'], $results);
 }
 public function testItReturnsTheServerResourceResponseIfItExists()
 {
     $secureRequestChecker = new MockeryCallableMock();
     $resourceProcessor = new MockeryCallableMock();
     $subscriber = new SymfonyHttpKernelAkamonOAuth2FirewallEventSubscriber($this->server, $secureRequestChecker, $resourceProcessor);
     $httpKernel = $this->httpKernelMock();
     $request = $this->requestMock();
     $event = new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST);
     $secureRequestChecker->should()->with($request)->once()->andReturn(true)->ordered();
     $response = new Response();
     $this->server->shouldReceive('resource')->with($request, $resourceProcessor)->once()->andReturn($response);
     $this->assertNull($subscriber->onKernelRequest($event));
     $this->assertSame($response, $event->getResponse());
 }
Ejemplo n.º 4
0
 /**
  * @expectedException \Tebru\Executioner\Exception\FailedException
  */
 public function testWithLogger()
 {
     $callable = new MockeryCallableMock();
     $exception = new Exception();
     $callable->shouldBeCalled()->times(1)->withNoArgs()->andThrow($exception);
     $callable->shouldBeCalled()->times(1)->withNoArgs()->andReturn(true);
     $logger = Mockery::mock(LoggerInterface::class);
     $dispatchException = new Exception();
     $logger->shouldReceive('info')->times(1)->with('Attempting "test" with 1 attempts to go. (uq)');
     $logger->shouldReceive('info')->times(1)->with('Attempting "test" with 0 attempts to go. (uq)');
     $logger->shouldReceive('info')->times(1)->with('Completed attempt for "test" (uq)', ['result' => true])->andThrow($dispatchException);
     $logger->shouldReceive('notice')->times(1)->with('Failed attempt for "test", retrying. 0 attempts remaining (uq)', ['exception' => $exception]);
     $logger->shouldReceive('error')->times(1)->with('Could not complete "test" (uq)', ['exception' => $dispatchException]);
     $loggerSubscriber = new LoggerSubscriber('test', $logger, 'uq');
     $dispatcher = Mockery::mock(EventDispatcher::class);
     $dispatcher->makePartial();
     $dispatcher->shouldReceive('dispatch')->times(5)->passthru();
     $dispatcher->shouldReceive('addSubscriber')->times(1)->with($loggerSubscriber)->passthru();
     $executor = new Executor();
     $executor->setDispatcher($dispatcher);
     $executor->addSubscriber($loggerSubscriber);
     $executor->execute(1, $callable);
 }
Ejemplo n.º 5
0
 private function assertFailureCalled($times, RuleInterface $rule, Node $node, CallbackVisitor $visitor)
 {
     $callback = new MockeryCallableMock();
     $callback->shouldBeCalled()->with($rule, $node, $this->file)->times($times);
     $visitor->onNodeFailure($callback);
     $visitor->enterNode($node);
 }
 public function testReturning()
 {
     $mock = new MockeryCallableMock();
     $mock->shouldBeCalled()->andReturn('foo');
     $this->assertSame('foo', $mock());
 }
Ejemplo n.º 7
0
 public function testParseCallback()
 {
     $this->parse->shouldBeCalled()->with('text')->andReturn('first', 'second');
     static::assertEquals('first', $this->parser->parseValue('text'));
     static::assertEquals('second', $this->parser->parseValue('text'));
 }
Ejemplo n.º 8
0
 /** @test */
 public function it_loads_only_indicated_relations_from_loader()
 {
     $id1 = 'ups';
     $id2 = 'yep';
     $data1 = new \stdClass();
     $data2 = new \ArrayObject();
     $relationTypeProcessorObtainer = new MockeryCallableMock();
     $destinationIdentityMap = new DestinationIdentityMap();
     $relationLoader = new CallableRelationLoader();
     $loader = new RelationsToLoadLoader($relationTypeProcessorObtainer, $destinationIdentityMap, $relationLoader);
     $oneRelationTypeProcessor = new OneRelationTypeProcessor();
     $relationTypeProcessorObtainer->should()->with('one')->andReturn($oneRelationTypeProcessor);
     $loaderInfo1 = new MockeryCallableMock();
     $loaderInfo2 = new MockeryCallableMock();
     $destinationDef1 = new DestinationMetadata('_', $loaderInfo1);
     $destinationDef2 = new DestinationMetadata('_', $loaderInfo2);
     $relationDef1 = new RelationMetadata('foo1', 'one', $destinationDef1);
     $relationDef2 = new RelationMetadata('foo2', 'one', $destinationDef2);
     $relationsToLoad = [new RelationToLoad($relationDef1, new IdOneTypeNotLoadedRelation($id1)), new RelationToLoad($relationDef2, new IdOneTypeNotLoadedRelation($id2))];
     $loaderInfo2->should()->with([$id2])->once()->andReturn([$id2 => $data2]);
     $result = $loader($relationsToLoad, ['foo2']);
     $expected = [new LoadedRelation($relationsToLoad[1], $data2)];
     $this->assertEquals($expected, $result);
 }