本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::expects方法的具体用法?PHP Request::expects怎么用?PHP Request::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetPathWithBasePathThatDoesNotMatch
public function testGetPathWithBasePathThatDoesNotMatch()
{
$this->request->expects($this->once())->method('getRequestUri')->will($this->returnValue('/bar'));
$extractorFactory = new ExtractorFactory('/foo');
$extractor = $extractorFactory->createPathExtractor();
$this->assertSame('', $extractor($this->request));
}
示例2: testInvalidLocaleFound
/**
* @covers Kunstmaan\LanguageChooserBundle\LocaleGuesser\UrlLocaleGuesser::guessLocale
*/
public function testInvalidLocaleFound()
{
$this->metaValidator->expects($this->once())->method('isAllowed')->will($this->returnValue(false));
$this->request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/en/another-path'));
$this->assertFalse($this->object->guessLocale($this->request));
$this->assertEquals(null, $this->object->getIdentifiedLocale());
}
示例3: testGetIncludeSubcategoriesChoice
/**
* @dataProvider getIncludeSubcategoriesChoiceDataProvider
*
* @param $value
* @param $expected
*/
public function testGetIncludeSubcategoriesChoice($value, $expected)
{
$this->requestProductHandler->setRequest($this->request);
$this->request->expects($this->once())->method('get')->with(RequestProductHandler::INCLUDE_SUBCATEGORIES_KEY)->willReturn($value);
$actual = $this->requestProductHandler->getIncludeSubcategoriesChoice();
$this->assertEquals($expected, $actual);
}
示例4: setUp
/**
* {@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->placesAutocompleteType = new PlacesAutocompleteType($this->placesAutocompleteHelperMock, $this->requestMock);
$this->factory = Forms::createFormFactoryBuilder()->addType($this->placesAutocompleteType)->getFormFactory();
}
示例5: testPageException
public function testPageException()
{
$this->request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/fail'));
$this->twig->expects($this->at(0))->method('render')->with('page/fail.html.twig')->will($this->throwException(new Twig_Error_Loader('Unable to find template')));
$this->twig->expects($this->at(1))->method('render')->with('error/404.html.twig');
$result = $this->controller->page($this->request);
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $result);
$this->assertSame(404, $result->getStatusCode());
}
示例6: testIsActivePath
/**
* Test isActivePath method
*/
public function testIsActivePath()
{
$this->request->expects($this->any())->method('getRequestUri')->will($this->returnValue('some/request/uri'));
$this->container->expects($this->any())->method('get')->with($this->equalTo('request'))->will($this->returnValue($this->request));
$this->extension->setActivePaths(array('some/specific/path'));
$this->assertEquals(array('some/specific/path'), $this->extension->getActivePaths(), 'setActivePaths: Should return an array with "some/specific/path"');
$this->assertTrue($this->extension->isActivePath('some/specific/path'), 'isActivePath: Should return true');
$this->assertTrue($this->extension->isActivePath('some/request/uri'), 'isActivePath: Should return false');
}
示例7: testProcess
public function testProcess()
{
$this->form->expects($this->once())->method('setData')->with($this->entity);
$this->request->expects($this->once())->method('getMethod')->will($this->returnValue('POST'));
$this->form->expects($this->once())->method('submit');
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
$this->manager->expects($this->once())->method('persist')->with($this->entity);
$this->manager->expects($this->once())->method('flush');
$this->assertTrue($this->handler->process($this->entity));
}
示例8: testOnBuildKernelHandler
/**
* @dataProvider buildKernelProvider
*/
public function testOnBuildKernelHandler($sessionName, $isStarted, $storageKey, $hasPreviousSession)
{
$this->session->expects($this->once())->method('getName')->will($this->returnValue($sessionName));
$this->session->expects($this->once())->method('isStarted')->will($this->returnValue($isStarted));
$this->request->expects($this->once())->method('hasPreviousSession')->will($this->returnValue($hasPreviousSession));
$sessionMapper = new SessionMapper($this->sessionStorage, $storageKey, $this->session);
$sessionMapper->setRequest($this->request);
$event = new PreBuildKernelEvent(new ParameterBag(), $this->request);
$sessionMapper->onBuildKernelHandler($event);
$this->assertSame(array('session' => array('configured' => true, 'started' => $isStarted, 'name' => $sessionName, 'namespace' => $storageKey, 'has_previous' => $hasPreviousSession, 'storage' => $this->sessionStorage), 'injected-settings' => array('site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false)), $event->getParameters()->all());
}
示例9: testProcessExistingShoppingList
public function testProcessExistingShoppingList()
{
$this->shoppingList->expects($this->once())->method('getId')->willReturn(1);
$this->request->expects($this->once())->method('getMethod')->will($this->returnValue('PUT'));
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
/** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $manager */
$manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
$manager->expects($this->once())->method('persist');
$manager->expects($this->once())->method('flush');
$this->registry->expects($this->once())->method('getManagerForClass')->with(self::SHOPPING_LIST_SHORTCUT)->will($this->returnValue($manager));
$handler = new ShoppingListHandler($this->form, $this->request, $this->manager, $this->registry);
$this->assertTrue($handler->process($this->shoppingList));
}
示例10: getRequestMock
/**
* @return PHPUnit_Framework_MockObject_MockObject|Request
*/
protected function getRequestMock()
{
if (!isset($this->requestMock)) {
$this->requestMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
$this->requestMock->attributes = $this->getRequestAttributesMock();
$this->requestMock->headers = $this->getRequestHeadersMock();
if ($this->requestMethod === false) {
$this->requestMock->expects($this->never())->method('getMethod');
} else {
$this->requestMock->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue($this->requestMethod));
}
}
return $this->requestMock;
}
示例11: testGetAccount
/**
* @dataProvider getAccountDataProvider
*
* @param string $method
* @param string $class
* @param string $param
*/
public function testGetAccount($method, $class, $param)
{
$entity = $this->getEntity($class, 42);
$this->request->expects($this->once())->method('get')->with(OrderType::NAME)->willReturn([$param => $entity->getId()]);
$this->objectManager->expects($this->once())->method('find')->with($class, $entity->getId())->willReturn($entity);
$this->assertSame($entity, $this->handler->{$method}());
}
示例12: assertSaveData
/**
* @param \PHPUnit_Framework_MockObject_MockObject|Form $form
* @param object $entity
* @param string $wid
* @return array
*/
protected function assertSaveData($form, $entity, $wid = 'WID')
{
$this->request->expects($this->atLeastOnce())->method('get')->with('_wid', false)->will($this->returnValue($wid));
$formView = $this->getMockBuilder('Symfony\\Component\\Form\\FormView')->disableOriginalConstructor()->getMock();
$form->expects($this->any())->method('createView')->will($this->returnValue($formView));
return ['entity' => $entity, 'form' => $formView, 'isWidgetContext' => true];
}
示例13: testGetShowTierPricesWithRequestAndSaveState
public function testGetShowTierPricesWithRequestAndSaveState()
{
$this->handler->setRequest($this->request);
$this->request->expects($this->exactly(3))->method('get')->willReturnMap([[FrontendPriceListRequestHandler::TIER_PRICES_KEY, null, false, '1'], [FrontendPriceListRequestHandler::SAVE_STATE_KEY, null, false, true]]);
$this->session->expects($this->once())->method('set')->with(FrontendPriceListRequestHandler::TIER_PRICES_KEY, true);
$this->assertEquals(true, $this->handler->getShowTierPrices());
}
示例14: testVisitDatasource
public function testVisitDatasource()
{
/** @var \PHPUnit_Framework_MockObject_MockObject|DatagridConfiguration $config */
$config = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration')->disableOriginalConstructor()->getMock();
$config->expects($this->any())->method('getName')->will($this->returnValue(AccountUserByAccountExtension::SUPPORTED_GRID));
$this->request->expects($this->any())->method('get')->with(AccountUserByAccountExtension::ACCOUNT_KEY)->will($this->returnValue(1));
$expr = $this->getMockBuilder('Doctrine\\ORM\\Query\\Expr')->disableOriginalConstructor()->getMock();
$qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
$qb->expects($this->once())->method('andWhere')->will($this->returnSelf());
$qb->expects($this->once())->method('setParameter')->with('account', 1)->will($this->returnSelf());
$qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['au']));
$qb->expects($this->once())->method('expr')->will($this->returnValue($expr));
/** @var \PHPUnit_Framework_MockObject_MockObject|OrmDatasource $datasource */
$datasource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock();
$datasource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb));
$this->extension->visitDatasource($config, $datasource);
}
示例15: testConfirmException
public function testConfirmException()
{
$this->request->expects($this->once())->method('get')->with('token')->willReturn('awesome-token');
$this->filesystem->expects($this->once())->method('exists')->with(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'awesome-token' . '.txt')->willReturn(true);
$this->mollieAPIClient->payments = $this->payments;
$this->payments->expects($this->once())->method('get')->with('test')->willThrowException(new Mollie_API_Exception());
$this->assertFalse($this->mollieDriver->confirm($this->request));
}