public function testSkipsDictionariesWithoutCustomSuffixInFilenameCustom()
 {
     $this->createLoader('testlangcode');
     $dictionariesDir = $this->resourcesDir . '/no-dictionaries';
     $this->dictionaryLoader->addFromDir($dictionariesDir);
     Phake::verify($this->templateMock, Phake::times(0))->includeInlineTranslation(Phake::anyParameters());
 }
 /**
  * @test
  */
 public function parseNormal()
 {
     \Phake::when($this->parser)->parse(\Phake::anyParameters())->thenReturn(null);
     $path = __DIR__ . '/../fixtures/1';
     $this->projectParser->parse($path);
     \Phake::verify($this->parser, \Phake::times(3))->parse(\Phake::anyParameters());
 }
Exemple #3
0
 public function testStorageDestruct()
 {
     $this->Web->queries($this->queries);
     $this->Web->crawl();
     // assertion maximus
     \Phake::verify($this->Storage, \Phake::times(1))->destruct();
 }
 public function testBuild()
 {
     $builder = \Phake::mock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $bundle = new ModeraMJRSecurityIntegrationBundle();
     $bundle->build($builder);
     \Phake::verify($builder, \Phake::times(1))->addCompilerPass($this->isInstanceOf('Symfony\\Component\\DependencyInjection\\Compiler\\CompilerPassInterface'));
 }
 /**
  * @test
  *
  * @link http://redmine.piece-framework.com/issues/323
  */
 public function clearsThePrecedingOutputHandlers()
 {
     $legacyProxy = \Phake::mock('Stagehand\\TestRunner\\Util\\LegacyProxy');
     \Phake::when($legacyProxy)->ob_get_level()->thenReturn(2)->thenReturn(1)->thenReturn(0);
     \Phake::when($legacyProxy)->ob_end_clean()->thenReturn(true);
     $this->setComponent('legacy_proxy', $legacyProxy);
     $this->createComponent('output_buffering')->clearOutputHandlers();
     \Phake::verify($legacyProxy, \Phake::times(3))->ob_get_level();
     \Phake::verify($legacyProxy, \Phake::times(2))->ob_end_clean();
 }
 public function testValidPostStore()
 {
     $rawpost = new Model\RawPost();
     $rawpost->setMethod('GET');
     $rawpost->setUrl('http://google.com');
     $rawpost->setData([1, 2]);
     $this->poststore->setRawPost($rawpost);
     $this->assertTrue($this->poststore->storePosts());
     \Phake::verify($this->storage, \Phake::times(1))->pipeline(\Phake::anyParameters());
 }
Exemple #7
0
 public function testExecuteWorksAndChainAppendedAndProcessed()
 {
     $this->chain->addProcessor($this->processorAppend);
     $this->chain->addProcessor($this->processorFalse);
     $result = $this->chain->execute($this->command);
     Phake::verify($this->processorFalse, Phake::times(2))->execute($this->command);
     Phake::verify($this->processorAppend)->execute($this->command);
     Phake::verify($this->processorTrue)->execute($this->command);
     $this->assertSame(TRUE, $result);
 }
 /** @test */
 public function should_use_segment_populator_for_content()
 {
     $loader = new MappingLoader(realpath(__DIR__ . '/../../src/EDI/Mapping'));
     $segmentPopulator = $this->givenSegmentPopulator();
     $populator = $this->givenPopulator($segmentPopulator, $loader);
     $fixtureDir = realpath(__DIR__ . '/../fixtures');
     $parser = new Parser();
     $data = $parser->parse($fixtureDir . '/invoic_message_standalone.edi');
     $populator->populate($data);
     \Phake::verify($segmentPopulator, \Phake::times(37))->populate(\Phake::anyParameters());
 }
 public function testCount()
 {
     $this->validAction = 'count';
     $expectedUrl = $this->getExpectedUrl($this->validBaseUrl, '');
     $this->hasMockHttpClient($expectedUrl);
     $this->spamReports->setHttpClient($this->mockHttpClient);
     $actualResponse = $this->spamReports->count();
     \Phake::verify($this->mockHttpClient, \Phake::times(2))->get($expectedUrl);
     $this->assertInstanceOf('\\Guzzle\\Http\\Message\\Response', $actualResponse);
     $this->assertEquals(200, $actualResponse->getStatusCode());
 }
Exemple #10
0
 public function testSpecificSqlFile()
 {
     $application = \Phake::partialMock('Dbup\\Application');
     /** want not to run, so change up method to mock */
     \Phake::when($application)->up(\Phake::anyParameters())->thenReturn(null);
     $application->add(new UpCommand());
     $command = $application->find('up');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName(), '--ini' => __DIR__ . '/../.dbup/properties.ini.test', 'file' => 'V12__sample12_select.sql']);
     \Phake::verify($application, \Phake::times(1))->up(\Phake::anyParameters());
 }
 public function testCallApiFunctionwithDefaultFromatAndMultipleParametersSomeNull()
 {
     $expectedUrl = $this->getExpectedUrl($this->validBaseUrl, '&date=1');
     $this->hasMockHttpClient($expectedUrl);
     $this->hasSendGridWebApi();
     $this->sendGridWebApiAbstract->addParameter('date', 1);
     $this->sendGridWebApiAbstract->addParameter('foo', 'bar');
     $this->sendGridWebApiAbstract->addParameter('foo', null);
     $actualResponse = $this->sendGridWebApiAbstract->callApiFunction();
     \Phake::verify($this->mockHttpClient, \Phake::times(2))->get($expectedUrl);
     $this->assertEquals($this->validHttpResponse, $actualResponse);
 }
 public function testOnKernelException()
 {
     $event = $this->createMockEvent(true, '/mega-backend', new AccessDeniedException());
     $lnr = new AjaxAuthenticationValidatingListener('/mega-backend');
     $lnr->onKernelException($event);
     \Phake::verify($event, \Phake::times(2))->getRequest();
     \Phake::verify($event)->getException();
     \Phake::verify($event)->setResponse(\Phake::capture($response));
     \Phake::verifyNoOtherInteractions($event);
     /* @var JsonResponse $response */
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\JsonResponse', $response);
     $content = json_decode($response->getContent(), true);
     $this->assertTrue(is_array($content));
     $this->assertArrayHasKey('success', $content);
     $this->assertFalse($content['success']);
     $this->assertArrayHasKey('message', $content);
     $this->assertTrue('' != $content['message']);
 }
Exemple #13
0
 public function testWork()
 {
     $worker = \Phake::partialMock('\\Brook\\Worker');
     $fanOut = \Phake::partialMock('\\Brook\\FanOut');
     $task = \Phake::mock('\\Brook\\TaskInterface');
     $server = \Phake::mock('ZMQSocket');
     $controller = \Phake::mock('ZMQSocket');
     $sink = \Phake::mock('ZMQSocket');
     $fanOut->setServer($server);
     $fanOut->setController($controller);
     $fanOut->setSink($sink);
     \Phake::when($fanOut)->sendOffWorker($task)->thenReturn($worker);
     \Phake::when($fanOut)->initialize()->thenReturn(true);
     $fanOut->distributeWork(3, $task);
     $this->assertEquals(3, count($fanOut->getWorkers()));
     \Phake::verify($fanOut, \Phake::times(3))->sendOffWorker($task);
     \Phake::verify($fanOut)->initialize();
 }
 public function testEventReceivedDuringReplay()
 {
     $concurrentMessage = new GenericEventMessage(new Payload("Concurrent MSG"));
     $self = $this;
     \Phake::when($this->mockEventStore)->visitEvents(\Phake::anyParameters())->thenGetReturnByLambda(function ($visitor, $criteria) use($concurrentMessage, $self) {
         $self->assertTrue($self->testSubject->isInReplayMode());
         $self->testSubject->publish(array($concurrentMessage));
         foreach ($self->messages as $message) {
             $visitor->doWithEvent($message);
         }
     });
     $listener = \Phake::mock(ReplayAwareListenerInterface::class);
     $this->testSubject->getEventListenerRegistry()->subscribe($listener);
     $this->testSubject->startReplay();
     \Phake::inOrder(\Phake::verify($this->mockMessageHandler)->prepareForReplay(\Phake::anyParameters()), \Phake::verify($listener)->beforeReplay(), \Phake::verify($this->mockEventStore)->visitEvents(\Phake::anyParameters()), \Phake::verify($this->mockMessageHandler)->onIncomingMessages(\Phake::anyParameters()), \Phake::verify($this->delegate, \Phake::times(10))->publish(\Phake::anyParameters()), \Phake::verify($listener)->afterReplay(), \Phake::verify($this->mockMessageHandler)->processBacklog(\Phake::anyParameters()));
     \Phake::verify($this->delegate, \Phake::never())->publish($concurrentMessage);
     //   \Phake::verify($this->delegate)->subscribe($listener);
 }
 public function testSagaEventsDoNotOvertakeRegularEvents()
 {
     $this->testSubject->start();
     $self = $this;
     \Phake::when($this->listener1)->handle($this->event1)->thenGetReturnByLambda(function ($event) use($self) {
         $uow = new DefaultUnitOfWork();
         $uow->start();
         $uow->registerAggregate($self->mockAggregateRoot, $self->mockEventBus, $self->callback2);
         $uow->commit();
         return null;
     });
     $this->testSubject->registerAggregate($this->mockAggregateRoot, $this->mockEventBus, $this->callback1);
     $this->testSubject->commit();
     \Phake::inOrder(\Phake::verify($this->listener1, \Phake::times(1))->handle($this->event1), \Phake::verify($this->listener2, \Phake::times(1))->handle($this->event1), \Phake::verify($this->listener1, \Phake::times(1))->handle($this->event2), \Phake::verify($this->listener2, \Phake::times(1))->handle($this->event2));
 }
Exemple #16
0
 public function testMagicCallMethodBypassesExplicitStub()
 {
     $ref = array('foo', array('bar'));
     $this->handler->invoke($this->mock, '__call', $ref, $ref);
     Phake::verify($this->stubMapper, Phake::times(0))->getStubByCall('__call', array('foo', array('bar')));
 }
Exemple #17
0
 /**
  * issue #1
  */
 public function testUpWithSingleStatementWithEmptyLineSqlFile()
 {
     $this->app->appliedFilesDir = __DIR__ . '/.dbup/applied';
     $this->app->pdo = $this->pdo;
     $file = new \SplFileInfo(__DIR__ . '/samples/singleWithEmpty.sql');
     $this->app->up($file);
     \Phake::verify($this->dbh, \Phake::times(1))->prepare(\Phake::anyParameters());
     @unlink(__DIR__ . '/.dbup/applied/single.sql');
 }
 /**
  * Verify the behaviour when the reference is set to a different
  * object than the one returned by the repository.
  *
  * @expectedException \UnexpectedValueException
  * @expectedExceptionMessage New value does not match existing test-test reference value
  */
 public function testAddIfNotPresentReferenceExistsNoMatch()
 {
     $params = $this->params();
     $trait = $this->factory();
     $existingEntity = new TestEntity('test-id');
     //Make the repostiory return an object
     \Phake::when($params['repo'])->findOneBy(\Phake::anyParameters())->thenReturn($existingEntity);
     \Phake::when($trait)->hasReference('test-test')->thenReturn(true);
     \Phake::when($trait)->getReference('test-test')->thenReturn(new TestEntity('test-id'));
     $entity = new TestEntity('test-id');
     $criteria = array('name' => 'test');
     $prefix = 'test';
     $result = \Phake::makeVisible($trait)->_addIfNotPresent($entity, $criteria, $prefix, $params['object_manager']);
     \Phake::verify($trait, \Phake::times(0))->addReference('test-test', $entity);
     \Phake::verify($params['object_manager'], \Phake::times(0))->persist($entity);
     $this->assertNotSame($entity, $result);
     $this->assertSame($existingEntity, $result);
 }
 /**
  * @Given /^the Adapter should send "([^"]*)" (\d+) times to the server$/
  */
 public function theAdapterShouldSendTimesToTheServer($expectedResult, $cntTimes)
 {
     Phake::verify($this->_mockedClient, Phake::times($cntTimes))->addResultToBufferStep($expectedResult);
 }
 /**
  * @test
  * @dataProvider notificationDecisions
  * @param boolean $notify
  */
 public function runsATest($notify)
 {
     $outputBuffering = \Phake::mock('Stagehand\\TestRunner\\Util\\OutputBuffering');
     \Phake::when($outputBuffering)->clearOutputHandlers()->thenReturn(null);
     $this->setComponent('output_buffering', $outputBuffering);
     $preparer = \Phake::mock('Stagehand\\TestRunner\\Preparer\\Preparer');
     \Phake::when($preparer)->prepare()->thenReturn(null);
     $this->setComponent('phpunit.preparer', $preparer);
     $collector = \Phake::mock('Stagehand\\TestRunner\\Collector\\Collector');
     $testSuite = new \stdClass();
     \Phake::when($collector)->collect()->thenReturn($testSuite);
     $this->setComponent('phpunit.collector', $collector);
     $runner = \Phake::mock('Stagehand\\TestRunner\\Runner\\Runner');
     \Phake::when($runner)->run($this->anything())->thenReturn(null);
     \Phake::when($runner)->shouldNotify()->thenReturn($notify);
     if ($notify) {
         $notification = new Notification(Notification::RESULT_PASSED, 'MESSAGE');
         \Phake::when($runner)->getNotification()->thenReturn($notification);
     }
     $this->setComponent('phpunit.runner', $runner);
     $notifier = \Phake::mock('Stagehand\\TestRunner\\Notification\\Notifier');
     if ($notify) {
         \Phake::when($notifier)->notifyResult($this->anything())->thenReturn(null);
     }
     $this->setComponent('notifier', $notifier);
     $this->createComponent('test_runner')->run();
     \Phake::verify($preparer)->prepare();
     \Phake::verify($collector)->collect();
     \Phake::verify($runner)->run($this->identicalTo($testSuite));
     \Phake::verify($runner)->shouldNotify();
     \Phake::verify($runner, \Phake::times($notify ? 1 : 0))->getNotification();
     if ($notify) {
         \Phake::verify($notifier)->notifyResult($this->identicalTo($notification));
     } else {
         \Phake::verify($notifier, \Phake::never())->notifyResult();
     }
 }
 public function test_checks_the_database_until_the_response_is_none_null()
 {
     Phake::when($this->wpdb)->get_var(Phake::anyParameters())->thenReturn(null)->thenReturn(null)->thenReturn('true')->thenReturn(null);
     $this->client->launchkey_user_authentication('user', 'username');
     Phake::verify($this->wpdb, Phake::times(3))->get_var($this->anything());
 }
 public function testMatch_FullMatchWithGaps()
 {
     \Phake::reset($this->mockMatcher2);
     \Phake::when($this->mockMatcher2)->matches(\Phake::anyParameters())->thenReturn(false);
     \Phake::when($this->mockMatcher2)->matches($this->stubEvent5)->thenReturn(true);
     $this->assertTrue($this->testSubject->matches(array($this->stubEvent1, $this->stubEvent2, $this->stubEvent3, $this->stubEvent4, $this->stubEvent5)));
     \Phake::verify($this->mockMatcher1)->matches($this->stubEvent1);
     \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent2);
     \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent3);
     \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent4);
     \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent5);
     \Phake::verify($this->mockMatcher2, \Phake::never())->matches($this->stubEvent1);
     \Phake::verify($this->mockMatcher2, \Phake::times(1))->matches($this->stubEvent2);
     \Phake::verify($this->mockMatcher2, \Phake::times(1))->matches($this->stubEvent3);
     \Phake::verify($this->mockMatcher2, \Phake::times(1))->matches($this->stubEvent4);
     \Phake::verify($this->mockMatcher2, \Phake::times(1))->matches($this->stubEvent5);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent1);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent2);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent3);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent4);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent5);
     \Phake::verify($this->mockMatcher3)->matches(null);
 }
 public function testShouldBindEventListenerWhenJsonFormatOptionIsTrue()
 {
     $builder = \Phake::mock('Symfony\\Component\\Form\\FormBuilderInterface');
     $this->formTypeJsonExtension->buildForm($builder, ['json_format' => true]);
     \Phake::verify($builder, \Phake::times(1))->addEventSubscriber(new JsonExtensionListener());
 }
 public function testRequestWithoutJsonContentShouldSubmitProxy()
 {
     \Phake::when($this->request)->getContentType()->thenReturn('txt');
     $this->jsonRequestHandler->handleRequest($this->form, $this->request);
     \Phake::verify($this->httpFoundationRequestHandler, \Phake::times(1))->handleRequest($this->form, $this->request);
 }
 /**
  * @since Method available since Release 4.0.0
  *
  * @test
  * @dataProvider emptyNotificationMessages
  */
 public function raisesAnExceptionWhenAnUnexpectedNotificationResultIsSet()
 {
     $this->setComponent('output_buffering', \Phake::mock('Stagehand\\TestRunner\\Util\\OutputBuffering'));
     $this->setComponent('phpunit.preparer', \Phake::mock('Stagehand\\TestRunner\\Preparer\\Preparer'));
     $collector = \Phake::mock('Stagehand\\TestRunner\\Collector\\Collector');
     \Phake::when($collector)->collect()->thenReturn(new \stdClass());
     $this->setComponent('phpunit.collector', $collector);
     $notification = \Phake::mock('Stagehand\\TestRunner\\Notification\\Notification');
     \Phake::when($notification)->isPassed()->thenReturn(false);
     \Phake::when($notification)->isFailed()->thenReturn(false);
     $runner = \Phake::mock('Stagehand\\TestRunner\\Runner\\Runner');
     \Phake::when($runner)->shouldNotify()->thenReturn(true);
     \Phake::when($runner)->getNotification()->thenReturn($notification);
     $this->setComponent('phpunit.runner', $runner);
     $notifier = \Phake::mock('Stagehand\\TestRunner\\Notification\\Notifier');
     $this->setComponent('notifier', $notifier);
     try {
         $this->createComponent('test_runner')->run();
         $this->fail('An expected exception has not been raised.');
     } catch (\LogicException $e) {
         \Phake::verify($runner)->getNotification();
         \Phake::verify($notification)->isFailed();
         \Phake::verify($notifier, \Phake::times(0))->notifyResult($this->anything());
     }
 }
 public function testVisitEvents_AfterTimestamp()
 {
     $eventVisitor = \Phake::mock(EventVisitorInterface::class);
     $this->testSubject->appendEvents("test", new SimpleDomainEventStream($this->createDomainEvents(11)));
     sleep(1);
     $this->testSubject->appendEvents("test", new SimpleDomainEventStream($this->createDomainEvents(12)));
     sleep(1);
     $now = new \DateTime();
     sleep(1);
     $this->testSubject->appendEvents("test", new SimpleDomainEventStream($this->createDomainEvents(13)));
     $this->testSubject->appendEvents("test", new SimpleDomainEventStream($this->createDomainEvents(14)));
     $criteriaBuilder = $this->testSubject->newCriteriaBuilder();
     $this->testSubject->visitEvents($eventVisitor, $criteriaBuilder->property("timestamp")->greaterThan($now));
     \Phake::verify($eventVisitor, \Phake::times(13 + 14))->doWithEvent(\Phake::anyParameters());
 }
 public function testMatch_ExcessEventsIgnored()
 {
     $this->assertTrue($this->testSubject->matches(array($this->stubEvent1, $this->stubEvent2, $this->stubEvent3, new StubEvent())));
     \Phake::verify($this->mockMatcher1, \Phake::times(1))->matches($this->stubEvent1);
     \Phake::verify($this->mockMatcher1, \Phake::never())->matches($this->stubEvent2);
     \Phake::verify($this->mockMatcher2, \Phake::never())->matches($this->stubEvent1);
     \Phake::verify($this->mockMatcher2, \Phake::times(1))->matches($this->stubEvent2);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent1);
     \Phake::verify($this->mockMatcher3, \Phake::never())->matches($this->stubEvent2);
     \Phake::verify($this->mockMatcher3, \Phake::times(1))->matches($this->stubEvent3);
 }
Exemple #28
0
 public function testGetOnMockedClass()
 {
     $mock = Phake::mock('PhakeTest_MagicClass');
     Phake::when($mock)->__get('myId')->thenReturn(500)->thenReturn(501);
     $this->assertEquals(500, $mock->myId);
     $this->assertEquals(501, $mock->myId);
     Phake::verify($mock, Phake::times(2))->__get('myId');
 }
 /**
  * @dataProvider jsonProvider
  */
 public function testValidJsonShouldBeDecoded($json, $data)
 {
     \Phake::when($this->formEvent)->getData()->thenReturn($json);
     $this->jsonExtensionListener->onPreSubmit($this->formEvent);
     \Phake::verify($this->formEvent, \Phake::times(1))->setData($data);
 }