本文整理汇总了PHP中TYPO3\Flow\Http\Request::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::create方法的具体用法?PHP Request::create怎么用?PHP Request::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Http\Request
的用法示例。
在下文中一共展示了Request::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @return void
*/
public function setUp()
{
$this->viewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
$this->viewHelperVariableContainer->expects($this->any())->method('exists')->will($this->returnCallback(array($this, 'viewHelperVariableContainerExistsCallback')));
$this->viewHelperVariableContainer->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'viewHelperVariableContainerGetCallback')));
$this->templateVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
$this->uriBuilder = $this->getMock('TYPO3\\Flow\\Mvc\\Routing\\UriBuilder');
$this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
$this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
// BACKPORTER TOKEN #1
$httpRequest = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('http://localhost/foo'));
$this->request = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array($httpRequest));
$this->request->expects($this->any())->method('isMainRequest')->will($this->returnValue(TRUE));
$this->controllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
$this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
$this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
$this->tagBuilder = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TagBuilder');
$this->arguments = array();
$this->renderingContext = new \TYPO3\Fluid\Core\Rendering\RenderingContext();
$this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
$this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
$this->renderingContext->setControllerContext($this->controllerContext);
}
示例2: requestMatchingBasicallyWorks
/**
* @dataProvider uriAndHostPatterns
* @test
*/
public function requestMatchingBasicallyWorks($uri, $pattern, $expected, $message)
{
$request = Request::create(new \TYPO3\Flow\Http\Uri($uri))->createActionRequest();
$requestPattern = new \TYPO3\Flow\Security\RequestPattern\Host();
$requestPattern->setPattern($pattern);
$this->assertEquals($expected, $requestPattern->matchRequest($request), $message);
}
示例3: dispatchContinuesWithNextRequestFoundInAForwardException
/**
* @test
*/
public function dispatchContinuesWithNextRequestFoundInAForwardException()
{
$httpRequest = Request::create(new Uri('http://localhost'));
$httpResponse = new Response();
$mainRequest = $httpRequest->createActionRequest();
$subRequest = new ActionRequest($mainRequest);
$nextRequest = $httpRequest->createActionRequest();
$mainRequest->setDispatched(TRUE);
$mainRequest->setControllerSubPackageKey('main');
$subRequest->setControllerSubPackageKey('sub');
$nextRequest->setControllerSubPackageKey('next');
$mockController = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerInterface', array('processRequest'));
$mockController->expects($this->at(0))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) {
$request->setDispatched(TRUE);
$forwardException = new ForwardException();
$forwardException->setNextRequest($nextRequest);
throw $forwardException;
}));
$mockController->expects($this->at(1))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) {
// NOTE: PhpUnit creates a clone of $nextRequest, thus $request is not the same instance as expected.
if ($request == $nextRequest) {
$nextRequest->setDispatched(TRUE);
}
}));
$dispatcher = $this->getMock('TYPO3\\Flow\\Mvc\\Dispatcher', array('resolveController', 'emitAfterControllerInvocation'), array(), '', FALSE);
$dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($mockController));
$dispatcher->dispatch($subRequest, $httpResponse);
}
示例4: updateCredentialsSetsTheCorrectAuthenticationStatusIfNoCredentialsArrived
/**
* @test
*/
public function updateCredentialsSetsTheCorrectAuthenticationStatusIfNoCredentialsArrived()
{
$httpRequest = Request::create(new Uri('http://foo.com'));
$mockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
$mockActionRequest->expects($this->atLeastOnce())->method('getHttpRequest')->will($this->returnValue($httpRequest));
$this->token->updateCredentials($mockActionRequest);
$this->assertSame(TokenInterface::NO_CREDENTIALS_GIVEN, $this->token->getAuthenticationStatus());
}
示例5: updateCredentialsSetsTheCorrectAuthenticationStatusIfNoCredentialsArrived
/**
* @test
*/
public function updateCredentialsSetsTheCorrectAuthenticationStatusIfNoCredentialsArrived()
{
$request = Request::create(new Uri('http://foo.com'));
$actionRequest = $request->createActionRequest();
$token = new UsernamePasswordHttpBasic();
$token->updateCredentials($actionRequest);
$this->assertSame(TokenInterface::NO_CREDENTIALS_GIVEN, $token->getAuthenticationStatus());
}
示例6: getMockControllerContext
/**
* Create a mock controllerContext
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getMockControllerContext()
{
$httpRequest = Request::create(new Uri('http://robertlemke.com/blog'));
$mockRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->setConstructorArgs(array($httpRequest))->getMock();
$mockRequest->expects($this->any())->method('getControllerPackageKey')->will($this->returnValue('Acme.Demo'));
$mockControllerContext = $this->getMockBuilder(\TYPO3\Flow\Mvc\Controller\ControllerContext::class)->setMethods(array('getRequest'))->disableOriginalConstructor()->getMock();
$mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
return $mockControllerContext;
}
示例7: requestMatchingBasicallyWorks
/**
* @test
*/
public function requestMatchingBasicallyWorks()
{
$uri = new \TYPO3\Flow\Http\Uri('http://typo3.org/some/nice/path/to/index.php');
$request = Request::create($uri)->createActionRequest();
$requestPattern = new \TYPO3\Flow\Security\RequestPattern\Uri();
$requestPattern->setPattern('/some/nice/.*');
$this->assertEquals('/some/nice/.*', $requestPattern->getPattern());
$this->assertTrue($requestPattern->matchRequest($request));
}
示例8: getMockControllerContext
/**
* Create a mock controllerContext
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getMockControllerContext()
{
$httpRequest = Request::create(new Uri('http://robertlemke.com/blog'));
$mockRequest = $this->getMock(\TYPO3\Flow\Mvc\ActionRequest::class, array(), array($httpRequest));
$mockRequest->expects($this->any())->method('getControllerPackageKey')->will($this->returnValue('Acme.Demo'));
$mockControllerContext = $this->getMock(\TYPO3\Flow\Mvc\Controller\ControllerContext::class, array('getRequest'), array(), '', false);
$mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
return $mockControllerContext;
}
示例9: getMockControllerContext
/**
* Create a mock controllerContext
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getMockControllerContext()
{
$httpRequest = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('http://robertlemke.com/blog'));
$mockRequest = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array($httpRequest));
$mockRequest->expects($this->any())->method('getControllerPackageKey')->will($this->returnValue('TYPO3.Fluid'));
$mockControllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array('getRequest'), array(), '', FALSE);
$mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest));
return $mockControllerContext;
}
示例10: createRegistrationRequest
/**
* @param string $payload
* @param string $uri
* @return Request
*/
protected function createRegistrationRequest($payload, $uri = self::ENDPOINT)
{
$request = Request::create(new Uri($uri));
$request->setMethod('POST');
$request->setHeader('Content-Type', 'application/json');
$request->setHeader('Accept', 'application/json');
$request->setContent($payload);
return $request;
}
示例11: renderEscapesBaseUri
/**
* @test
*/
public function renderEscapesBaseUri()
{
$baseUri = new Uri('<some nasty uri>');
$this->request->expects($this->any())->method('getHttpRequest')->will($this->returnValue(Request::create($baseUri)));
$viewHelper = new BaseViewHelper();
$this->injectDependenciesIntoViewHelper($viewHelper);
$expectedResult = '<base href="http://' . htmlspecialchars($baseUri) . '/" />';
$actualResult = $viewHelper->render();
$this->assertSame($expectedResult, $actualResult);
}
示例12: renderTakesBaseUriFromControllerContext
/**
* @test
*/
public function renderTakesBaseUriFromControllerContext()
{
$baseUri = new \TYPO3\Flow\Http\Uri('http://typo3.org/');
$this->request->expects($this->any())->method('getHttpRequest')->will($this->returnValue(\TYPO3\Flow\Http\Request::create($baseUri)));
$viewHelper = new \TYPO3\Fluid\ViewHelpers\BaseViewHelper();
$this->injectDependenciesIntoViewHelper($viewHelper);
$expectedResult = '<base href="' . $baseUri . '" />';
$actualResult = $viewHelper->render();
$this->assertSame($expectedResult, $actualResult);
}
示例13: templateIsEvaluatedCorrectly
/**
* @test
* @dataProvider exampleTemplates
*/
public function templateIsEvaluatedCorrectly($source, $variables, $expected)
{
$request = Request::create(new Uri('http://localhost'));
$actionRequest = $request->createActionRequest();
$standaloneView = new \TYPO3\Fluid\Tests\Functional\View\Fixtures\View\StandaloneView($actionRequest, uniqid());
$standaloneView->assignMultiple($variables);
$standaloneView->setTemplateSource($source);
$actual = $standaloneView->render();
$this->assertSame($expected, $actual);
}
示例14: actionRequestDoesNotStripParentActionRequest
/**
* @test
*/
public function actionRequestDoesNotStripParentActionRequest()
{
$httpRequest = Request::create(new Uri('http://typo3.org'));
$parentActionRequest = new ActionRequest($httpRequest);
$actionRequest = new ActionRequest($parentActionRequest);
$serializedActionRequest = serialize($actionRequest);
/* @var $unserializedActionRequest ActionRequest */
$unserializedActionRequest = unserialize($serializedActionRequest);
$this->assertNotNull($unserializedActionRequest->getParentRequest(), 'Parent action request should not be NULL after deserialization');
}
示例15: query
/**
* @param string $resource
* @param string $method
* @return \TYPO3\Flow\Http\Response
*/
public function query($resource, $method = 'GET')
{
$uri = new Uri($this->endpoint . $resource);
parse_str((string) $uri->getQuery(), $query);
$query['access_token'] = $this->currentAccessToken;
$query['appsecret_proof'] = hash_hmac('sha256', $this->currentAccessToken, $this->appSecret);
$uri->setQuery(http_build_query($query));
$request = Request::create($uri, $method);
$response = $this->requestEngine->sendRequest($request);
return $response;
}