当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\Session::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::expects方法的具体用法?PHP Session::expects怎么用?PHP Session::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Session\Session的用法示例。


在下文中一共展示了Session::expects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDeleteUserId

 public function testDeleteUserId()
 {
     $this->session->expects($this->any())->method('get')->will($this->returnValueMap([[State::USER_KEY, null, 'bar']]));
     $this->state->saveUserId($this->state->getUserId());
     $this->assertEquals('bar', $this->storedValues[State::USER_KEY]);
     $this->state->deleteUserId();
     $this->assertNull($this->storedValues[State::USER_KEY]);
 }
开发者ID:alebear,项目名称:horses,代码行数:8,代码来源:StateTest.php

示例2: testOnPostSubmitWithInvalidForm

 public function testOnPostSubmitWithInvalidForm()
 {
     $event = $this->createFormEventMock();
     $event->expects($this->once())->method('getForm')->will($this->returnValue($form = $this->createFormMock()));
     $form->expects($this->once())->method('isValid')->will($this->returnValue(false));
     $this->session->expects($this->once())->method('getFlashBag')->will($this->returnValue($flashBag = $this->createFlashBagMock()));
     $this->translator->expects($this->once())->method('trans')->with($this->identicalTo('lug.resource.csrf.error'), $this->identicalTo([]), $this->identicalTo('flashes'))->will($this->returnValue($translation = 'translation'));
     $flashBag->expects($this->once())->method('add')->with($this->identicalTo('error'), $this->identicalTo($translation));
     $this->flashCsrfProtectionSubscriber->onPostSubmit($event);
 }
开发者ID:php-lug,项目名称:lug,代码行数:10,代码来源:FlashCsrfProtectionSubscriberTest.php

示例3: testInvalidatesOnInvalidUserAgent

 public function testInvalidatesOnInvalidUserAgent()
 {
     $logger = $this->getMockBuilder('Monolog\\Logger')->setConstructorArgs(array(''))->enableArgumentCloning()->getMock();
     // Change client agent
     $this->request->server->set('HTTP_USER_AGENT', 'TESTING');
     // Set session agent to something different
     $this->session->set('CLIENT_HTTP_USER_AGENT', 'SOME OTHER USER AGENT');
     $this->validator->setLogger($logger);
     // Invalidate
     $logger->expects($this->once())->method('debug');
     $this->session->expects($this->once())->method('invalidate');
     $this->validator->handleSessionValidation($this->session);
 }
开发者ID:digideskio,项目名称:concrete5,代码行数:13,代码来源:SessionValidatorTest.php

示例4: testSaveAndDuplicate

 public function testSaveAndDuplicate()
 {
     $entity = $this->getProductMock();
     $queryParameters = ['qwe' => 'rty'];
     $this->request->query = new ParameterBag($queryParameters);
     $this->request->expects($this->once())->method('getMethod')->will($this->returnValue('POST'));
     $this->request->expects($this->at(1))->method('get')->with($this->anything())->will($this->returnValue(false));
     $this->request->expects($this->at(2))->method('get')->with(Router::ACTION_PARAMETER)->will($this->returnValue(ProductUpdateHandler::ACTION_SAVE_AND_DUPLICATE));
     $this->doctrineHelper->expects($this->once())->method('getEntityManager')->with($entity)->will($this->returnValue($this->entityManager));
     $message = 'Saved';
     $savedAndDuplicatedMessage = 'Saved and duplicated';
     /** @var \PHPUnit_Framework_MockObject_MockObject|Form $form */
     $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $flashBag = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface')->getMock();
     $flashBag->expects($this->once())->method('add')->with('success', $message);
     $flashBag->expects($this->once())->method('set')->with('success', $savedAndDuplicatedMessage);
     $this->session->expects($this->any())->method('getFlashBag')->will($this->returnValue($flashBag));
     $saveAndStayRoute = ['route' => 'test_update'];
     $saveAndCloseRoute = ['route' => 'test_view'];
     $this->router->expects($this->once())->method('redirectAfterSave')->with(array_merge($saveAndStayRoute, ['parameters' => $queryParameters]), array_merge($saveAndCloseRoute, ['parameters' => $queryParameters]), $entity)->will($this->returnValue(new RedirectResponse('test_url')));
     $this->translator->expects($this->once())->method('trans')->with('orob2b.product.controller.product.saved_and_duplicated.message')->will($this->returnValue($savedAndDuplicatedMessage));
     $this->urlGenerator->expects($this->once())->method('generate')->with('orob2b_product_duplicate', ['id' => self::PRODUCT_ID])->will($this->returnValue('generated_redirect_url'));
     $result = $this->handler->handleUpdate($entity, $form, $saveAndStayRoute, $saveAndCloseRoute, $message);
     $this->assertEquals('generated_redirect_url', $result->headers->get('location'));
     $this->assertEquals(302, $result->getStatusCode());
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:27,代码来源:ProductUpdateHandlerTest.php

示例5: testHandleSaveNoWid

 public function testHandleSaveNoWid()
 {
     $queryParameters = ['qwe' => 'rty'];
     $this->request->query = new ParameterBag($queryParameters);
     $message = 'Saved';
     /** @var \PHPUnit_Framework_MockObject_MockObject|Form $form */
     $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $entity = $this->getObject();
     $handler = $this->getMockBuilder('Oro\\Bundle\\FormBundle\\Tests\\Unit\\Form\\Stub\\HandlerStub')->getMock();
     $handler->expects($this->once())->method('process')->with($entity)->will($this->returnValue(true));
     $flashBag = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface')->getMock();
     $flashBag->expects($this->once())->method('add')->with('success', $message);
     $this->session->expects($this->once())->method('getFlashBag')->will($this->returnValue($flashBag));
     $saveAndStayRoute = ['route' => 'test_update'];
     $saveAndCloseRoute = ['route' => 'test_view'];
     $expected = ['redirect' => true];
     $this->router->expects($this->once())->method('redirectAfterSave')->with(array_merge($saveAndStayRoute, ['parameters' => $queryParameters]), array_merge($saveAndCloseRoute, ['parameters' => $queryParameters]), $entity)->will($this->returnValue($expected));
     $result = $this->handler->handleUpdate($entity, $form, $saveAndStayRoute, $saveAndCloseRoute, $message, $handler);
     $this->assertEquals($expected, $result);
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:UpdateHandlerTest.php

示例6: testFlashWithApi

 public function testFlashWithApi()
 {
     $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true));
     $this->session->expects($this->never())->method('getFlashBag');
     $this->flashListener->addFlash($this->createDomainEventMock());
 }
开发者ID:blazarecki,项目名称:lug,代码行数:6,代码来源:FlashListenerTest.php


注:本文中的Symfony\Component\HttpFoundation\Session\Session::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。