Skip to content

Commit

Permalink
Merge pull request #420 from magento-ogre/PR_Branch
Browse files Browse the repository at this point in the history
[Ogre's] Bug fixes and Increased code coverage
  • Loading branch information
Kopylova,Olga(okopylova) committed Jul 6, 2015
2 parents 8b5026a + 240f7ad commit 0df70ba
Show file tree
Hide file tree
Showing 17 changed files with 1,908 additions and 82 deletions.
39 changes: 33 additions & 6 deletions setup/pub/magento/setup/readiness-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,40 @@ angular.module('readiness-check', [])
$rootScope.checkingInProgress = function() {
return $scope.progressCounter > 0;
};
$scope.requestFailedHandler = function(obj) {
obj.processed = true;
obj.isRequestError = true;
$scope.hasErrors = true;
$rootScope.hasErrors = true;
$scope.stopProgress();
};

$scope.completed = false;
$scope.hasErrors = false;

$scope.version = {
visible: false,
processed: false,
expanded: false
expanded: false,
isRequestError: false
};
$scope.settings = {
visible: false,
processed: false,
expanded: false
expanded: false,
isRequestError: false
};
$scope.extensions = {
visible: false,
processed: false,
expanded: false
expanded: false,
isRequestError: false
};
$scope.permissions = {
visible: false,
processed: false,
expanded: false
expanded: false,
isRequestError: false
};

$scope.items = {
Expand All @@ -60,6 +71,9 @@ angular.module('readiness-check', [])
angular.extend($scope.version, data);
$scope.updateOnProcessed($scope.version.responseType);
$scope.stopProgress();
},
fail: function() {
$scope.requestFailedHandler($scope.version);
}
},
'php-settings': {
Expand All @@ -73,6 +87,9 @@ angular.module('readiness-check', [])
angular.extend($scope.settings, data);
$scope.updateOnProcessed($scope.settings.responseType);
$scope.stopProgress();
},
fail: function() {
$scope.requestFailedHandler($scope.settings);
}
},
'php-extensions': {
Expand All @@ -86,6 +103,9 @@ angular.module('readiness-check', [])
angular.extend($scope.extensions, data);
$scope.updateOnProcessed($scope.extensions.responseType);
$scope.stopProgress();
},
fail: function() {
$scope.requestFailedHandler($scope.extensions);
}
},
'file-permissions': {
Expand All @@ -99,12 +119,16 @@ angular.module('readiness-check', [])
angular.extend($scope.permissions, data);
$scope.updateOnProcessed($scope.permissions.responseType);
$scope.stopProgress();
},
fail: function() {
$scope.requestFailedHandler($scope.permissions);
}
}
};

$scope.isCompleted = function() {
return $scope.version.processed
&& $scope.settings.processed
&& $scope.extensions.processed
&& $scope.permissions.processed;
};
Expand Down Expand Up @@ -133,8 +157,11 @@ angular.module('readiness-check', [])
};

$scope.query = function(item) {
return $http.get(item.url)
.success(function(data) { item.process(data) });
return $http.get(item.url, {timeout: 3000})
.success(function(data) { item.process(data) })
.error(function(data, status) {
item.fail();
});
};

$scope.progress = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public function validate(InputInterface $input)
switch ($key) {
case StoreConfigurationDataMapper::KEY_BASE_URL:
/** @var Validator $url */
if (strcmp($value, '{{base_url}}') == 0) {
break;
}
$url = $this->objectManager->get('Magento\Framework\Url\Validator');
if (!$url->isValid($value)) {
$errorMsgs = $url->getMessages();
Expand Down
5 changes: 0 additions & 5 deletions setup/src/Magento/Setup/Fixtures/FixtureModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ public function reindex(OutputInterface $output)
*/
public function loadFixtures()
{
if (!is_readable(__DIR__)) {
throw new \Exception(
'Fixtures set directory `' . __DIR__ . '` is not readable or does not exists.'
);
}
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN);

foreach ($files as $file) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Setup\Test\Unit\Fixtures;

use \Magento\Setup\Fixtures\CartPriceRulesFixture;

class CartPriceRulesFixtureTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel
*/
private $fixtureModelMock;

/**
* @var \Magento\Setup\Fixtures\CartPriceRulesFixture
*/
private $model;

public function setUp()
{
$this->fixtureModelMock = $this->getMock('\Magento\Setup\Fixtures\FixtureModel', [], [], '', false);

$this->model = new CartPriceRulesFixture($this->fixtureModelMock);
}

public function testExecute()
{
$storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false);
$storeMock->expects($this->once())
->method('getRootCategoryId')
->will($this->returnValue(2));

$websiteMock = $this->getMock('\Magento\Store\Model\Website', [], [], '', false);
$websiteMock->expects($this->once())
->method('getGroups')
->will($this->returnValue([$storeMock]));
$websiteMock->expects($this->once())
->method('getId')
->will($this->returnValue('website_id'));

$contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
$abstractDbMock = $this->getMockForAbstractClass(
'\Magento\Framework\Model\Resource\Db\AbstractDb',
[$contextMock],
'',
true,
true,
true,
['getAllChildren']
);
$abstractDbMock->expects($this->once())
->method('getAllChildren')
->will($this->returnValue([1]));

$storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false);
$storeManagerMock->expects($this->once())
->method('getWebsites')
->will($this->returnValue([$websiteMock]));

$categoryMock = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false);
$categoryMock->expects($this->once())
->method('getResource')
->will($this->returnValue($abstractDbMock));
$categoryMock->expects($this->once())
->method('getPath')
->will($this->returnValue('path/to/file'));
$categoryMock->expects($this->once())
->method('getId')
->will($this->returnValue('category_id'));

$modelMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false);
$modelMock->expects($this->once())
->method('getIdFieldName')
->will($this->returnValue('Field Id Name'));

$objectValueMap = [
['Magento\SalesRule\Model\Rule', $modelMock],
['Magento\Catalog\Model\Category', $categoryMock]
];

$objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false);
$objectManagerMock->expects($this->once())
->method('create')
->will($this->returnValue($storeManagerMock));
$objectManagerMock->expects($this->exactly(2))
->method('get')
->will($this->returnValueMap($objectValueMap));

$valueMap = [
['cart_price_rules', 0, 1],
['cart_price_rules_floor', 3, 3]
];

$this->fixtureModelMock
->expects($this->exactly(2))
->method('getValue')
->will($this->returnValueMap($valueMap));
$this->fixtureModelMock
->expects($this->exactly(3))
->method('getObjectManager')
->will($this->returnValue($objectManagerMock));

$this->model->execute();
}

public function testNoFixtureConfigValue()
{
$ruleMock = $this->getMock('\Magento\SalesRule\Model\Rule', [], [], '', false);
$ruleMock->expects($this->never())->method('save');

$objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false);
$objectManagerMock->expects($this->never())
->method('get')
->with($this->equalTo('Magento\SalesRule\Model\Rule'))
->willReturn($ruleMock);

$this->fixtureModelMock
->expects($this->never())
->method('getObjectManager')
->willReturn($objectManagerMock);
$this->fixtureModelMock
->expects($this->once())
->method('getValue')
->willReturn(false);

$this->model->execute();
}

public function testGetActionTitle()
{
$this->assertSame('Generating Cart Price Rules', $this->model->getActionTitle());
}

public function testIntroduceParamLabels()
{
$this->assertSame([
'cart_price_rules' => 'Cart Price Rules'
], $this->model->introduceParamLabels());
}
}
Loading

0 comments on commit 0df70ba

Please sign in to comment.