/** * @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")); }
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(); }
/** * @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); }
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(); }
/** * @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); }
public function testGetBasePath() { $this->request->expects($this->once())->method('getBasePath')->willReturn('/'); $this->assertEquals('/', $this->zendRequestContext->getBasePath()); }