コード例 #1
0
 public function testConfigureNoRequest()
 {
     $response = new Response();
     $expected_response = clone $response;
     $this->request_stack->expects($this->once())->method('getMasterRequest')->will($this->returnValue(null));
     $configurator = new ResponseConfigurator($this->key_builder, $this->request_stack, []);
     $this->assertEquals($expected_response, $configurator->configure($response, new \DateTime(), -1));
 }
コード例 #2
0
 /**
  * setup type we want to test
  *
  * @return void
  */
 public function setUp()
 {
     $this->converter = $this->getMockBuilder('\\Graviton\\DocumentBundle\\Service\\ExtReferenceConverterInterface')->disableOriginalConstructor()->getMock();
     $this->requestAttrs = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\ParameterBag')->disableOriginalConstructor()->setMethods(['get'])->getMock();
     $this->request = new Request();
     $this->request->attributes = $this->requestAttrs;
     $this->requestStack = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\RequestStack')->disableOriginalConstructor()->setMethods(['getCurrentRequest'])->getMock();
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($this->request);
 }
コード例 #3
0
 /**
  * Setup the test
  *
  * @return void
  */
 protected function setUp()
 {
     $this->requestAttrs = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->setMethods(['get'])->getMock();
     $this->request = new Request();
     $this->request->attributes = $this->requestAttrs;
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->setMethods(['getCurrentRequest'])->getMock();
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($this->request);
     parent::setUp();
 }
コード例 #4
0
ファイル: LocaleContextTest.php プロジェクト: blazarecki/lug
 public function testLocalesWithApiRequestWithoutAcceptLanguageHeader()
 {
     $request = $this->createRequestMock();
     $request->headers->expects($this->once())->method('get')->with($this->identicalTo('Accept-Language'))->will($this->returnValue(null));
     $request->expects($this->once())->method('getLocale')->will($this->returnValue($locale = 'en'));
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue($request));
     $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true));
     $this->assertSame([$locale], $this->localeContext->getLocales());
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->placesAutocompleteHelperMock = $this->getMockBuilder('Ivory\\GoogleMap\\Helper\\Places\\AutocompleteHelper')->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->requestMock->expects($this->any())->method('getLocale')->will($this->returnValue('en'));
     $this->requestStackMock = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
     $this->requestStackMock->expects($this->any())->method('getCurrentRequest')->willReturn($this->requestMock);
     $this->placesAutocompleteType = new PlacesAutocompleteType($this->placesAutocompleteHelperMock, $this->requestStackMock);
     $this->factory = Forms::createFormFactoryBuilder()->addType($this->placesAutocompleteType)->getFormFactory();
     //        var_dump($this->factory);die;
 }
コード例 #6
0
ファイル: SmartContentTest.php プロジェクト: kriswillis/sulu
 public function setUp()
 {
     $this->contentQuery = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Query\\ContentQueryExecutorInterface');
     $this->contentQueryBuilder = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Query\\ContentQueryBuilderInterface');
     $this->tagManager = $this->getMockForAbstractClass('Sulu\\Bundle\\TagBundle\\Tag\\TagManagerInterface', [], '', false, true, true, ['resolveTagIds', 'resolveTagNames']);
     $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')->getMock();
     $this->request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($this->request));
     $this->smartContent = new SmartContent($this->contentQuery, $this->contentQueryBuilder, $this->tagManager, $this->requestStack, 'SuluContentBundle:Template:content-types/smart_content.html.twig');
     $this->tagManager->expects($this->any())->method('resolveTagIds')->will($this->returnValueMap([[[1, 2], ['Tag1', 'Tag2']]]));
     $this->tagManager->expects($this->any())->method('resolveTagName')->will($this->returnValueMap([[['Tag1', 'Tag2'], [1, 2]]]));
 }
コード例 #7
0
 protected function setUp()
 {
     $this->router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $this->requestStack = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
     $this->requestStack->expects($this->any())->method('getMasterRequest')->will($this->returnValue(new Request()));
     $column = new Action($this->router, $this->requestStack);
     $column->setName('action');
     $column->initOptions();
     $extension = new DefaultColumnOptionsExtension();
     $extension->initOptions($column);
     $this->column = $column;
 }
コード例 #8
0
 /**
  * Test setup.
  */
 public function setup()
 {
     $this->controller = [new \stdClass(), 'fooAction'];
     $this->params = [];
     $this->paramReader = $this->getMock('FOS\\RestBundle\\Request\\ParamReaderInterface');
     $this->validator = $this->getMock('Symfony\\Component\\Validator\\Validator\\ValidatorInterface');
     $this->violationFormatter = $this->getMock('FOS\\RestBundle\\Validator\\ViolationFormatterInterface');
     $this->request = new Request();
     $this->requestStack = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack', array());
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($this->request);
     $this->paramFetcherBuilder = $this->getMockBuilder('FOS\\RestBundle\\Request\\ParamFetcher');
     $this->paramFetcherBuilder->setConstructorArgs(array($this->paramReader, $this->requestStack, $this->violationFormatter, $this->validator))->setMethods(null);
 }
コード例 #9
0
 /**
  * @dataProvider getHashParams
  *
  * @param string $algorithm
  * @param Request|null $request
  */
 public function testHash($algorithm, Request $request = null)
 {
     $last_modified = new \DateTime('-1 day');
     $response = (new Response())->setLastModified($last_modified);
     $this->request_stack->expects($this->atLeastOnce())->method('getMasterRequest')->will($this->returnValue($request));
     $hasher = new EtagHasher($this->request_stack, $algorithm);
     $suffix = '';
     if ($request) {
         $suffix = EtagHasher::ETAG_SEPARATOR . http_build_query($request->cookies->all());
     }
     $etag = hash($algorithm, $response->getLastModified()->format(\DateTime::ISO8601) . $suffix);
     $this->assertEquals($etag, $hasher->hash($response));
 }
コード例 #10
0
 /**
  * Test the forcedLogin redirect.
  *
  * @covers ::forceLogin
  * @covers ::__construct
  */
 public function testForceLogin()
 {
     $request = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $query = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
     $request->query = $query;
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
     $parameters = array('returnto' => 'node/1', 'foo' => 'bar');
     $query->expects($this->once())->method('all')->will($this->returnValue($parameters));
     $this->casHelper->expects($this->once())->method('getServerLoginUrl')->with($this->equalTo($parameters))->will($this->returnValue('https://example.com'));
     $expected_response = new TrustedRedirectResponse('https://example.com', 302);
     $force_login_controller = new ForceLoginController($this->casHelper, $this->requestStack);
     $response = $force_login_controller->forceLogin();
     $this->assertEquals($expected_response, $response);
 }
コード例 #11
0
 /**
  * Test setup.
  */
 public function setup()
 {
     $this->controller = [new \stdClass(), 'fooAction'];
     $this->params = [];
     $this->paramReader = $this->getMock(ParamReaderInterface::class);
     $this->validator = $this->getMock(ValidatorInterface::class);
     $this->violationFormatter = $this->getMock(ViolationFormatterInterface::class);
     $this->request = new Request();
     $this->requestStack = $this->getMock(RequestStack::class, array());
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($this->request);
     $this->paramFetcherBuilder = $this->getMockBuilder(ParamFetcher::class);
     $this->paramFetcherBuilder->setConstructorArgs(array($this->paramReader, $this->requestStack, $this->violationFormatter, $this->validator))->setMethods(null);
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
 }
コード例 #12
0
 /**
  * Test the proxy callback.
  *
  * @covers ::callback
  * @covers ::__construct
  *
  * @dataProvider callbackDataProvider
  */
 public function testCallback($pgt_iou, $pgt_id, $request_exception)
 {
     $proxy_callback_controller = $this->getMockBuilder('\\Drupal\\cas\\Controller\\ProxyCallbackController')->setConstructorArgs(array($this->connection, $this->requestStack, $this->casHelper))->setMethods(array('storePgtMapping'))->getMock();
     $request = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $query = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
     $request->query = $query;
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
     if (!$request_exception) {
         $query->expects($this->any())->method('get')->will($this->onConsecutiveCalls($pgt_id, $pgt_iou));
         $expected_response = new Response('OK', 200);
     } else {
         $query->expects($this->any())->method('get')->will($this->returnValue(FALSE));
         $expected_response = new Response('Missing necessary parameters', 400);
     }
     $response = $proxy_callback_controller->callback();
     $this->assertEquals($expected_response->getStatusCode(), $response->getStatusCode());
 }
コード例 #13
0
 /**
  * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
  * @expectedExceptionMessage The request could not be found.
  */
 public function testApiWithHateoasButWithoutRequest()
 {
     $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true));
     $this->parameterResolver->expects($this->once())->method('resolveHateoas')->will($this->returnValue(true));
     $event = $this->createViewEventMock();
     $event->expects($this->once())->method('getView')->will($this->returnValue($view = $this->createViewMock()));
     $view->expects($this->once())->method('getData')->will($this->returnValue($pagerfanta = $this->createPagerfantaMock()));
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue(null));
     $this->subscriber->onApi($event);
 }
コード例 #14
0
ファイル: ContentTypeTest.php プロジェクト: Silwereth/sulu
 public function setUp()
 {
     $this->contentDataProvider = $this->prophesize(DataProviderInterface::class);
     $this->contentDataProvider->getConfiguration()->willReturn($this->getProviderConfiguration());
     $this->contentDataProvider->getDefaultPropertyParameter()->willReturn([]);
     $this->dataProviderPool = new DataProviderPool();
     $this->dataProviderPool->add('content', $this->contentDataProvider->reveal());
     $this->tagManager = $this->getMockForAbstractClass(TagManagerInterface::class, [], '', false, true, true, ['resolveTagIds', 'resolveTagNames']);
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->getMock();
     $this->request = $this->getMockBuilder(Request::class)->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($this->request));
     $this->tagRequestHandler = $this->prophesize(TagRequestHandlerInterface::class);
     $this->tagRequestHandler->getTags('tags')->willReturn([]);
     $this->categoryRequestHandler = $this->prophesize(CategoryRequestHandlerInterface::class);
     $this->categoryRequestHandler->getCategories('categories')->willReturn([]);
     $this->smartContent = new SmartContent($this->dataProviderPool, $this->tagManager, $this->requestStack, $this->tagRequestHandler->reveal(), $this->categoryRequestHandler->reveal(), 'SuluContentBundle:Template:content-types/smart_content.html.twig');
     $this->tagManager->expects($this->any())->method('resolveTagIds')->will($this->returnValueMap([[[1, 2], ['Tag1', 'Tag2']]]));
     $this->tagManager->expects($this->any())->method('resolveTagName')->will($this->returnValueMap([[['Tag1', 'Tag2'], [1, 2]]]));
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityFormBuilder = $this->getMock(EntityFormBuilderInterface::class);
     $this->paymentLineItemManager = $this->getMock(PaymentLineItemManagerInterface::class);
     $this->fieldDefinition = $this->getMock(FieldDefinitionInterface::class);
     $this->renderer = $this->getMock(RendererInterface::class);
     $this->request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($this->request);
     $this->paymentStorage = $this->getMock(EntityStorageInterface::class);
     $this->sut = new PaymentForm($this->randomMachineName(), [], $this->fieldDefinition, [], $this->randomMachineName(), $this->randomMachineName(), [], $this->requestStack, $this->entityFormBuilder, $this->paymentStorage, $this->paymentLineItemManager);
 }
コード例 #16
0
 /**
  * Tests for a potential login error.
  *
  * @dataProvider parameterDataProvider
  */
 public function testLoginError($returnto)
 {
     $this->setupRequestParameters($returnto, FALSE, TRUE);
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($this->requestObject));
     if ($returnto) {
         $this->assertDestinationSetFromReturnTo();
     }
     $this->assertSuccessfulValidation($returnto);
     // Login should throw an exception.
     $this->casLogin->expects($this->once())->method('loginToDrupal')->will($this->throwException(new CasLoginException()));
     $this->assertRedirectedToFrontPageOnHandle();
 }
 /**
  * @covers ::access
  */
 public function testAccess()
 {
     $plugin_id = $this->randomMachineName();
     $request = new Request();
     $request->attributes->set('plugin_id', $plugin_id);
     $this->requestStack->expects($this->atLeastOnce())->method('getCurrentRequest')->willReturn($request);
     $access_controller = $this->getMock(EntityAccessControlHandlerInterface::class);
     $access_controller->expects($this->at(0))->method('createAccess')->with($plugin_id, $this->currentUser, [], TRUE)->willReturn(AccessResult::allowed());
     $access_controller->expects($this->at(1))->method('createAccess')->with($plugin_id, $this->currentUser, [], TRUE)->willReturn(AccessResult::forbidden());
     $this->entityManager->expects($this->exactly(2))->method('getAccessControlHandler')->with('payment_method_configuration')->willReturn($access_controller);
     $this->assertTrue($this->sut->access($request)->isAllowed());
     $this->assertFalse($this->sut->access($request)->isAllowed());
 }
コード例 #18
0
ファイル: DateTest.php プロジェクト: nsp15/Drupal8
 /**
  * Tests the formatTimeDiffSince method.
  *
  * @covers ::formatTimeDiffSince
  */
 public function testFormatTimeDiffSince()
 {
     $expected = '1 second';
     $timestamp = $this->createTimestamp('2013-12-11 10:09:07');
     $request_time = $this->createTimestamp('2013-12-11 10:09:08');
     $options = array();
     // Mocks the formatDiff function of the dateformatter object.
     $this->dateFormatterStub->expects($this->any())->method('formatDiff')->with($request_time, $timestamp, $options)->will($this->returnValue($expected));
     $request = Request::createFromGlobals();
     $request->server->set('REQUEST_TIME', $request_time);
     // Mocks a the request stack getting the current request.
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($request);
     $this->assertEquals($expected, $this->dateFormatterStub->formatTimeDiffUntil($timestamp, $options));
 }
コード例 #19
0
 /**
  * Tests the getWorkspaceSwitchLinks() method.
  */
 public function testGetWorkspaceSwitchLinks()
 {
     $path = '<front>';
     $request = Request::create($path);
     $query = array();
     $url = Url::fromRoute('<front>');
     $expected_links = array(1 => array('href' => $url, 'title' => null, 'query' => $query));
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
     $workspace_manager = new WorkspaceManager($this->requestStack, $this->entityManager, $this->cacheRender);
     $workspace_manager->addNegotiator($this->workspaceNegotiators[1][0], 1);
     $this->workspaceNegotiators[1][0]->expects($this->any())->method('applies')->with($request)->will($this->returnValue(TRUE));
     $this->workspaceNegotiators[1][0]->expects($this->once())->method('getWorkspaceSwitchLinks')->with($request, $url)->will($this->returnValue($expected_links));
     $result_links = $workspace_manager->getWorkspaceSwitchLinks($url);
     $this->assertSame($expected_links, $result_links);
 }
コード例 #20
0
ファイル: SorterRendererTest.php プロジェクト: blazarecki/lug
 public function testRenderWithPersistentSorted()
 {
     $column = $this->createColumnMock();
     $column->expects($this->once())->method('getName')->will($this->returnValue($name = 'name'));
     $view = $this->createGridViewMock();
     $view->expects($this->once())->method('getDefinition')->will($this->returnValue($grid = $this->createGridMock()));
     $grid->expects($this->once())->method('hasSort')->with($this->identicalTo($name))->will($this->returnValue(true));
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue($request = $this->createRequestMock()));
     $request->attributes->expects($this->once())->method('get')->with($this->identicalTo('_route_params'), $this->identicalTo([]))->will($this->returnValue($routeParams = ['route' => 'param']));
     $request->query->expects($this->once())->method('all')->will($this->returnValue($queryParams = ['query' => 'query']));
     $grid->expects($this->once())->method('hasOption')->with($this->identicalTo('persistent'))->will($this->returnValue(true));
     $grid->expects($this->once())->method('getOption')->with($this->identicalTo('persistent'))->will($this->returnValue(true));
     $this->filterManager->expects($this->once())->method('get')->with($this->identicalTo($grid))->will($this->returnValue(['sorting' => $name]));
     $this->assertNull($this->renderer->render($view, $column, SorterInterface::ASC));
 }
コード例 #21
0
ファイル: CasSubscriberTest.php プロジェクト: anarshi/recap
 /**
  * Test processing gateway with CHECK_ONCE to make sure SESSION gets set.
  *
  * @covers ::handle
  * @covers ::handleGateway
  */
 public function testHandleGatewayWithCheckOnceSuccess()
 {
     $config_factory = $this->getConfigFactoryStub(array('cas.settings' => array('forced_login.enabled' => TRUE, 'forced_login.paths' => array('<front>'), 'gateway.check_frequency' => CasHelper::CHECK_ONCE, 'gateway.paths' => array('<front>'))));
     $cas_subscriber = $this->getMockBuilder('\\Drupal\\cas\\Subscriber\\CasSubscriber')->setConstructorArgs(array($this->requestStack, $this->routeMatcher, $config_factory, $this->currentUser, $this->conditionManager, $this->casHelper))->setMethods(NULL)->getMock();
     $this->event->expects($this->any())->method('getRequestType')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST));
     $request_object = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $attributes = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
     $request_object->attributes = $attributes;
     $server = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ServerBag');
     $request_object->server = $server;
     $condition = $this->getMockBuilder('\\Drupal\\Core\\Condition\\ConditionPluginBase')->disableOriginalConstructor()->getMock();
     $this->conditionManager->expects($this->any())->method('createInstance')->with('request_path')->will($this->returnValue($condition));
     $condition->expects($this->any())->method('setConfiguration')->with(array('<front>'));
     $this->conditionManager->expects($this->any())->method('execute')->with($condition)->will($this->onConsecutiveCalls(FALSE, TRUE));
     $request_object->expects($this->once())->method('isMethod')->with('GET')->will($this->returnValue(TRUE));
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($request_object));
     $this->casHelper->expects($this->once())->method('getServerLoginUrl')->will($this->returnValue('https://example.com'));
     $this->event->expects($this->once())->method('setResponse');
     $cas_subscriber->handle($this->event);
     $this->assertArrayHasKey('cas_gateway_checked', $_SESSION);
 }
コード例 #22
0
 public function testGetData()
 {
     $request = new Request([], ['data' => ['url' => 'localhost/path']], [], [], [], ['SCRIPT_NAME' => 'localhost']);
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($request);
     $this->assertEquals(['url' => 'localhost/path', 'cleanUrl' => '/path'], $this->manager->getData());
 }
コード例 #23
0
 public function testResolveValidationGroupsExplicit()
 {
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue($request = $this->createRequestMock()));
     $request->attributes->expects($this->once())->method('get')->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo([]))->will($this->returnValue($groups = ['group']));
     $this->assertSame($groups, $this->parameterResolver->resolveValidationGroups());
 }
コード例 #24
0
 /**
  * @param bool $isFrontend
  */
 protected function assertIsFrontendRouteCall($isFrontend)
 {
     $request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->disableOriginalConstructor()->getMock();
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
     $this->helper->expects($this->once())->method('isFrontendRequest')->with($request)->will($this->returnValue($isFrontend));
 }
コード例 #25
0
 /**
  * @covers ::pay
  *
  * @dataProvider providerTestPay
  */
 public function testPay($has_completed, $is_xml_http_request)
 {
     $configuration = [];
     $plugin_id = $this->randomMachineName();
     $this->pluginDefinition = [];
     $this->sut = $this->getMockBuilder(PaymentReferenceBase::class)->setConstructorArgs(array($configuration, $plugin_id, $this->pluginDefinition, $this->requestStack, $this->paymentStorage, $this->stringTranslation, $this->dateFormatter, $this->linkGenerator, $this->renderer, $this->currentUser, $this->pluginSelectorManager, $this->paymentMethodType, new Random()))->setMethods(array('getEntityFormDisplay', 'getPluginSelector'))->getMockForAbstractClass();
     $payment_method = $this->getMock(PaymentMethodInterface::class);
     $url = new Url($this->randomMachineName());
     $result = $this->getMock(OperationResultInterface::class);
     $result->expects($this->atLeastOnce())->method('isCompleted')->willReturn($has_completed);
     $payment = $this->getMock(PaymentInterface::class);
     $payment->expects($this->atLeastOnce())->method('createDuplicate')->willReturnSelf();
     $payment->expects($this->atLeastOnce())->method('execute')->willReturn($result);
     $payment->expects($this->atLeastOnce())->method('setPaymentMethod')->with($payment_method);
     $payment->expects(!$has_completed && !$is_xml_http_request ? $this->atLeastOnce() : $this->never())->method('urlInfo')->with('complete')->willReturn($url);
     $form = array('foo' => array('bar' => array('#prototype_payment' => $payment, 'container' => array('#id' => $this->randomMachineName(), 'payment_form' => array('pay' => array('#array_parents' => array('foo', 'bar', 'container', 'payment_form', 'pay')), 'payment_method' => array('#foo' => $this->randomMachineName()))))));
     $form_state = new FormState();
     $form_state->setTriggeringElement($form['foo']['bar']['container']['payment_form']['pay']);
     $request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $request->expects($has_completed ? $this->never() : $this->atLeastOnce())->method('isXmlHttpRequest')->willReturn($is_xml_http_request);
     $this->requestStack->expects($has_completed ? $this->never() : $this->atLeastOnce())->method('getCurrentRequest')->willReturn($request);
     $plugin_selector = $this->getMock(PluginSelectorInterface::class);
     $plugin_selector->expects($this->atLeastOnce())->method('getSelectedPlugin')->willReturn($payment_method);
     $plugin_selector->expects($this->once())->method('submitSelectorForm')->with($form['foo']['bar']['container']['payment_form']['payment_method'], $form_state);
     $entity_form_display = $this->getMock(EntityFormDisplayInterface::class);
     $entity_form_display->expects($this->once())->method('extractFormValues')->with($payment, $form['foo']['bar']['container']['payment_form'], $form_state);
     $this->sut->expects($this->atLeastOnce())->method('getEntityFormDisplay')->willReturn($entity_form_display);
     $this->sut->expects($this->atLeastOnce())->method('getPluginSelector')->willReturn($plugin_selector);
     $this->sut->pay($form, $form_state);
     $this->assertTrue($form_state->isRebuilding());
 }
コード例 #26
0
ファイル: ParameterResolverTest.php プロジェクト: php-lug/lug
 public function testResolveVoterExplicit()
 {
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue($request = $this->createRequestMock()));
     $request->attributes->expects($this->once())->method('get')->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))->will($this->returnValue(true));
     $this->assertTrue($this->parameterResolver->resolveVoter());
 }
コード例 #27
0
ファイル: CookieStorageTest.php プロジェクト: blazarecki/lug
 public function testOffsetUnset()
 {
     $this->cookieBag->expects($this->once())->method('remove')->with($this->identicalTo($offset = 'foo'));
     unset($this->cookieStorage[$offset]);
 }