/**
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  * @param \Doctrine\Common\Annotations\AnnotationReader $annotationReader
  * @param \FSi\Bundle\AdminBundle\Finder\AdminClassFinder $adminClassFinder
  */
 function it_registers_annotated_admin_classes_as_services($container, $annotationReader, $adminClassFinder)
 {
     $container->getParameter('kernel.bundles')->willReturn(array('FSi\\Bundle\\AdminBundle\\spec\\fixtures\\MyBundle', 'FSi\\Bundle\\AdminBundle\\FSiAdminBundle', 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'));
     $baseDir = __DIR__ . '/../../../../../..';
     $adminClassFinder->findClasses(array(realpath($baseDir . '/spec/fixtures/Admin'), realpath($baseDir . '/Admin')))->willReturn(array('FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\CRUDElement'));
     $annotationReader->getClassAnnotation(Argument::allOf(Argument::type('ReflectionClass'), Argument::which('getName', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\CRUDElement')), 'FSi\\Bundle\\AdminBundle\\Annotation\\Element')->willReturn(null);
     $annotationReader->getClassAnnotation(Argument::allOf(Argument::type('ReflectionClass'), Argument::which('getName', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement')), 'FSi\\Bundle\\AdminBundle\\Annotation\\Element')->willReturn(new Element(array()));
     $container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'), Argument::which('getResource', realpath($baseDir . '/spec/fixtures/Admin')), Argument::which('getPattern', '/\\.php$/')))->shouldBeCalled();
     $container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'), Argument::which('getResource', realpath($baseDir . '/Admin')), Argument::which('getPattern', '/\\.php$/')))->shouldBeCalled();
     $container->addDefinitions(Argument::that(function ($definitions) {
         if (count($definitions) !== 1) {
             return false;
         }
         /** @var \Symfony\Component\DependencyInjection\Definition $definition */
         $definition = $definitions[0];
         if ($definition->getClass() !== 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement') {
             return false;
         }
         if (!$definition->hasTag('admin.element')) {
             return false;
         }
         return true;
     }))->shouldBeCalled();
     $this->process($container);
 }
 function it_should_have_fields(FormBuilderInterface $builder, FormBuilderInterface $costBuilder, FormBuilderInterface $emailBuilder)
 {
     // Cost field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->create('cost', 'money', Argument::cetera())->shouldBeCalled()->willReturn($costBuilder);
     /** @noinspection PhpParamsInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     $costBuilder->addViewTransformer(Argument::type(MoneyTransformer::class), true)->willReturn($costBuilder);
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add($costBuilder)->shouldBeCalled()->willReturn($builder);
     // Stripe field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add('stripe_form', 'cm_stripe', Argument::that(function (array $options) {
         $expectedOptions = ['inherit_data' => true, 'label' => false];
         foreach ($expectedOptions as $option => $value) {
             if (!isset($options[$option]) || $options[$option] !== $value) {
                 return false;
             }
         }
         return true;
     }))->shouldBeCalled()->willReturn($builder);
     // Description field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add('description', Argument::cetera())->shouldBeCalled()->willReturn($builder);
     // User email field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->create('userEmail', Argument::cetera())->shouldBeCalled()->willReturn($emailBuilder);
     /** @noinspection PhpParamsInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     $emailBuilder->addViewTransformer(Argument::type(EmailTransformer::class), true)->willReturn($emailBuilder);
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add($emailBuilder)->shouldBeCalled()->willReturn($builder);
     /** @noinspection PhpUndefinedMethodInspection */
     $this->buildForm($builder, []);
 }
 /**
  * @covers ::processAttachments
  *
  * @dataProvider attachmentsProvider
  */
 public function testHtmlResponse(array $attachments)
 {
     $big_pipe_response = new BigPipeResponse('original');
     $big_pipe_response->setAttachments($attachments);
     // This mock is the main expectation of this test: verify that the decorated
     // service (that is this mock) never receives BigPipe placeholder
     // attachments, because it doesn't know (nor should it) how to handle them.
     $html_response_attachments_processor = $this->prophesize(AttachmentsResponseProcessorInterface::class);
     $html_response_attachments_processor->processAttachments(Argument::that(function ($response) {
         return $response instanceof HtmlResponse && empty(array_intersect(['big_pipe_placeholders', 'big_pipe_nojs_placeholders'], array_keys($response->getAttachments())));
     }))->will(function ($args) {
         /** @var \Symfony\Component\HttpFoundation\Response|\Drupal\Core\Render\AttachmentsInterface $response */
         $response = $args[0];
         // Simulate its actual behavior.
         $attachments = array_diff_key($response->getAttachments(), ['html_response_attachment_placeholders' => TRUE]);
         $response->setContent('processed');
         $response->setAttachments($attachments);
         return $response;
     })->shouldBeCalled();
     $big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($html_response_attachments_processor);
     $processed_big_pipe_response = $big_pipe_response_attachments_processor->processAttachments($big_pipe_response);
     // The secondary expectation of this test: the original (passed in) response
     // object remains unchanged, the processed (returned) response object has
     // the expected values.
     $this->assertSame($attachments, $big_pipe_response->getAttachments(), 'Attachments of original response object MUST NOT be changed.');
     $this->assertEquals('original', $big_pipe_response->getContent(), 'Content of original response object MUST NOT be changed.');
     $this->assertEquals(array_diff_key($attachments, ['html_response_attachment_placeholders' => TRUE]), $processed_big_pipe_response->getAttachments(), 'Attachments of returned (processed) response object MUST be changed.');
     $this->assertEquals('processed', $processed_big_pipe_response->getContent(), 'Content of returned (processed) response object MUST be changed.');
 }
 /**
  * @param Symfony\Component\DependencyInjection\ContainerBuilder $container
  * @param Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag
  * @param Symfony\Component\DependencyInjection\Definition $libraryDefinition
  * @param Symfony\Component\DependencyInjection\Definition $parserDefinition
  */
 public function it_loads_the_configuration($container, $parameterBag, $libraryDefinition, $parserDefinition)
 {
     $container->getParameterBag()->shouldBeCalled()->willReturn($parameterBag);
     $container->hasExtension(Argument::any())->shouldBeCalled()->willReturn(false);
     $container->addResource(Argument::any())->shouldBeCalled()->willReturn($container);
     foreach (array('dispatcher', 'metadata.driver', 'metadata.factory', 'metadata.reader', 'parser', 'library', 'parser', 'formatter', 'formatter.markdown', 'formatter.textile', 'validator', 'validator.constraint_validator_factory') as $service) {
         $container->setDefinition('fabricius.' . $service, Argument::any())->shouldBeCalled();
     }
     $container->setAlias('fabricius', Argument::any())->shouldBeCalled();
     $container->getDefinition('fabricius.library')->shouldBeCalled()->willReturn($libraryDefinition);
     $libraryDefinition->addMethodCall('registerRepository', Argument::that(function ($args) {
         if ($args[0] !== 'Fabricius\\FabriciusBundle\\ContentItem') {
             return false;
         } elseif ($args[1]->getClass() !== 'Fabricius\\Loader\\FileLoader') {
             return false;
         } elseif ($args[2]->getClass() !== 'Fabricius\\Storage\\ArrayStorage') {
             return false;
         }
         return true;
     }))->shouldBeCalled();
     $container->getDefinition('fabricius.parser')->shouldBeCalled()->willReturn($parserDefinition);
     $parserDefinition->addMethodCall('setExcerptDelimiter', array('[MORE]'))->shouldBeCalled();
     $config = array('excerpt_delimiter' => '[MORE]', 'formatter' => array('markdown' => array('enabled' => true), 'textile' => array('enabled' => true)), 'repositories' => array('Fabricius\\FabriciusBundle\\ContentItem' => array('loader' => array('file' => array('dir' => __DIR__)), 'storage' => array('array' => array('enabled' => true)))));
     $this->load(array('fabricius' => $config), $container)->shouldReturn(null);
 }
 private function pathArgument($expected)
 {
     $regex = $this->pathRegex($expected);
     return Argument::that(function ($path) use($regex) {
         return preg_match($regex, $path);
     });
 }
 /** @test */
 public function it_registers_columns()
 {
     /** @var CompoundColumn $compoundColumn */
     $compoundColumn = null;
     $datagridBuilder = $this->prophesize(DatagridBuilderInterface::class);
     $datagridBuilder->set(Argument::that(function ($column) use(&$compoundColumn) {
         self::assertInstanceOf(CompoundColumn::class, $column);
         $compoundColumn = $column;
         return true;
     }))->shouldBeCalledTimes(1);
     $builder = new CompoundColumnBuilder($this->factory, $datagridBuilder->reveal(), 'actions', ['label' => 'act']);
     $builder->add('id', NumberType::class);
     $builder->add('name', TextType::class, ['format' => '%s']);
     self::assertTrue($builder->has('id'));
     self::assertTrue($builder->has('name'));
     self::assertFalse($builder->has('date'));
     // Register it.
     $builder->end();
     if (!$compoundColumn) {
         self::fail('$compoundColumn was not set. So set() was not called internally.');
     }
     self::assertEquals('actions', $compoundColumn->getName());
     self::assertEquals(['label' => 'act', 'data_provider' => null], $compoundColumn->getOptions());
     $columns = $compoundColumn->getColumns();
     self::assertArrayHasKey('id', $columns);
     self::assertArrayHasKey('name', $columns);
     self::assertArrayNotHasKey('date', $columns);
     self::assertColumnEquals($columns['id'], 'id', NumberType::class, ['parent_column' => $compoundColumn, 'data_provider' => null]);
     self::assertColumnEquals($columns['name'], 'name', TextType::class, ['format' => '%s', 'parent_column' => $compoundColumn, 'data_provider' => null]);
 }
 function let(FileSourceRegistry $fileSourceRegistry, ArchiveFactory $archiveFactory, ArchiveRepository $archiveRepository, FileSource $fileSource, Archive $archive, Archive $existingArchive, ArchiveRepository $archiveRepository, File $file)
 {
     $fileSourceRegistry->get('dummy')->willReturn($fileSource);
     $fileSource->getFiles('path')->willReturn([$file]);
     $archiveFactory->create('name', Argument::that(function ($archiveFiles) {
         foreach ($archiveFiles as $archiveFile) {
             if (!$archiveFile instanceof ArchiveFile) {
                 return false;
             }
         }
         return true;
     }))->willReturn($archive);
     $archiveFactory->create('existingName', Argument::that(function ($archiveFiles) {
         foreach ($archiveFiles as $archiveFile) {
             if (!$archiveFile instanceof ArchiveFile) {
                 return false;
             }
         }
         return true;
     }))->willReturn($existingArchive);
     $archive->getName()->willReturn('name');
     $existingArchive->getName()->willReturn('existingName');
     $archiveRepository->findByName("name")->willReturn(null);
     $archiveRepository->findByName("existingName")->willReturn($existingArchive);
     $this->beConstructedWith($fileSourceRegistry, $archiveFactory, $archiveRepository);
 }
 public function let(RowBuilderFactory $rowBuilderFactory, ColumnIndexTransformer $columnIndexTransformer, ValueTransformer $valueTransformer, RowBuilder $rowBuilder)
 {
     $startWith = function ($startString) {
         return function ($string) use($startString) {
             return $startString === substr($string, 0, strlen($startString));
         };
     };
     $columnIndexTransformer->transform(Argument::that($startWith('A')))->willReturn(0);
     $columnIndexTransformer->transform(Argument::that($startWith('B')))->willReturn(1);
     $columnIndexTransformer->transform(Argument::that($startWith('C')))->willReturn(2);
     $columnIndexTransformer->transform(Argument::that($startWith('D')))->willReturn(3);
     $row = null;
     $rowBuilderFactory->create()->will(function () use($rowBuilder, &$row) {
         $row = [];
         return $rowBuilder;
     });
     $rowBuilder->addValue(Argument::type('int'), Argument::type('array'))->will(function ($args) use(&$row) {
         $row[$args[0]] = $args[1];
     });
     $rowBuilder->getData()->will(function () use(&$row) {
         return $row;
     });
     $this->beConstructedWith($rowBuilderFactory, $columnIndexTransformer, $valueTransformer, __DIR__ . '/fixtures/sheet.xml', []);
     $valueTransformer->transform(Argument::type('string'), Argument::type('string'), Argument::type('string'))->will(function ($args) {
         return $args;
     });
 }
 public function testShouldDispatchEvents()
 {
     $notification = Email::create();
     $notifyArg = Argument::allOf(Argument::type(Email::class), Argument::that(function ($arg) use($notification) {
         return $arg !== $notification;
     }));
     $handler = $this->prophesize(NotificationHandlerInterface::class);
     $handler->getName()->willReturn('default');
     $handler->supports(Argument::any())->willReturn(true);
     $handler->notify($notifyArg)->willReturn();
     $handler2 = $this->prophesize(NotificationHandlerInterface::class);
     $handler2->getName()->willReturn('default');
     $handler2->supports(Argument::any())->willReturn(true);
     $handler2->notify($notifyArg)->willReturn();
     $this->dispatcher->dispatch('notifire.pre_notify', Argument::type(PreNotifyEvent::class))->shouldBeCalled();
     $this->dispatcher->dispatch('notifire.notify', Argument::that(function ($arg) use($notification) {
         if (!$arg instanceof NotifyEvent) {
             return false;
         }
         $not = $arg->getNotification();
         return $not !== $notification;
     }))->shouldBeCalledTimes(2);
     $this->dispatcher->dispatch('notifire.post_notify', Argument::type(PostNotifyEvent::class))->shouldBeCalled();
     $this->manager->addHandler($handler->reveal());
     $this->manager->addHandler($handler2->reveal());
     $this->manager->notify($notification);
 }
示例#10
0
 public function testRender()
 {
     $request = new Request(['test' => 1], ['test' => 2], [], ['test' => 3]);
     $activeTheme = $this->prophesize(ActiveTheme::class);
     $controllerResolver = $this->prophesize(ControllerResolver::class);
     $webspaceManager = $this->prophesize(WebspaceManager::class);
     $requestStack = $this->prophesize(RequestStack::class);
     $structure = $this->prophesize(PageBridge::class);
     $translator = $this->prophesize(TranslatorInterface::class);
     $webspaceManager->findWebspaceByKey('sulu_io')->willReturn($this->getWebspace());
     $structure->getController()->willReturn('TestController:test');
     $structure->getLanguageCode()->willReturn('de_at');
     $structure->getWebspaceKey()->willReturn('sulu_io');
     $controllerResolver->getController(Argument::type(Request::class))->will(function () {
         return [new TestController(), 'testAction'];
     });
     $requestStack->getCurrentRequest()->willReturn($request);
     $requestStack->push(Argument::that(function (Request $newRequest) use($request) {
         $this->assertEquals($request->query->all(), $newRequest->query->all());
         $this->assertEquals($request->request->all(), $newRequest->request->all());
         $this->assertEquals($request->cookies->all(), $newRequest->cookies->all());
         return true;
     }))->shouldBeCalledTimes(1);
     $requestStack->pop()->shouldBeCalled();
     $translator->getLocale()->willReturn('de');
     $translator->setLocale('de_at')->shouldBeCalled();
     $translator->setLocale('de')->shouldBeCalled();
     $renderer = new PreviewRenderer($activeTheme->reveal(), $controllerResolver->reveal(), $webspaceManager->reveal(), $requestStack->reveal(), $translator->reveal());
     $result = $renderer->render($structure->reveal());
     $this->assertEquals('TEST', $result);
 }
示例#11
0
文件: FredSpec.php 项目: wouterj/fred
 function it_accepts_nested_tasks(TaskStack $stack)
 {
     $stack->push(Argument::that(function ($task) {
         return $task->getName() === 'build' && $task->getDependencies() === array('test', 'minify', 'cleanup');
     }));
     $this->task('build', array('test', 'minify', 'cleanup'));
 }
 /**
  * @covers ::onPageContext
  */
 public function testOnPageContext()
 {
     $collection = new RouteCollection();
     $route_provider = $this->prophesize(RouteProviderInterface::class);
     $route_provider->getRoutesByPattern('/test_route')->willReturn($collection);
     $request = new Request();
     $request_stack = new RequestStack();
     $request_stack->push($request);
     $data_definition = new DataDefinition(['type' => 'entity:user']);
     $typed_data = $this->prophesize(TypedDataInterface::class);
     $this->typedDataManager->getDefaultConstraints($data_definition)->willReturn([]);
     $this->typedDataManager->create($data_definition, 'banana')->willReturn($typed_data->reveal());
     $this->typedDataManager->createDataDefinition('bar')->will(function () use($data_definition) {
         return $data_definition;
     });
     $this->page->getPath()->willReturn('/test_route');
     $this->page->getParameter('foo')->willReturn(['machine_name' => 'foo', 'type' => 'integer', 'label' => 'Foo']);
     $this->page->getParameter('baz')->willReturn(['machine_name' => 'baz', 'type' => 'integer', 'label' => '']);
     $this->page->getParameter('page')->willReturn(['machine_name' => 'page', 'type' => 'entity:page', 'label' => '']);
     $this->page->addContext('foo', Argument::that(function ($context) {
         return $context instanceof Context && $context->getContextDefinition()->getLabel() == 'Foo';
     }))->shouldBeCalled();
     $this->page->addContext('baz', Argument::that(function ($context) {
         return $context instanceof Context && $context->getContextDefinition()->getLabel() == '{baz} from route';
     }))->shouldBeCalled();
     $this->page->addContext('page', Argument::that(function ($context) {
         return $context instanceof Context && $context->getContextDefinition()->getLabel() == '{page} from route';
     }))->shouldBeCalled();
     $collection->add('test_route', new Route('/test_route', [], [], ['parameters' => ['foo' => ['type' => 'bar'], 'baz' => ['type' => 'bop'], 'page' => ['type' => 'entity:page']]]));
     // Set up a request with one of the expected parameters as an attribute.
     $request->attributes->add(['foo' => 'banana']);
     $route_param_context = new RouteParamContext($route_provider->reveal(), $request_stack);
     $route_param_context->onPageContext($this->event);
 }
示例#13
0
 /**
  * @param \Zend\EventManager\EventManager $eventManager
  * @param \Zend\Form\FormInterface $form
  * @param \ArrayAccess $spec
  */
 public function it_should_trigger_events_during_form_configuration($eventManager, $form, $spec)
 {
     $this->configureForm($form, $spec);
     $triggeredEvents = array(FormEvent::EVENT_CONFIGURE_ELEMENT_PRE, FormEvent::EVENT_CONFIGURE_ELEMENT_POST);
     $eventManager->trigger(Argument::that(function ($event) use($form, $spec, $triggeredEvents) {
         return $event instanceof FormEvent && in_array($event->getName(), $triggeredEvents) && $event->getTarget() == $form->getWrappedObject() && $event->getParam('spec') == $spec->getWrappedObject();
     }))->shouldBeCalledTimes(count($triggeredEvents));
 }
示例#14
0
 function it_request_provided_time_apod(Client $httpClient, ResponseInterface $response)
 {
     $today = new \DateTime('today');
     $httpClient->request('GET', Argument::any(), Argument::that(function ($argument) use($today) {
         return $argument['query']['date'] === $today->format('Y-m-d');
     }))->shouldBeCalled()->willReturn($response);
     $this->get('today');
 }
 function it_should_not_validate_group_membership_when_going_to_ldap_if_the_op_type_is_not_modification($connection)
 {
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(objectClass=group)(cn=Domain Users)(groupType:1.2.840.113556.1.4.803:=2147483648))' && $operation->getAttributes() == ['objectSid'];
     }))->willReturn(['count' => 1, ["objectSid" => ["count" => 1, 0 => pack('H*', str_replace('\\', '', $this->groupSidHex))], 0 => "objectSid", "count" => 1, "dn" => "CN=Domain Users,CN=Users,dc=example,dc=local"]]);
     $this->setOperationType(AttributeConverterInterface::TYPE_SEARCH_TO);
     $this->toLdap('Domain Users')->shouldBeEqualTo('513');
 }
示例#16
0
 function it_logs_fixture_name_on_before_fixture_event(LoggerInterface $logger, SuiteInterface $suite, FixtureInterface $fixture)
 {
     $fixture->getName()->willReturn('uber_fixture');
     $logger->notice(Argument::that(function ($argument) use($fixture) {
         return false !== strpos($argument, $fixture->getWrappedObject()->getName());
     }))->shouldBeCalled();
     $this->beforeFixture(new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), []), []);
 }
示例#17
0
 public function it_should_render_chartjs_charts(Renderer $view, ChartInterface $chart)
 {
     $view->render(Argument::that(function ($viewModel) use($chart) {
         return $viewModel instanceof ViewModel && $viewModel->getTemplate() === 'zf-charts/chartjs' && $viewModel->getVariable('chart') === $chart->getWrappedObject() && $viewModel->getVariable('width') === 100 && $viewModel->getVariable('height') === 100 && $viewModel->getVariable('showLegend') === false;
     }))->willReturn('chart-html');
     $this->markAsInitialized(true);
     $this->render($chart, ['width' => 100, 'height' => 100, 'show_legend' => false])->shouldBe('chart-html');
 }
示例#18
0
 /** @dataProvider provideLanguage */
 public function testShouldLocalizeErrorMessage($language, $expectedLanguage)
 {
     $this->browser->send(Argument::that(function (Request $r) use($expectedLanguage) {
         assertThat($r->headers['Accept-Language'], is($expectedLanguage));
         return true;
     }))->shouldBeCalled();
     $this->givenGoPay($language)->call($this->urlPath, 'irrelevant content-type', 'irrelevant auth');
 }
 function it_accepts_side_widgets(FunctionInvoker $functionInvoker, Widget $widget)
 {
     $functionInvoker->invoke('add_meta_box', Argument::that(function ($args) {
         return $args[0] == 'my-widget' && $args[1] == 'My Widget' && Argument::that(function ($callable) {
             return $callable() == '<p>My Widget</p>';
         })->scoreArgument($args[2]) && $args[3] == 'dashboard';
     }))->shouldBeCalled();
     $this->addSideWidget($widget);
 }
 /**
  * @param DomainMessage $command
  * @return \Prophecy\Argument\Token\CallbackToken
  */
 protected function validate_message_body($command)
 {
     return Argument::that(function ($actual) use($command) {
         $messageData = $this->messageConverter->convertToArray($command);
         $messageData['created_at'] = $command->createdAt()->format('Y-m-d\\TH:i:s.u');
         $expected = json_encode($messageData);
         return $expected === $actual;
     });
 }
示例#21
0
 function it_creates_an_article(Blog $blog, Title $title, Text $teaser, Collection $rawDisplayables, SlugifierInterface $slugifier, Slug $slug)
 {
     $slugifier->slugify($title)->shouldBeCalled()->willReturn($slug);
     $blog->addPost(Argument::that(function ($argument) use($slug) {
         return $argument instanceof Article && $argument->getSlug() === $slug->getWrappedObject();
     }))->shouldBeCalled();
     $rawDisplayables->getIterator()->willReturn(new \ArrayIterator([]));
     $this->create($blog, $title, $teaser, $rawDisplayables)->shouldBeAnInstanceOf(Article::class);
 }
示例#22
0
 /**
  * @test
  */
 public function it_adds_notifications()
 {
     $message = $this->prophesize(DTO\Message::class);
     $this->mockedRecordDecoder->addEntries(Argument::type(Camt054\DTO\Notification::class), Argument::type('\\SimpleXMLElement'))->shouldBeCalled();
     $message->setRecords(Argument::that(function ($argument) {
         return is_array($argument) && $argument[0] instanceof Camt054\DTO\Notification;
     }))->shouldBeCalled();
     $this->decoder->addRecords($message->reveal(), $this->getXmlMessage());
 }
 /**
  * @param \Zend\Mail\Transport\TransportInterface $transport
  * @param \Phpro\MailManager\Service\MailMessageCreator $messageCreator
  * @param \Zend\Mime\Message $mailMessage
  */
 public function it_should_send_a_mail_with_zend_view_renderer($transport, $messageCreator, $mailMessage)
 {
     $mail = $this->getRenderableMailStub();
     $messageCreator->createMessage($mail)->willReturn($mailMessage);
     $transport->send(Argument::that(function ($message) use($mail, $mailMessage) {
         return $message instanceof Mandrill && $message->getTo()->has('*****@*****.**') && $message->getCc()->has('*****@*****.**') && $message->getBcc()->has('*****@*****.**') && $message->getFrom()->has('*****@*****.**') && $message->getReplyTo()->has('*****@*****.**') && $message->getSubject() == $mail->getSubject() && $message->getOptions() == ['subaccount' => 'test'] && $message->getImages() == [] && $message->getTags() == ['tag1', 'tag2'] && $message->getBody() == $mailMessage->getWrappedObject();
     }))->shouldBeCalled();
     $this->send($mail);
 }
示例#24
0
 /**
  * @param \Zend\EventManager\EventManager $eventManager
  */
 public function it_should_trigger_events_while_creating_form($eventManager)
 {
     $this->mockConfiguration();
     $this->createForm('stdClass');
     $eventManager->trigger(Argument::that(function ($event) {
         $validEvents = array(FormEvent::EVENT_FORM_CREATE_PRE, FormEvent::EVENT_FORM_CREATE_POST);
         return $event instanceof FormEvent && in_array($event->getName(), $validEvents);
     }))->shouldBeCalledTimes(2);
 }
示例#25
0
 function it_convert_array_body_as_json_content($httpClient, $response)
 {
     $body = ['value' => 'test'];
     $httpClient->request('POST', '/uri', Argument::that(function ($options) use($body) {
         return $options['body'] === json_encode($body) && $options['headers']['Content-Type'] === 'application/json';
     }))->willReturn($response);
     $this->post('/uri', $body)->shouldReturn($response);
     $this->send('POST', '/uri', $body)->shouldReturn($response);
 }
 /**
  * @param \Zend\Mail\Transport\TransportInterface $transport
  * @param \Phpro\MailManager\Service\MailMessageCreator $messageCreator
  * @param \Zend\Mime\Message $mailMessage
  */
 public function it_should_send_a_mail($transport, $messageCreator, $mailMessage)
 {
     $mail = $this->getMailStub();
     $messageCreator->createMessage($mail)->willReturn($mailMessage);
     $transport->send(Argument::that(function ($message) use($mail, $mailMessage) {
         return $message->getBody() == $mailMessage->getWrappedObject() && $message->getTo()->has('*****@*****.**') && $message->getCc()->has('*****@*****.**') && $message->getBcc()->has('*****@*****.**') && $message->getFrom()->has('*****@*****.**') && $message->getReplyTo()->has('*****@*****.**') && $message->getSubject() == $mail->getSubject();
     }))->shouldBeCalled();
     $this->send($mail);
 }
示例#27
0
 function let(LdapConnectionInterface $connection, EventDispatcherInterface $dispatcher)
 {
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == "(&(objectClass=*))" && $operation->getBaseDn() == "";
     }))->willReturn($this->entry);
     $connection->getConfig()->willReturn(new DomainConfiguration('example.local'));
     $connection->isBound()->willReturn(false);
     $connection->connect('', '', true)->willReturn(null);
     $this->beConstructedWith($connection, $dispatcher);
 }
 /**
  * Checks that the argument passed is an instance of FileResource with the given resource.
  *
  * @param string $filePath
  *
  * @return \Prophecy\Argument\Token\CallbackToken
  */
 public static function service($filePath)
 {
     return Argument::that(function ($args) use($filePath) {
         /** @var FileResource $args */
         if (false === $args instanceof FileResource) {
             return false;
         }
         return $filePath === $args->getResource();
     });
 }
示例#29
0
 function it_uses_parser_options(ParserFactory $parserFactory, TraverserFactory $traverserFactory, Parser $parser, NodeTraverserInterface $traverser)
 {
     $file = new SplFileInfo('php://memory');
     $this->setParserOptions($options = ['kind' => 'php7']);
     $parserFactory->createFromOptions($options)->shouldBeCalled()->willReturn($parser);
     $traverserFactory->createForTaskContext($options, Argument::that(function (ParserContext $context) use($file) {
         return $context->getFile() === $file && $context->getErrors() instanceof ParseErrorsCollection;
     }))->shouldBeCalled()->willReturn($traverser);
     $this->parse($file);
 }
示例#30
0
 /**
  * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  * @param \Prophecy\Doubler\Generator\Node\MethodNode $method
  */
 function it_should_not_supply_a_file_for_a_directory_iterator($node, $method)
 {
     $node->hasMethod('__construct')->willReturn(true);
     $node->getMethod('__construct')->willReturn($method);
     $node->getParentClass()->willReturn('DirectoryIterator');
     $method->setCode(Argument::that(function ($value) {
         return strpos($value, '.php') === false;
     }))->shouldBeCalled();
     $this->apply($node);
 }