Skip to content

Commit 0df70ba

Browse files
author
Kopylova,Olga(okopylova)
committed
Merge pull request #420 from magento-ogre/PR_Branch
[Ogre's] Bug fixes and Increased code coverage
2 parents 8b5026a + 240f7ad commit 0df70ba

17 files changed

+1908
-82
lines changed

setup/pub/magento/setup/readiness-check.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,40 @@ angular.module('readiness-check', [])
2323
$rootScope.checkingInProgress = function() {
2424
return $scope.progressCounter > 0;
2525
};
26+
$scope.requestFailedHandler = function(obj) {
27+
obj.processed = true;
28+
obj.isRequestError = true;
29+
$scope.hasErrors = true;
30+
$rootScope.hasErrors = true;
31+
$scope.stopProgress();
32+
};
2633

2734
$scope.completed = false;
2835
$scope.hasErrors = false;
2936

3037
$scope.version = {
3138
visible: false,
3239
processed: false,
33-
expanded: false
40+
expanded: false,
41+
isRequestError: false
3442
};
3543
$scope.settings = {
3644
visible: false,
3745
processed: false,
38-
expanded: false
46+
expanded: false,
47+
isRequestError: false
3948
};
4049
$scope.extensions = {
4150
visible: false,
4251
processed: false,
43-
expanded: false
52+
expanded: false,
53+
isRequestError: false
4454
};
4555
$scope.permissions = {
4656
visible: false,
4757
processed: false,
48-
expanded: false
58+
expanded: false,
59+
isRequestError: false
4960
};
5061

5162
$scope.items = {
@@ -60,6 +71,9 @@ angular.module('readiness-check', [])
6071
angular.extend($scope.version, data);
6172
$scope.updateOnProcessed($scope.version.responseType);
6273
$scope.stopProgress();
74+
},
75+
fail: function() {
76+
$scope.requestFailedHandler($scope.version);
6377
}
6478
},
6579
'php-settings': {
@@ -73,6 +87,9 @@ angular.module('readiness-check', [])
7387
angular.extend($scope.settings, data);
7488
$scope.updateOnProcessed($scope.settings.responseType);
7589
$scope.stopProgress();
90+
},
91+
fail: function() {
92+
$scope.requestFailedHandler($scope.settings);
7693
}
7794
},
7895
'php-extensions': {
@@ -86,6 +103,9 @@ angular.module('readiness-check', [])
86103
angular.extend($scope.extensions, data);
87104
$scope.updateOnProcessed($scope.extensions.responseType);
88105
$scope.stopProgress();
106+
},
107+
fail: function() {
108+
$scope.requestFailedHandler($scope.extensions);
89109
}
90110
},
91111
'file-permissions': {
@@ -99,12 +119,16 @@ angular.module('readiness-check', [])
99119
angular.extend($scope.permissions, data);
100120
$scope.updateOnProcessed($scope.permissions.responseType);
101121
$scope.stopProgress();
122+
},
123+
fail: function() {
124+
$scope.requestFailedHandler($scope.permissions);
102125
}
103126
}
104127
};
105128

106129
$scope.isCompleted = function() {
107130
return $scope.version.processed
131+
&& $scope.settings.processed
108132
&& $scope.extensions.processed
109133
&& $scope.permissions.processed;
110134
};
@@ -133,8 +157,11 @@ angular.module('readiness-check', [])
133157
};
134158

135159
$scope.query = function(item) {
136-
return $http.get(item.url)
137-
.success(function(data) { item.process(data) });
160+
return $http.get(item.url, {timeout: 3000})
161+
.success(function(data) { item.process(data) })
162+
.error(function(data, status) {
163+
item.fail();
164+
});
138165
};
139166

140167
$scope.progress = function() {

setup/src/Magento/Setup/Console/Command/InstallStoreConfigurationCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ public function validate(InputInterface $input)
178178
switch ($key) {
179179
case StoreConfigurationDataMapper::KEY_BASE_URL:
180180
/** @var Validator $url */
181+
if (strcmp($value, '{{base_url}}') == 0) {
182+
break;
183+
}
181184
$url = $this->objectManager->get('Magento\Framework\Url\Validator');
182185
if (!$url->isValid($value)) {
183186
$errorMsgs = $url->getMessages();

setup/src/Magento/Setup/Fixtures/FixtureModel.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ public function reindex(OutputInterface $output)
105105
*/
106106
public function loadFixtures()
107107
{
108-
if (!is_readable(__DIR__)) {
109-
throw new \Exception(
110-
'Fixtures set directory `' . __DIR__ . '` is not readable or does not exists.'
111-
);
112-
}
113108
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN);
114109

115110
foreach ($files as $file) {
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Setup\Test\Unit\Fixtures;
8+
9+
use \Magento\Setup\Fixtures\CartPriceRulesFixture;
10+
11+
class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel
15+
*/
16+
private $fixtureModelMock;
17+
18+
/**
19+
* @var \Magento\Setup\Fixtures\CartPriceRulesFixture
20+
*/
21+
private $model;
22+
23+
public function setUp()
24+
{
25+
$this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false);
26+
27+
$this->model = new CartPriceRulesFixture($this->fixtureModelMock);
28+
}
29+
30+
public function testExecute()
31+
{
32+
$storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false);
33+
$storeMock->expects($this->once())
34+
->method('getRootCategoryId')
35+
->will($this->returnValue(2));
36+
37+
$websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false);
38+
$websiteMock->expects($this->once())
39+
->method('getGroups')
40+
->will($this->returnValue([$storeMock]));
41+
$websiteMock->expects($this->once())
42+
->method('getId')
43+
->will($this->returnValue('website_id'));
44+
45+
$contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
46+
$abstractDbMock = $this->getMockForAbstractClass(
47+
'\Magento\Framework\Model\Resource\Db\AbstractDb',
48+
[$contextMock],
49+
'',
50+
true,
51+
true,
52+
true,
53+
['getAllChildren']
54+
);
55+
$abstractDbMock->expects($this->once())
56+
->method('getAllChildren')
57+
->will($this->returnValue([1]));
58+
59+
$storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false);
60+
$storeManagerMock->expects($this->once())
61+
->method('getWebsites')
62+
->will($this->returnValue([$websiteMock]));
63+
64+
$categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false);
65+
$categoryMock->expects($this->once())
66+
->method('getResource')
67+
->will($this->returnValue($abstractDbMock));
68+
$categoryMock->expects($this->once())
69+
->method('getPath')
70+
->will($this->returnValue('path/to/file'));
71+
$categoryMock->expects($this->once())
72+
->method('getId')
73+
->will($this->returnValue('category_id'));
74+
75+
$modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false);
76+
$modelMock->expects($this->once())
77+
->method('getIdFieldName')
78+
->will($this->returnValue('Field Id Name'));
79+
80+
$objectValueMap = [
81+
['Magento\SalesRule\Model\Rule', $modelMock],
82+
['Magento\Catalog\Model\Category', $categoryMock]
83+
];
84+
85+
$objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false);
86+
$objectManagerMock->expects($this->once())
87+
->method('create')
88+
->will($this->returnValue($storeManagerMock));
89+
$objectManagerMock->expects($this->exactly(2))
90+
->method('get')
91+
->will($this->returnValueMap($objectValueMap));
92+
93+
$valueMap = [
94+
['cart_price_rules', 0, 1],
95+
['cart_price_rules_floor', 3, 3]
96+
];
97+
98+
$this->fixtureModelMock
99+
->expects($this->exactly(2))
100+
->method('getValue')
101+
->will($this->returnValueMap($valueMap));
102+
$this->fixtureModelMock
103+
->expects($this->exactly(3))
104+
->method('getObjectManager')
105+
->will($this->returnValue($objectManagerMock));
106+
107+
$this->model->execute();
108+
}
109+
110+
public function testNoFixtureConfigValue()
111+
{
112+
$ruleMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false);
113+
$ruleMock->expects($this->never())->method('save');
114+
115+
$objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false);
116+
$objectManagerMock->expects($this->never())
117+
->method('get')
118+
->with($this->equalTo('Magento\SalesRule\Model\Rule'))
119+
->willReturn($ruleMock);
120+
121+
$this->fixtureModelMock
122+
->expects($this->never())
123+
->method('getObjectManager')
124+
->willReturn($objectManagerMock);
125+
$this->fixtureModelMock
126+
->expects($this->once())
127+
->method('getValue')
128+
->willReturn(false);
129+
130+
$this->model->execute();
131+
}
132+
133+
public function testGetActionTitle()
134+
{
135+
$this->assertSame('Generating Cart Price Rules', $this->model->getActionTitle());
136+
}
137+
138+
public function testIntroduceParamLabels()
139+
{
140+
$this->assertSame([
141+
'cart_price_rules' => 'Cart Price Rules'
142+
], $this->model->introduceParamLabels());
143+
}
144+
}

0 commit comments

Comments
 (0)