本文整理汇总了PHP中Zend\Http\PhpEnvironment\Request::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::expects方法的具体用法?PHP Request::expects怎么用?PHP Request::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\PhpEnvironment\Request
的用法示例。
在下文中一共展示了Request::expects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasUninstallAction
/**
* @param string $content
* @param array $expected
* @param bool $result
* @dataProvider hasUninstallActionDataProvider
*/
public function testHasUninstallAction($content, $expected, $result)
{
$this->request->expects($this->any())->method('getContent')->willReturn($content);
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->uninstallCollector->expects($this->once())->method('collectUninstall')->with(["some_module"])->willReturn($expected);
$this->assertSame($result, $this->controller->hasUninstallAction()->getVariable("hasUninstall"));
}
示例2: testUpdateActionSuccess
public function testUpdateActionSuccess()
{
$content = '{"packages":[{"name":"vendor\\/package","version":"1.0"}],"type":"update",' . '"headerTitle": "Update package 1" }';
$this->request->expects($this->any())->method('getContent')->willReturn($content);
$this->payloadValidator->expects($this->once())->method('validatePayload')->willReturn('');
$this->updaterTaskCreator->expects($this->once())->method('createUpdaterTasks')->willReturn('');
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
}
示例3: testOnDispatchErrorStripBaseUrl
/**
* @covers ::onDispatchError
*/
public function testOnDispatchErrorStripBaseUrl()
{
$baseUrl = '/base';
$path = '/some/uri';
$uri = $baseUrl . $path;
$this->event->setError(Application::ERROR_ROUTER_NO_MATCH);
$this->request->expects($this->once())->method('getRequestUri')->willReturn($uri);
$this->request->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl);
$this->manager->expects($this->once())->method('matchUri')->with($this->equalTo($path));
$this->listener->onDispatchError($this->event);
}
示例4: testUpdateActionSuccessDisable
public function testUpdateActionSuccessDisable()
{
$content = '{"packages":[{"name":"vendor\\/package"}],"type":"disable",' . '"headerTitle": "Disable Package 1" }';
$this->request->expects($this->any())->method('getContent')->willReturn($content);
$this->fullModuleList->expects($this->once())->method('has')->willReturn(true);
$write = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], '', false);
$this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
$write->expects($this->once())->method('writeFile')->with('.type.json', '{"type":"disable","headerTitle":"Disable Package 1","titles":["D"]}');
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
}
示例5: testGetRedirectRouteFromRequest
/**
* @dataProvider providerGetRedirectRouteFromRequest
*/
public function testGetRedirectRouteFromRequest($get, $post, $getRouteExists, $postRouteExists)
{
$expectedResult = false;
$this->request->expects($this->once())->method('getQuery')->will($this->returnValue($get));
if ($get) {
$this->router->expects($this->any())->method('assemble')->with(array(), array('name' => $get))->will($getRouteExists);
if ($getRouteExists == $this->returnValue(true)) {
$expectedResult = $get;
}
}
if (!$get || !$getRouteExists) {
$this->request->expects($this->once())->method('getPost')->will($this->returnValue($post));
if ($post) {
$this->router->expects($this->any())->method('assemble')->with(array(), array('name' => $post))->will($postRouteExists);
if ($postRouteExists == $this->returnValue(true)) {
$expectedResult = $post;
}
}
}
$method = new \ReflectionMethod('ZfcUser\\Controller\\RedirectCallback', 'getRedirectRouteFromRequest');
$method->setAccessible(true);
$result = $method->invoke($this->redirectCallback);
$this->assertSame($expectedResult, $result);
}
示例6: testGetBasePath
public function testGetBasePath()
{
$this->request->expects($this->once())->method('getBasePath')->willReturn('/');
$this->assertEquals('/', $this->zendRequestContext->getBasePath());
}