示例#1
0
 function it_should_show_prompt(Application $application, OutputInterface $output, OutputFormatterInterface $outputFormatter)
 {
     $application->getName()->willReturn('some')->shouldBeCalled();
     $outputFormatter->format(Argument::containingString('some'))->shouldBeCalled()->willReturn('prompt');
     $output->write('prompt')->shouldBeCalled();
     $this->showPrompt();
 }
 public function testOnKernelRequestRelevantRequest()
 {
     $headerBag = $this->prophesize('Symfony\\Component\\HttpFoundation\\HeaderBag');
     $headerBag->get('Content-type', null)->willReturn('application/pgp-encrypted')->shouldBeCalled();
     $headerBag = $headerBag->reveal();
     $parameterBag = $this->prophesize('Symfony\\Component\\HttpFoundation\\ParameterBag');
     $parameterBag->set(Argument::containingString('decrypted'), Argument::type('string'))->shouldBeCalled();
     $parameterBag->set(Argument::containingString('signature'), Argument::any())->shouldBeCalled();
     $parameterBag = $parameterBag->reveal();
     $request = $this->prophesize('Symfony\\Component\\HttpFoundation\\Request');
     $request->getContent()->willReturn('foo')->shouldBeCalled();
     $request->headers = $headerBag;
     $request->request = $parameterBag;
     $request = $request->reveal();
     $args = $this->prophesize('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent');
     $args->isMasterRequest()->willReturn(true);
     $args->getRequest()->willReturn($request);
     $args = $args->reveal();
     $decrypter = $this->prophesize();
     $decrypter->willImplement('Alameda\\Bundle\\EncryptionBundle\\Encryption\\DecrypterInterface');
     $decrypter->willImplement('Alameda\\Bundle\\EncryptionBundle\\Encryption\\AuthorizedSignatureInterface');
     $decrypter->decrypt(Argument::type('string'))->willReturn('foo');
     $decrypter->getSignature()->willReturn('bar');
     $decrypter = $decrypter->reveal();
     $subscriber = new DecryptSubscriber($decrypter);
     $subscriber->onKernelRequest($args);
 }
 public function test createKeyPair will notice the logger()
 {
     $dummyKeyPair = $this->prophesize(KeyPair::class)->reveal();
     $this->mockLogger->info(Argument::containingString('Generating new KeyPair'), Argument::any())->shouldBeCalled();
     $this->mockManager->generateKeyPair()->shouldBeCalled()->willReturn($dummyKeyPair);
     $this->mockStorage->store($dummyKeyPair)->shouldBeCalled();
     $this->service->createKeyPair();
 }
示例#4
0
 protected function addLikeCriteriaSpec(Collaborator $queryBuilder, Collaborator $expr, array $values, Collaborator $comparison)
 {
     $queryBuilder->expr()->shouldBeCalled()->willReturn($expr);
     $expr->like($this->getPropertyNameSpec(key($values)), Argument::containingString(':likeValue'))->shouldBeCalled()->willReturn($comparison);
     $queryBuilder->andWhere($comparison)->shouldBeCalled()->willReturn($queryBuilder);
     $queryBuilder->setParameter(Argument::containingString('likeValue'), '%' . $values[key($values)] . '%')->shouldBeCalled()->willReturn($queryBuilder);
     return $queryBuilder;
 }
 function it_shows_message_when_pause_is_called(OutputInterface $output)
 {
     fputs($this->inputStream, "Y\n");
     rewind($this->inputStream);
     $this->activate();
     $this->pause('step name');
     $output->write(Argument::containingString('step name'))->shouldHaveBeenCalled();
 }
示例#6
0
 public function testThrowExceptionIfQueueDoesNotExist()
 {
     $input = $this->prophesize(InputInterface::class);
     $output = $this->prophesize(OutputInterface::class);
     $input->getOption('queue')->shouldBeCalled()->willReturn('default');
     $this->sqsClient->getQueueUrl(['QueueName' => 'default'])->shouldBeCalled()->willThrow(SqsException::class);
     $output->writeln(Argument::containingString('<error>Impossible to retrieve URL for queue "default"'))->shouldBeCalled();
     $this->executeCommand($input, $output);
 }
示例#7
0
 /**
  * It should log exceptions as ERROR.
  */
 public function testLogError()
 {
     $this->iterations->hasException()->willReturn(true);
     $this->iterations->getSubject()->willReturn($this->subject->reveal());
     $this->subject->getName()->willReturn('benchFoo');
     $this->output->write(Argument::containingString('ERROR'))->shouldBeCalled();
     $this->output->write(PHP_EOL)->shouldBeCalled();
     $this->logger->iterationsEnd($this->iterations->reveal());
 }
示例#8
0
 function it_should_setup_container(Container $container, EventDispatcherInterface $dispatcher)
 {
     $container->setShared(Argument::any(), Argument::any())->shouldBeCalled();
     $container->set('phpguard', Argument::any())->shouldBeCalled();
     $container->get('dispatcher')->shouldBeCalled()->willReturn($dispatcher);
     $container->set('ui.application', $this)->shouldBeCalled();
     $container->setShared('ui.shell', Argument::any())->shouldBeCalled();
     $container->setShared(Argument::containingString('listeners'), Argument::any())->shouldBeCalled();
     $this->setupContainer($container);
 }
 public function test register will notice the logger()
 {
     $dummyKeyPair = $this->prophesize(KeyPair::class)->reveal();
     $mockClient = $this->prophesize(AcmeClient::class);
     $mockClient->registerAccount($this->dummyContactEmail)->shouldBeCalled();
     $mockLogger = $this->prophesize(LoggerInterface::class);
     $this->service->setLogger($mockLogger->reveal());
     $mockLogger->notice(Argument::containingString('Account {contactEmail} registered'), ['contactEmail' => $this->dummyContactEmail])->shouldBeCalled();
     $this->mockClientFactory->createAcmeClient($dummyKeyPair)->shouldBeCalled()->willReturn($mockClient->reveal());
     $this->service->register($dummyKeyPair);
 }
示例#10
0
 /**
  * It should allow the PHP executable to be wrapped with a different executable.
  */
 public function testWrap()
 {
     $process = $this->prophesize('Symfony\\Component\\Process\\Process');
     $payload = new Payload(__DIR__ . '/template/foo.template', array(), $process->reveal());
     $payload->setWrapper('bockfire');
     $payload->setPhpPath('/boo/bar/php');
     $process->setCommandLine(Argument::containingString('bockfire /boo/bar/php'))->shouldBeCalled();
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $process->getOutput()->willReturn('{"foo": "bar"}');
     $payload->launch($payload);
 }
示例#11
0
 /**
  * It should use the subject time unit.
  */
 public function testUseSubjectTimeUnit()
 {
     $this->iterations->getRejectCount()->willReturn(0);
     $this->iterations->getStats()->willReturn(array('mean' => 1.0, 'stdev' => 2.0, 'rstdev' => 20.0));
     $this->iterations->getSubject()->willReturn($this->subject->reveal());
     $this->iterations->getParameterSet()->willReturn($this->parameterSet->reveal());
     $this->subject->getOutputTimeUnit()->willReturn(TimeUnit::MICROSECONDS);
     $this->subject->getName()->willReturn('benchFoo');
     $this->parameterSet->getIndex()->willReturn(0);
     $this->output->writeln(Argument::containingString('1.000μs'))->shouldBeCalled();
     $this->logger->iterationsEnd($this->iterations->reveal());
 }
 /**
  * @test
  */
 public function find_all_will_return_an_array_of_segments()
 {
     $client = $this->prophesize(Auth::class);
     $repository = new SegmentBillingRepository($client->reveal());
     $fakeResponse = $this->getFakeResponse($this->getMultipleBillingSegments());
     $client->request('GET', Argument::containingString('start_element=3'))->willReturn($fakeResponse)->shouldBeCalled();
     $segments = $repository->findAll('member_id', 3, 3);
     $this->assertNotEmpty($segments);
     foreach ($segments as $segment) {
         $this->assertInstanceOf(SegmentBilling::class, $segment);
     }
 }
 /**
  * @test
  */
 public function preConsume_should_log_debug_message()
 {
     $body = 'payload-body';
     $messageName = 'message-name';
     $methodName = 'MyClass::myMethod';
     /** @var ConsumerContainer $consumerContainer */
     $consumerContainer = $this->prophesize(ConsumerContainer::class);
     $consumerContainer->getRoutingKey()->willReturn($messageName);
     $consumerContainer->getMethodName()->willReturn($methodName);
     $event = new ConsumerEvent(new AMQPMessage($body), $consumerContainer->reveal());
     $this->subscriber->preConsume($event);
     $this->logger->debug(Argument::allOf(Argument::containingString($messageName), Argument::containingString($methodName), Argument::containingString($body)))->shouldHaveBeenCalled();
 }
示例#14
0
 function it_should_handle_runAllCommand_events(GenericEvent $event, ContainerInterface $container, PluginInterface $plugin, Logger $logger)
 {
     $event->getSubject()->willReturn($container);
     $event->addProcessEvent(Argument::any())->shouldBeCalled();
     $logger->addDebug(Argument::cetera())->shouldBeCalled();
     $logger->addDebug(Argument::containingString('Start'))->shouldBeCalled();
     $logger->addDebug(Argument::containingString('End'), Argument::cetera())->shouldBeCalled();
     $event->getArgument('plugin')->willReturn(null);
     $resultEvent = new ProcessEvent($plugin->getWrappedObject(), array());
     $plugin->getTitle()->willReturn('PluginSpec');
     $plugin->runAll()->shouldBeCalled()->willReturn($resultEvent);
     $this->runAllCommand($event);
 }
 /**
  * @test
  */
 public function handle_should_log_message_with_payload()
 {
     $exceptionMessage = "Fatal error";
     $baseException = new Exception($exceptionMessage);
     $payloadMessage = $this->prophesize(MessageInterface::class);
     $exception = new ConsumerContainerException($this->consumerContainer->reveal(), new AMQPMessage(), $payloadMessage->reveal(), $baseException);
     $this->handler->handle($exception);
     $this->logger->warning(Argument::allOf(Argument::containingString(self::MESSAGE_CLASS), Argument::containingString($exceptionMessage)), Argument::that(function ($context) use($baseException) {
         verify($context['exception'])->isInstanceOf(ConsumerContainerException::class);
         verify($context['exception']->getPrevious())->equals($baseException);
         return $context;
     }))->shouldHaveBeenCalled();
 }
示例#16
0
 function it_uploads_without_removing(MediaInterface $media, Filesystem $filesystem, UploadedFile $file)
 {
     $media->hasMedia()->shouldBeCalled()->willReturn(true);
     $media->getName()->shouldBeCalled()->willReturn(null);
     $media->getMedia()->shouldBeCalled()->willReturn($file);
     $file->guessExtension()->shouldBeCalled()->willReturn('md');
     $filesystem->has(Argument::containingString('.md'))->shouldBeCalled()->willReturn(false);
     $media->setName(Argument::any())->shouldBeCalled()->willReturn($media);
     $media->getMedia()->shouldBeCalled()->willReturn($file);
     $file->getPathname()->shouldBeCalled()->willReturn(__DIR__ . '/../../../../../README.md');
     $filesystem->write(Argument::any(), file_get_contents(__DIR__ . '/../../../../../README.md'))->shouldBeCalled()->willReturn(Argument::type('int'));
     $this->upload($media);
 }
 public function testOnCheckerStartProgress()
 {
     $reflClass = new \ReflectionClass('SensioLabs\\DeprecationDetector\\EventListener\\ProgressListener');
     $prop = $reflClass->getProperty('progressBar');
     $prop->setAccessible(true);
     $output = $this->prophesize('Symfony\\Component\\Console\\Output\\OutputInterface');
     $listener = new ProgressListener($output->reveal());
     $progressBar = $this->prophesize('Symfony\\Component\\Console\\Helper\\ProgressBar');
     $progressBar->setFormat(Argument::containingString('deprecations'))->shouldBeCalled();
     $progressBar->start(123)->shouldBeCalled();
     $prop->setValue($listener, $progressBar->reveal());
     $event = new ProgressEvent(0, 123);
     $listener->onCheckerProgress($event);
 }
示例#18
0
 /**
  * It should show errors.
  */
 public function testEndSuiteErrors()
 {
     $this->setUpSummary();
     $this->document->hasErrors()->willReturn(true);
     $this->document->getErrorStacks()->willReturn(array(array('subject' => 'Namespace\\Foo::bar', 'exceptions' => array(array('exception_class' => 'ExceptionOne', 'message' => 'MessageOne'), array('exception_class' => 'ExceptionTwo', 'message' => 'MessageTwo')))));
     $this->output->writeln(Argument::containingString('1 subjects encountered errors'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('Namespace\\Foo::bar'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('ExceptionOne'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('ExceptionTwo'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('MessageOne'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('Two'))->shouldBeCalled();
     $this->output->writeln(Argument::any())->shouldBeCalled();
     $this->logger->endSuite($this->document->reveal());
 }
 /**
  * @dataProvider packageProvider
  */
 public function testAddPackage($packageName, $packageVersion, $expectedStability)
 {
     // Prepare the installer
     OptionalPackages::removeDevDependencies();
     $io = $this->prophesize('Composer\\IO\\IOInterface');
     $io->write(Argument::containingString('Adding package'))->shouldBeCalled();
     OptionalPackages::addPackage($io->reveal(), $packageName, $packageVersion);
     $this->assertComposerHasPackages(['zendframework/zend-stdlib']);
     $stabilityFlags = $this->getStabilityFlags();
     // Stability flags are only set for non-stable packages
     if ($expectedStability) {
         $this->assertArrayHasKey($packageName, $stabilityFlags);
         $this->assertEquals($expectedStability, $stabilityFlags[$packageName]);
     }
 }
示例#20
0
 public function testGetRevisionLog()
 {
     $repository_connector = $this->prophesize('ConsoleHelpers\\SVNBuddy\\Repository\\Connector\\Connector');
     $repository_connector->withCache('1 year')->willReturn($repository_connector)->shouldBeCalled();
     $repository_connector->getProperty('bugtraq:logregex', 'svn://localhost/trunk')->willReturn('')->shouldBeCalled();
     $repository_connector->getFirstRevision('svn://localhost')->willReturn(1)->shouldBeCalled();
     $repository_connector->getLastRevision('svn://localhost')->willReturn(1)->shouldBeCalled();
     $repository_connector->getProjectUrl('svn://localhost/trunk')->willReturn('svn://localhost')->shouldBeCalled();
     $cache_manager = $this->prophesize('ConsoleHelpers\\SVNBuddy\\Cache\\CacheManager');
     $cache_manager->getCache('log:svn://localhost', Argument::containingString('main:'))->shouldBeCalled();
     $io = $this->prophesize('ConsoleHelpers\\ConsoleKit\\ConsoleIO');
     $factory = new RevisionLogFactory($repository_connector->reveal(), $cache_manager->reveal(), $io->reveal());
     $revision_log = $factory->getRevisionLog('svn://localhost/trunk');
     $this->assertInstanceOf('ConsoleHelpers\\SVNBuddy\\Repository\\RevisionLog\\RevisionLog', $revision_log);
 }
示例#21
0
 /**
  * @test
  */
 public function itShouldAnalyseTargetDirectory()
 {
     $files = [fixture('MyClass.php'), fixture('MyOtherClass.php'), fixture('Example.php')];
     $this->argumentManager->get('format')->shouldBeCalled()->willReturn('pretty');
     $this->argumentManager->get('path')->shouldBeCalled()->willReturn(FIXTURES_DIR);
     // Assert that all files show up in the table
     $this->climate->table(Argument::that(function ($table) use($files) {
         foreach ($table as $row) {
             unset($files[array_search($row['file'], $files)]);
         }
         return count($files) === 0;
     }))->shouldBeCalled()->willReturn($this->climate);
     $this->climate->out(Argument::containingString('boolean expressions are assumptions'))->shouldBeCalled();
     $this->cli->handle(['phpa', FIXTURES_DIR]);
 }
 public function testAnsweredWithPackage()
 {
     // Prepare the installer
     OptionalPackages::removeDevDependencies();
     $io = $this->prophesize('Composer\\IO\\IOInterface');
     $io->write(Argument::containingString('Adding package <info>league/container</info>'))->shouldBeCalled();
     $io->write(Argument::containingString('<warning>You need to edit public/index.php'))->shouldBeCalled();
     $config = $this->getConfig();
     $question = $config['questions']['container'];
     $answer = 'league/container:2.2.0';
     $copyFilesKey = 'minimal-files';
     $result = OptionalPackages::processAnswer($io->reveal(), $question, $answer, $copyFilesKey);
     $this->assertTrue($result);
     $this->assertFileNotExists($this->getProjectRoot() . '/config/container.php');
     $this->assertComposerHasPackages(['league/container']);
 }
 function it_uses_the_media_manager_to_handle_the_media_of_product_templates($mediaManager, $normalizer, ProductTemplateInterface $template, ProductValueInterface $imageValue, ProductMediaInterface $imageMedia, File $imageFile, AttributeInterface $image, ProductValueInterface $fileValue, ProductMediaInterface $fileMedia)
 {
     $normalizer->normalize(Argument::cetera())->willReturn([]);
     $template->getValues()->willReturn([$imageValue, $fileValue]);
     $template->setValuesData([])->willReturn($template);
     $imageValue->getMedia()->willReturn($imageMedia);
     $imageMedia->getFile()->willReturn($imageFile);
     $imageValue->getAttribute()->willReturn($image);
     $imageValue->getLocale()->willReturn('en_US');
     $imageValue->getScope()->willReturn('mobile');
     $image->getCode()->willReturn('main_image');
     $fileValue->getMedia()->willReturn($fileMedia);
     $mediaManager->handle($imageMedia, Argument::containingString('-main_image-en_US-mobile-'))->shouldBeCalled();
     $mediaManager->handle($fileMedia, null)->shouldBeCalled();
     $this->handleProductTemplateMedia($template);
 }
 public function testRegisterEncryptSubscriber()
 {
     $definition = $this->prophesize('Symfony\\Component\\DependencyInjection\\Definition');
     $definition->setPublic(false)->shouldBeCalled();
     $definition->setArguments(Argument::type('array'))->shouldBeCalled();
     $definition->setFactoryService(Argument::type('string'))->shouldBeCalled();
     $definition->setFactoryMethod('createEncrypter')->shouldBeCalled();
     $definition->addTag(Argument::type('string'))->shouldBeCalled();
     $definition = $definition->reveal();
     $container = $this->prophesize('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $container->register(Argument::containingString('encrypt.gnupg'), Argument::type('string'))->willReturn($definition)->shouldBeCalled();
     $container = $container->reveal();
     $factory = new EventSubscriberFactory();
     $listenerId = $factory->registerEncryptSubscriber($container, 'id', 'encryptKey', 'signKey');
     $this->assertGreaterThan(2, strlen($listenerId));
     $this->assertStringEndsWith('id', $listenerId);
 }
 function it_adds_an_not_in_filter_on_a_field_in_the_query($qb, EntityManager $em, QueryBuilder $notInQb, Expr $expr, Expr\Func $inFunc, Expr\Func $whereFunc)
 {
     $qb->getRootAlias()->willReturn('f');
     $qb->leftJoin('f.groups', Argument::containingString('filtergroups'))->willReturn($qb);
     $qb->getEntityManager()->willReturn($em);
     $em->createQueryBuilder()->willReturn($notInQb);
     $qb->getRootEntities()->willReturn(['ProductClassName']);
     $notInQb->select(Argument::containingString('.id'))->shouldBeCalled()->willReturn($notInQb);
     $notInQb->from('ProductClassName', Argument::any(), Argument::containingString('.id'))->shouldBeCalled()->willReturn($notInQb);
     $notInQb->getRootAlias()->willReturn('ep');
     $notInQb->innerJoin(Argument::containingString('ep.groups'), Argument::containingString('filtergroups'))->shouldBeCalled()->willReturn($notInQb);
     $notInQb->expr()->willReturn($expr);
     $expr->in(Argument::containingString('.id'), [3])->shouldBeCalled()->willReturn($inFunc);
     $notInQb->where($inFunc)->shouldBeCalled();
     $notInQb->getDQL()->willReturn('excluded products DQL');
     $qb->expr()->willReturn($expr);
     $expr->notIn('f.id', 'excluded products DQL')->shouldBeCalled()->willReturn($whereFunc);
     $qb->andWhere($whereFunc)->shouldBeCalled();
     $this->addFieldFilter('groups.id', 'NOT IN', [3]);
 }
 function it_adds_a_not_equal_attribute_filter_in_the_query($attrValidatorHelper, QueryBuilder $queryBuilder, AttributeInterface $sku, Expr $expr, Expr\Comparison $comp, Expr\Literal $literal)
 {
     $attrValidatorHelper->validateLocale($sku, Argument::any())->shouldBeCalled();
     $attrValidatorHelper->validateScope($sku, Argument::any())->shouldBeCalled();
     $sku->getId()->willReturn(42);
     $sku->getCode()->willReturn('sku');
     $sku->getBackendType()->willReturn('varchar');
     $sku->isLocalizable()->willReturn(false);
     $sku->isScopable()->willReturn(false);
     $queryBuilder->expr()->willReturn($expr);
     $queryBuilder->getRootAlias()->willReturn('p');
     $expr->literal('My Sku')->willReturn($literal);
     $expr->notLike(Argument::any(), 'My Sku')->shouldBeCalled()->willReturn($comp);
     $literal->__toString()->willReturn('My Sku');
     $comp->__toString()->willReturn('filtersku.varchar NOT LIKE "My Sku"');
     $queryBuilder->innerJoin(Argument::any(), Argument::any(), 'WITH', Argument::containingString('.attribute = 42 AND filtersku.varchar NOT LIKE "My Sku"'))->shouldBeCalled();
     $this->addAttributeFilter($sku, '!=', 'My Sku', null, null, ['field' => 'sku']);
 }
 function it_adds_a_not_between_filter_on_an_attribute_in_the_query($attrValidatorHelper, $qb, AttributeInterface $attribute, Expr $expr, Expr\Comparison $ltComp, Expr\Comparison $gtComp, Expr\Orx $or)
 {
     $attrValidatorHelper->validateLocale($attribute, Argument::any())->shouldBeCalled();
     $attrValidatorHelper->validateScope($attribute, Argument::any())->shouldBeCalled();
     $attribute->getCode()->willReturn('release_date');
     $attribute->getBackendType()->willReturn('date');
     $attribute->getId()->willReturn(42);
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $qb->getRootAlias()->willReturn('p');
     $qb->innerJoin('p.values', Argument::containingString('filterrelease_date'), 'WITH', Argument::any())->shouldBeCalled();
     $qb->expr()->willReturn($expr);
     $expr->literal('2014-03-15')->willReturn('2014-03-15');
     $expr->literal('2014-03-18')->willReturn('2014-03-18');
     $expr->lt(Argument::containingString('.date'), '2014-03-15')->willReturn($ltComp);
     $expr->gt(Argument::containingString('.date'), '2014-03-18')->willReturn($gtComp);
     $expr->orX($ltComp, $gtComp)->willReturn($or);
     $qb->andWhere($or)->shouldBeCalled();
     $this->addAttributeFilter($attribute, 'NOT BETWEEN', ['2014-03-15', '2014-03-18']);
 }
 public function testInstallerDoesNotAddAutoloaderEntryIfAlreadyPresent()
 {
     $json = json_encode(['autoload' => ['psr-4' => ['Zend\\ComponentInstaller\\' => 'foo-bar/']]]);
     FileInfoStub::defineFile(__DIR__ . '/composer.json', $json);
     $this->console->writeLine(Argument::containingString('ComponentInstaller installed'), Color::GREEN)->shouldBeCalled();
     $installer = new Installer();
     $this->assertEquals(0, $installer($this->route->reveal(), $this->console->reveal()));
     $composerJson = FileInfoStub::get(__DIR__ . '/composer.json');
     $composer = json_decode($composerJson, true);
     $this->assertComposerContains('autoload.psr-4.Zend\\ComponentInstaller\\', 'foo-bar/', $composer);
 }
示例#29
0
 /**
  * It should use the subject time unit.
  * It should use the subject mode.
  */
 public function testUseSubjectTimeUnit()
 {
     $this->variant->getRejectCount()->willReturn(0);
     $this->variant->hasErrorStack()->willReturn(false);
     $this->variant->getStats()->willReturn($this->stats->reveal());
     $this->variant->getSubject()->willReturn($this->subject->reveal());
     $this->variant->count()->willReturn(10);
     $this->variant->getParameterSet()->willReturn($this->parameterSet->reveal());
     $this->subject->getOutputTimeUnit()->willReturn(TimeUnit::MICROSECONDS);
     $this->subject->getOutputTimePrecision()->willReturn(null);
     $this->subject->getOutputMode()->willReturn(TimeUnit::MODE_THROUGHPUT);
     $this->subject->getName()->willReturn('benchFoo');
     $this->parameterSet->getIndex()->willReturn(0);
     $this->output->writeln(Argument::containingString('1.000 (ops/μs)'))->shouldBeCalled();
     $this->logger->variantEnd($this->variant->reveal());
 }
示例#30
0
 /**
  * It should show errors.
  */
 public function testEndSuiteErrors()
 {
     $error1 = $this->prophesize(Error::class);
     $error1->getMessage()->willReturn('MessageOne');
     $error1->getClass()->willReturn('ExceptionOne');
     $error1->getTrace()->willReturn('-- trace --');
     $error2 = $this->prophesize(Error::class);
     $error2->getMessage()->willReturn('MessageTwo');
     $error2->getClass()->willReturn('ExceptionTwo');
     $error2->getTrace()->willReturn('-- trace --');
     $errorStack = $this->prophesize(ErrorStack::class);
     $errorStack->getVariant()->willReturn($this->variant->reveal());
     $errorStack->getIterator()->willReturn(new \ArrayIterator([$error1->reveal(), $error2->reveal()]));
     $this->setUpSummary();
     $this->suite->getErrorStacks()->willReturn([$errorStack]);
     $errorStack->getVariant()->willReturn($this->variant->reveal());
     $this->variant->getSubject()->willReturn($this->subject->reveal());
     $this->subject->getBenchmark()->willReturn($this->benchmark->reveal());
     $this->subject->getName()->willReturn('bar');
     $this->benchmark->getClass()->willReturn('Namespace\\Foo');
     $this->output->writeln(Argument::containingString('1 subjects encountered errors'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('Namespace\\Foo::bar'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('ExceptionOne'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('ExceptionTwo'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('MessageOne'))->shouldBeCalled();
     $this->output->writeln(Argument::containingString('Two'))->shouldBeCalled();
     $this->output->writeln(Argument::any())->shouldBeCalled();
     $this->logger->endSuite($this->suite->reveal());
 }