9 use \Magento\Setup\Controller\Marketplace;
16 private $packagesAuth;
21 private $packagesData;
32 $this->packagesAuth = $this->createMock(\
Magento\Setup\Model\PackagesAuth::class);
33 $this->packagesData = $this->createMock(\
Magento\Setup\Model\PackagesData::class);
34 $this->controller =
new Marketplace($this->packagesAuth, $this->packagesData);
40 ->expects($this->once())
41 ->method(
'checkCredentials')
42 ->will($this->returnValue(json_encode([
'success' =>
true])));
44 ->expects($this->once())
45 ->method(
'saveAuthJson')
47 $jsonModel = $this->controller->saveAuthJsonAction();
48 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class, $jsonModel);
49 $variables = $jsonModel->getVariables();
50 $this->assertArrayHasKey(
'success', $variables);
51 $this->assertTrue($variables[
'success']);
57 ->expects($this->once())
58 ->method(
'checkCredentials')
59 ->will($this->throwException(
new \
Exception));
60 $this->packagesAuth->expects($this->never())->method(
'saveAuthJson');
61 $jsonModel = $this->controller->saveAuthJsonAction();
62 $this->assertInstanceOf(\
Zend\View\Model\JsonModel::class, $jsonModel);
63 $variables = $jsonModel->getVariables();
64 $this->assertArrayHasKey(
'success', $variables);
65 $this->assertArrayHasKey(
'message', $variables);
66 $this->assertFalse($variables[
'success']);
72 ->expects($this->once())
73 ->method(
'getAuthJsonData')
74 ->will($this->returnValue([
'username' =>
'test',
'password' =>
'test']));
76 ->expects($this->once())
77 ->method(
'checkCredentials')
78 ->will($this->returnValue(json_encode([
'success' =>
true])));
79 $jsonModel = $this->controller->checkAuthAction();
80 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class, $jsonModel);
81 $variables = $jsonModel->getVariables();
82 $this->assertArrayHasKey(
'success', $variables);
83 $this->assertTrue($variables[
'success']);
89 ->expects($this->once())
90 ->method(
'getAuthJsonData')
91 ->will($this->throwException(
new \
Exception));
92 $jsonModel = $this->controller->checkAuthAction();
93 $this->assertInstanceOf(\
Zend\View\Model\JsonModel::class, $jsonModel);
94 $variables = $jsonModel->getVariables();
95 $this->assertArrayHasKey(
'success', $variables);
96 $this->assertArrayHasKey(
'message', $variables);
97 $this->assertFalse($variables[
'success']);
103 ->expects($this->once())
104 ->method(
'removeCredentials')
105 ->will($this->returnValue(
true));
107 $jsonModel = $this->controller->removeCredentialsAction();
108 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class, $jsonModel);
109 $variables = $jsonModel->getVariables();
110 $this->assertArrayHasKey(
'success', $variables);
111 $this->assertTrue($variables[
'success']);
117 ->expects($this->once())
118 ->method(
'removeCredentials')
119 ->will($this->throwException(
new \
Exception));
120 $jsonModel = $this->controller->removeCredentialsAction();
121 $this->assertInstanceOf(\
Zend\View\Model\JsonModel::class, $jsonModel);
122 $variables = $jsonModel->getVariables();
123 $this->assertArrayHasKey(
'success', $variables);
124 $this->assertArrayHasKey(
'message', $variables);
125 $this->assertFalse($variables[
'success']);
130 $viewModel = $this->controller->popupAuthAction();
131 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class,
$viewModel);
137 $model = $this->controller->indexAction();
138 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class,
$model);
testCheckAuthActionWithError()
testSaveAuthJsonActionWithError()
testRemoveCredentialsWithError()
testRemoveCredentialsAction()