16 private $uninstallCollector;
40 $this->request = $this->createMock(\
Zend\Http\PhpEnvironment\Request::class);
41 $this->response = $this->createMock(\
Zend\Http\PhpEnvironment\Response::class);
42 $routeMatch = $this->createMock(\
Zend\Mvc\Router\RouteMatch::class);
44 $this->uninstallCollector = $this->createMock(\
Magento\Setup\Model\UninstallCollector::class);
45 $this->controller =
new DataOption($this->uninstallCollector);
47 $this->mvcEvent = $this->createMock(\
Zend\Mvc\MvcEvent::class);
48 $this->mvcEvent->expects($this->any())
49 ->method(
'setRequest')
50 ->with($this->request)
51 ->willReturn($this->mvcEvent);
52 $this->mvcEvent->expects($this->any())
53 ->method(
'setResponse')
54 ->with($this->response)
55 ->willReturn($this->mvcEvent);
56 $this->mvcEvent->expects($this->any())
58 ->with($this->controller)
59 ->willReturn($this->mvcEvent);
60 $this->mvcEvent->expects($this->any())->method(
'getRouteMatch')->willReturn($routeMatch);
66 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class,
$viewModel);
72 $this->request->expects($this->any())->method(
'getContent')->willReturn(
'{}');
73 $this->controller->setEvent($this->mvcEvent);
74 $this->controller->dispatch($this->request, $this->response);
75 $this->uninstallCollector->expects($this->never())->method(
'collectUninstall')->with([
"some_module"]);
76 $this->assertFalse($this->controller->hasUninstallAction()->getVariable(
"hasUninstall"));
87 $this->request->expects($this->any())->method(
'getContent')->willReturn(
$content);
88 $this->controller->setEvent($this->mvcEvent);
89 $this->controller->dispatch($this->request, $this->response);
91 $this->uninstallCollector
92 ->expects($this->once())
93 ->method(
'collectUninstall')
94 ->with([
"some_module"])
95 ->willReturn($expected);
97 $this->assertSame(
$result, $this->controller->hasUninstallAction()->getVariable(
"hasUninstall"));
105 $content =
'{"moduleName": "some_module"}';
107 'module has uninstall class' => [
$content, [
'module'],
true],
108 'module does not have uninstall class' => [
$content, [],
false],
hasUninstallActionDataProvider()
testHasUninstallAction($content, $expected, $result)
testNoHasUninstallAction()