public function testReformatAttributes()
 {
     $client = $this->getRiemannClient();
     $logger = new Logger($client->reveal());
     $logger->log([], ['foo' => 'bar']);
     $client->sendEvent(Argument::withEntry('attributes', [['key' => 'foo', 'value' => 'bar']]))->shouldHaveBeenCalled();
 }
示例#2
0
 function it_generates_time_inputs($html)
 {
     // Expect
     $html->attributes(Arg::withEntry('type', 'time'));
     // When
     $this->time('time');
 }
示例#3
0
 public function testLogFailure_AddsExceptionContext()
 {
     $message = "Testing";
     $exception = new \Exception("Expected Exception");
     $this->mockLogger->log(Argument::type('string'), Argument::type('string'), Argument::withEntry('exception', $exception))->shouldBeCalledTimes(1);
     $this->testedBuildLogger->logFailure($message, $exception);
 }
 function it_render_template_with_paginator(EngineInterface $templating, Response $response, GalleryManagerInterface $galleryManager, AdapterInterface $adapter)
 {
     $galleryManager->createPagerfantaAdapter()->willReturn($adapter);
     $adapter->getNbResults()->willReturn(5);
     $templating->renderResponse('FSiGalleryBundle:Gallery:list.html.twig', Argument::allOf(Argument::withEntry('galleries', Argument::type('Pagerfanta\\Pagerfanta')), Argument::withEntry('preview_photos_count', 4)))->willReturn($response);
     $this->listAction(2)->shouldReturn($response);
 }
 public function testTestPermissions()
 {
     $permissions = ['foo', 'bar'];
     $this->connection->testPermissions(Argument::withEntry('permissions', $permissions))->willReturn($permissions);
     $iam = new Iam($this->connection->reveal(), self::RESOURCE);
     $this->assertEquals($permissions, $iam->testPermissions($permissions));
 }
示例#6
0
 function it_builds_form_with_proper_fields(FormBuilder $builder)
 {
     $builder->add('masterVariant', 'sylius_product_variant', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('attributes', 'collection', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('options', 'sylius_product_option_choice', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('associations', 'collection', Argument::withEntry('type', 'sylius_product_association'))->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }
 function it_should_use_the_take_payment_command_data_class(OptionsResolver $resolver)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     $this->setDefaultOptions($resolver);
     /** @noinspection PhpParamsInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     $resolver->setDefaults(Argument::withEntry('data_class', TakePaymentCommand::class))->shouldHaveBeenCalled();
 }
示例#8
0
 function it_sets_default_options(OptionsResolver $resolver)
 {
     $resolver->setDefaults(Argument::withEntry('data_class', 'Kreta\\Component\\Project\\Model\\IssuePriority'))->shouldBeCalled()->willReturn($resolver);
     $resolver->setDefaults(Argument::withEntry('csrf_protection', false))->shouldBeCalled()->willReturn($resolver);
     $resolver->setDefaults(Argument::withEntry('empty_data', Argument::type('closure')))->shouldBeCalled()->willReturn($resolver);
     $resolver->setRequired(['project'])->shouldBeCalled()->willReturn($resolver);
     $this->configureOptions($resolver);
 }
示例#9
0
 function it_sets_default_options(OptionsResolver $resolver)
 {
     $resolver->setDefaults(Argument::withEntry('data_class', 'Kreta\\Component\\Workflow\\Model\\Status'))->shouldBeCalled()->willReturn($resolver);
     $resolver->setDefaults(Argument::withEntry('csrf_protection', false))->shouldBeCalled()->willReturn($resolver);
     $resolver->setDefaults(Argument::withEntry('empty_data', Argument::type('closure')))->shouldBeCalled()->willReturn($resolver);
     $resolver->setOptional(['workflow'])->shouldBeCalled()->willReturn($resolver);
     $this->configureOptions($resolver);
 }
示例#10
0
 function it_builds_form_with_proper_fields(FormBuilder $builder)
 {
     $builder->add('attributes', 'collection', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('options', 'sylius_product_option_choice', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
     $builder->add('associations', 'collection', Argument::withEntry('type', 'sylius_product_association'))->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }
 public function testUpdate()
 {
     $this->connection->patchDataset(Argument::withEntry('friendlyName', 'A fanciful dataset.'))->shouldBeCalledTimes(1)->willReturn([]);
     $dataset = $this->getDataset($this->connection);
     $snippet = $this->snippetFromMethod(Dataset::class, 'update');
     $snippet->addLocal('dataset', $dataset);
     $snippet->invoke();
 }
 function it_adds_code_with_type_text_by_default(FormEvent $event, FormInterface $form, CodeAwareInterface $resource)
 {
     $event->getData()->willReturn($resource);
     $event->getForm()->willReturn($form);
     $resource->getCode()->willReturn('Code12');
     $form->add('code', 'text', Argument::withEntry('disabled', true))->shouldBeCalled();
     $this->preSetData($event);
 }
 function it_does_not_set_base_currency_as_enabled_when_channel_is_new(FormEvent $event, ChannelInterface $channel, FormInterface $form)
 {
     $event->getData()->willReturn($channel);
     $event->getForm()->willReturn($form);
     $channel->getId()->willReturn(null);
     $form->add('baseCurrency', Argument::type('string'), Argument::withEntry('disabled', false))->shouldBeCalled();
     $this->preSetData($event);
 }
 public function it_set_controller_if_init_return_response(FilterControllerEvent $event, Request $request, SampleInitController $controller)
 {
     $event->getRequest()->willReturn($request);
     $event->getController()->willReturn(array($controller));
     $controller->init($request)->willReturn(new Response('http://example.com/'));
     $event->setController(Argument::allOf(Argument::withEntry('0', Argument::type('Yavin\\Symfony\\Controller\\InitControllerSubscriber')), Argument::withEntry('1', 'responseAction')))->shouldBeCalled();
     $this->onKernelController($event);
 }
 /**
  * @test
  * it should return the escaped content if provided
  */
 public function it_should_return_the_escaped_content_if_provided()
 {
     $sut = $this->make_instance();
     $this->context->get_post_id()->willReturn(23);
     $this->context->get_comment_text()->willReturn('default text');
     $content = 'some&content$$<>';
     $this->render_engine->render(Argument::any(), Argument::withEntry('comment_text', esc_attr($content)))->shouldBeCalled();
     $out = $sut->render([], $content);
 }
示例#16
0
 function it_sets_default_options(OptionsResolver $resolver, ObjectManager $manager, TokenStorageInterface $context, TokenInterface $token, UserInterface $user)
 {
     $token->getUser()->shouldBeCalled()->willReturn($user);
     $this->beConstructedWith('data-class', Argument::type('Object'), $context, $manager);
     $resolver->setDefaults(Argument::withKey('data_class'))->shouldBeCalled()->willReturn($resolver);
     $resolver->setDefaults(Argument::withEntry('csrf_protection', false))->shouldBeCalled()->willReturn($resolver);
     $resolver->setDefaults(Argument::withEntry('empty_data', Argument::type('closure')))->shouldBeCalled()->willReturn($resolver);
     $this->configureOptions($resolver);
 }
 function it_moves_down_item_when_move_down_action_called(CRUDElement $element, NestedTreeRepository $repository, \StdClass $category, ObjectManager $om, Router $router, DoctrineDataIndexer $indexer, Request $request)
 {
     $indexer->getData(1)->willReturn($category);
     $repository->moveDown($category)->shouldBeCalled();
     $om->flush()->shouldBeCalled();
     $router->generate('fsi_admin_crud_list', Argument::withEntry('element', 'category'))->willReturn('sample-path');
     $response = $this->moveDownAction($element, 1, $request);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse');
     $response->getTargetUrl()->shouldReturn('sample-path');
 }
 public function testProxies()
 {
     $connection = $this->prophesize(ConnectionInterface::class);
     $connection->getTopicIamPolicy(Argument::withEntry('foo', 'bar'))->willReturn('test')->shouldBeCalledTimes(1);
     $connection->setTopicIamPolicy(Argument::withEntry('foo', 'bar'))->willReturn('test')->shouldBeCalledTimes(1);
     $connection->testTopicIamPermissions(Argument::withEntry('foo', 'bar'))->willReturn('test')->shouldBeCalledTimes(1);
     $iamTopic = new IamTopic($connection->reveal());
     $this->assertEquals('test', $iamTopic->getPolicy(['foo' => 'bar']));
     $this->assertEquals('test', $iamTopic->setPolicy(['foo' => 'bar']));
     $this->assertEquals('test', $iamTopic->testPermissions(['foo' => 'bar']));
 }
 public function testHandleMultipleRecords()
 {
     $riemannLogger = $this->getRiemannLogger();
     $logger = new RiemannAggregateRecordsLogger($riemannLogger->reveal());
     $logger->handle(['level_name' => 'foo']);
     $logger->handle(['level_name' => 'bar']);
     $logger->handle(['level_name' => 'bar']);
     $logger->flush();
     $riemannLogger->log(Argument::withEntry('metrics', 1), Argument::withEntry('level', 'foo'))->shouldHaveBeenCalled();
     $riemannLogger->log(Argument::withEntry('metrics', 2), Argument::withEntry('level', 'bar'))->shouldHaveBeenCalled();
 }
 public function testAddDurationToData()
 {
     $duration = 2611;
     $logger = $this->getRiemannLogger();
     $stopwatch = $this->getStopwatch();
     $listener = new RequestListener($logger->reveal(), $stopwatch->reveal());
     $event = $this->getPostResponseEvent();
     $stopwatch->stop(Argument::any())->will(function () use($duration) {
         return new FixedDurationStopwatchEvent($duration);
     });
     $listener->onKernelTerminate($event);
     $logger->log(Argument::withEntry('metrics', $duration), Argument::any())->shouldHaveBeenCalled();
 }
示例#21
0
 function it_checks_access_through_the_gate(AccessHandler $access)
 {
     // Having
     $this->setAccessHandler($access);
     // Expect
     $access->check(Argument::withEntry('allows', ['update-post', 1]))->shouldBeCalled()->willReturn(true);
     // When
     $menu = $this->make(['edit-post' => ['allows' => ['update-post', ':post']]])->setParam('post', 1);
     // Expect
     $menu->shouldReturnAnInstanceOf('Styde\\Html\\Menu\\Menu');
     $items = ['edit-post' => ['class' => '', 'submenu' => null, 'id' => 'edit-post', 'active' => false, 'title' => 'Edit post', 'url' => '#']];
     $menu->getItems()->shouldReturn($items);
 }
示例#22
0
 function it_builds_form_with_proper_fields(FormBuilder $builder)
 {
     $builder->add(Argument::cetera())->willReturn($builder);
     $builder->add('masterVariant', 'sylius_product_variant', Argument::any())->willReturn($builder);
     $builder->add('name', 'text', Argument::any())->willReturn($builder);
     $builder->add('description', 'textarea', Argument::any())->willReturn($builder);
     $builder->add('attributes', 'collection', Argument::any())->willReturn($builder);
     $builder->add('options', 'sylius_product_option_choice', Argument::any())->willReturn($builder);
     $builder->add('associations', 'collection', Argument::withEntry('type', 'sylius_product_association'))->willReturn($builder);
     $builder->add('metaKeywords', 'text', Argument::any())->willReturn($builder);
     $builder->add('metaDescription', 'text', Argument::any())->willReturn($builder);
     $this->buildForm($builder, array());
 }
示例#23
0
 function it_checks_access(AccessHandler $access)
 {
     // Having
     $this->setAccessHandler($access);
     // Expect
     $access->check(Argument::withEntry("id", "home"))->shouldBeCalled()->willReturn(true);
     $access->check(Argument::withEntry("id", "your-account"))->shouldBeCalled()->willReturn(false);
     // When
     $menu = $this->make(['home' => [], 'your-account' => []]);
     // Expect
     $menu->shouldReturnAnInstanceOf('Styde\\Html\\Menu\\Menu');
     $items = ['home' => ['class' => '', 'submenu' => null, 'id' => 'home', 'active' => false, 'title' => 'Home', 'url' => '#']];
     $menu->getItems()->shouldReturn($items);
 }
 public function testClass()
 {
     $connection = $this->prophesize(ConnectionInterface::class);
     $connection->pull(Argument::withEntry('subscription', self::SUBSCRIPTION))->shouldBeCalled()->willReturn(['receivedMessages' => [['message' => ['data' => base64_encode('hello world')]]]]);
     $snippet = $this->snippetFromClass(Message::class);
     $snippet->addLocal('connectionStub', $connection->reveal());
     $snippet->insertAfterLine(3, '$reflection = new \\ReflectionClass($pubsub);
         $property = $reflection->getProperty(\'connection\');
         $property->setAccessible(true);
         $property->setValue($pubsub, $connectionStub);
         $property->setAccessible(false);
         $property = $reflection->getProperty(\'encode\');
         $property->setAccessible(true);
         $property->setValue($pubsub, \'false\');
         $property->setAccessible(false);');
     $res = $snippet->invoke('messages');
     $this->assertInstanceOf(\Generator::class, $res->returnVal());
     $this->assertEquals('hello world', $res->output());
 }
示例#25
0
 function it_should_send_request_with_custom_options($httpClient, $response)
 {
     $httpClient->request('GET', '/uri', Argument::withEntry('timeout', 10))->willReturn($response);
     $this->send('GET', '/uri', null, [], [], ['timeout' => 10])->shouldReturn($response);
 }
 public function testSubscriptions()
 {
     $subscriptionResult = [['name' => 'projects/project/subscriptions/subscription-a', 'topic' => 'projects/project/topics/topic-a'], ['name' => 'projects/project/subscriptions/subscription-b', 'topic' => 'projects/project/topics/topic-a'], ['name' => 'projects/project/subscriptions/subscription-c', 'topic' => 'projects/project/topics/topic-a']];
     $this->connection->listSubscriptions(Argument::withEntry('foo', 'bar'))->willReturn(['subscriptions' => $subscriptionResult])->shouldBeCalledTimes(1);
     $this->client->setConnection($this->connection->reveal());
     $subscriptions = $this->client->subscriptions(['foo' => 'bar']);
     $this->assertInstanceOf(Generator::class, $subscriptions);
     $arr = iterator_to_array($subscriptions);
     $this->assertInstanceOf(Subscription::class, $arr[0]);
     $this->assertEquals($arr[0]->info()['name'], $subscriptionResult[0]['name']);
     $this->assertEquals($arr[1]->info()['name'], $subscriptionResult[1]['name']);
     $this->assertEquals($arr[2]->info()['name'], $subscriptionResult[2]['name']);
 }
示例#27
0
 public function testSubscriptions()
 {
     $subscriptionResult = ['projects/project-name/subscriptions/subscription-a', 'projects/project-name/subscriptions/subscription-b', 'projects/project-name/subscriptions/subscription-c'];
     $this->connection->listSubscriptionsByTopic(Argument::withEntry('foo', 'bar'))->willReturn(['subscriptions' => $subscriptionResult])->shouldBeCalledTimes(1);
     $topic = new Topic($this->connection->reveal(), 'topic-name', 'project-name');
     $subscriptions = $topic->subscriptions(['foo' => 'bar']);
     $this->assertInstanceOf(Generator::class, $subscriptions);
     $arr = iterator_to_array($subscriptions);
     $this->assertInstanceOf(Subscription::class, $arr[0]);
     $this->assertEquals($arr[0]->name(), $subscriptionResult[0]);
     $this->assertEquals($arr[1]->name(), $subscriptionResult[1]);
     $this->assertEquals($arr[2]->name(), $subscriptionResult[2]);
 }
示例#28
0
 function it_adds_code_with_specified_type_and_label(FormEvent $event, FormInterface $form, CodeAwareInterface $resource)
 {
     $this->beConstructedWith(FormType::class, ['label' => 'sylius.ui.name']);
     $event->getData()->willReturn($resource);
     $event->getForm()->willReturn($form);
     $resource->getCode()->willReturn('Code12');
     $form->add('code', FormType::class, Argument::withEntry('label', 'sylius.ui.name'))->shouldBeCalled();
     $this->preSetData($event);
 }
 /**
  * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
  */
 function it_should_set_default_options($resolver)
 {
     $resolver->setDefaults(Argument::allOf(Argument::withEntry('data_class', 'FSi\\DoctrineExtensions\\Uploadable\\File'), Argument::withEntry('constraints', Argument::withEntry(0, Argument::type('\\FSi\\Bundle\\DoctrineExtensionsBundle\\Validator\\Constraints\\File')))))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
 public function testExcludeFlags()
 {
     $defaultFlags = $this->getDefaultFlags();
     $bundleDir = realpath(__DIR__ . '/../..');
     $kernelDir = $bundleDir . '/Tests/Fixtures';
     $resourceDir = $kernelDir . '/Resources/views';
     $parameterBag = $this->prophesize('Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface');
     $container = $this->prophesize('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $loaderDefinition = $this->prophesize('Symfony\\Component\\DependencyInjection\\Definition');
     $loaderDefinition->addMethodCall("addPath", [$resourceDir])->shouldBeCalled();
     $container->getParameterBag()->willReturn($parameterBag->reveal());
     $container->hasExtension(Argument::any())->willReturn(false);
     $container->addResource(new FileResource(realpath(__DIR__ . '/../../Resources/config/handlebars.xml')))->shouldBeCalled();
     $container->setDefinition(Argument::type('string'), Argument::type('Symfony\\Component\\DependencyInjection\\Definition'))->shouldBeCalled();
     $container->setAlias(Argument::type('string'), Argument::type('Symfony\\Component\\DependencyInjection\\Alias'))->shouldBeCalled();
     $container->setParameter("handlebars.cms.default_namespace", null)->shouldBeCalled();
     $container->setParameter("handlebars.translation.default_namespace", null)->shouldBeCalled();
     $container->setParameter("handlebars.translation.interpolation_prefix", '%')->shouldBeCalled();
     $container->setParameter("handlebars.translation.interpolation_suffix", '%')->shouldBeCalled();
     $container->getParameter('kernel.bundles')->willReturn([])->shouldBeCalled();
     $container->setParameter('handlebars.assetic', false)->shouldBeCalled();
     $container->getDefinition("handlebars.loader.filesystem")->willReturn($loaderDefinition->reveal())->shouldBeCalled();
     $container->getParameter("kernel.root_dir")->willReturn($kernelDir);
     $container->addResource(new FileExistenceResource($resourceDir))->shouldBeCalled();
     $cacheDefinition = $this->prophesize('Symfony\\Component\\DependencyInjection\\Definition');
     $cacheDefinition->replaceArgument(0, '%kernel.cache_dir%/handlebars')->shouldBeCalled();
     $cacheDefinition->replaceArgument(1, '%kernel.debug%')->shouldBeCalled();
     $hbDefinition = $this->prophesize('Symfony\\Component\\DependencyInjection\\Definition');
     $hbDefinition->replaceArgument(2, Argument::withEntry('flags', $defaultFlags & ~LightnCandy::FLAG_ERROR_LOG))->shouldBeCalled();
     $container->getDefinition("handlebars.cache")->willReturn($cacheDefinition);
     $container->getDefinition("handlebars")->willReturn($hbDefinition);
     $extension = new HandlebarsExtension();
     $extension->load([['flags' => ['FLAG_STANDALONEPHP'], 'excludeFlags' => ['FLAG_ERROR_LOG', 'FLAG_BESTPERFORMANCE']]], $container->reveal());
 }