Skip to content

Commit

Permalink
Merge pull request #325 from magento-api/develop
Browse files Browse the repository at this point in the history
[API] Sprint 49 Bugfixes + Task
  • Loading branch information
Paliarush, Alexander(apaliarush) committed May 28, 2015
2 parents 183254f + 5afa00a commit 932b845
Show file tree
Hide file tree
Showing 60 changed files with 473 additions and 251 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UserConfigTest extends \PHPUnit_Framework_TestCase
{
public function testUserRequestCreation()
{
$factoryMock = $this->getMock('Magento\Config\Model\Config\Factory', [], [], '', false);
$factoryMock = $this->getMock('Magento\Config\Model\Config\Factory', ['create'], [], '', false);
$responseMock = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false);
$configMock = $this->getMock('Magento\Config\Model\Config', [], [], '', false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function setUp()
);
$this->orderFactoryMock = $this->getMock(
'Magento\Sales\Model\OrderFactory',
[],
['create'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function setUp()
->getMock();
$this->backupModelFactoryMock = $this->getMockBuilder('Magento\Backup\Model\BackupFactory')
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->backupModelMock = $this->getMockBuilder('Magento\Backup\Model\Backup')
->disableOriginalConstructor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected function setUp()
{
$this->optionListMock = $this->getMock('\Magento\Bundle\Model\Product\OptionList', [], [], '', false);
$this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->model = new \Magento\Bundle\Model\Plugin\BundleLoadOptions(
Expand Down
20 changes: 16 additions & 4 deletions app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class PriceTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->ruleFactoryMock = $this->getMock(
'\Magento\CatalogRule\Model\Resource\RuleFactory',
[],
'Magento\CatalogRule\Model\Resource\RuleFactory',
['create'],
[],
'',
false
Expand All @@ -77,8 +77,20 @@ protected function setUp()
$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock();
$this->groupManagement = $this->getMockBuilder('Magento\Customer\Api\GroupManagementInterface')
->getMockForAbstractClass();
$gpFactory = $this->getMock('Magento\Catalog\Api\Data\ProductGroupPriceInterfaceFactory', [], [], '', false);
$tpFactory = $this->getMock('Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory', [], [], '', false);
$gpFactory = $this->getMock(
'Magento\Catalog\Api\Data\ProductGroupPriceInterfaceFactory',
['create'],
[],
'',
false
);
$tpFactory = $this->getMock(
'Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory',
['create'],
[],
'',
false
);
$scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');

$objectManagerHelper = new ObjectManagerHelper($this);
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ protected function setUp()
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->bundleModelSelection = $this->getMockBuilder('Magento\Bundle\Model\SelectionFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->bundleFactory = $this->getMockBuilder('\Magento\Bundle\Model\Resource\BundleFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Captcha/Test/Unit/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testGetCaptcha()
new \Magento\Captcha\Model\DefaultModel(
$this->getMock('Magento\Framework\Session\SessionManager', [], [], '', false),
$this->getMock('Magento\Captcha\Helper\Data', [], [], '', false),
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', [], [], '', false),
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', ['create'], [], '', false),
'user_create'
)
)
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Captcha/Test/Unit/Model/CronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function setUp()
);

$this->_model = new \Magento\Captcha\Model\Cron(
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', [], [], '', false),
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', ['create'], [], '', false),
$this->_helper,
$this->_adminHelper,
$this->_filesystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function setUp()
);
$this->categoryFactoryMock = $this->getMock(
'Magento\Catalog\Model\CategoryFactory',
[],
['create'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testGetOptionHtml()

$optValFactoryMock = $this->getMock(
'Magento\Catalog\Model\Product\Option\ValueFactory',
[],
['create'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class IndexTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->contextMock = $this->getMock('Magento\Framework\App\Action\Context',
$this->contextMock = $this->getMock(
'Magento\Framework\App\Action\Context',
['getRequest', 'getResponse', 'getResultRedirectFactory'],
[],
'',
Expand All @@ -90,10 +91,16 @@ protected function setUp()
->method('getResultRedirectFactory')
->willReturn($this->redirectFactoryMock);

$this->itemFactoryMock = $this->getMock('Magento\Catalog\Model\Product\Compare\ItemFactory', [], [], '', false);
$this->itemFactoryMock = $this->getMock(
'Magento\Catalog\Model\Product\Compare\ItemFactory',
['create'],
[],
'',
false
);
$this->collectionFactoryMock = $this->getMock(
'Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory',
[],
['create'],
[],
'',
false
Expand Down Expand Up @@ -131,10 +138,12 @@ public function testExecute()
$beforeUrl = 'test_url';
$this->request->expects($this->any())
->method('getParam')
->willReturnMap([
->willReturnMap(
[
['items', null, null],
['uenc', null, $beforeUrl],
]);
]
);
$this->decoderMock->expects($this->once())
->method('decode')
->with($beforeUrl)
Expand All @@ -152,10 +161,12 @@ public function testExecuteWithItems()
{
$this->request->expects($this->any())
->method('getParam')
->willReturnMap([
->willReturnMap(
[
['items', null, '1,2,3'],
['uenc', null, null],
]);
]
);
$this->decoderMock->expects($this->never())->method('decode');
$this->catalogSession->expects($this->never())->method('setBeforeCompareUrl');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public function setUp()

$resourceConfigFactoryMock = $this->getMock(
'Magento\Catalog\Model\Resource\ConfigFactory',
[],
['create'],
[],
'',
false
);

$eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', [], [], '', false);
$eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', ['create'], [], '', false);

$this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->typeFactoryMock = $this->getMockBuilder('Magento\Eav\Model\Entity\TypeFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
Expand All @@ -153,6 +154,7 @@ protected function setUp()
->getMock();
$this->attributeOptionFactoryMock =
$this->getMockBuilder('Magento\Eav\Api\Data\AttributeOptionInterfaceFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor')
Expand Down
31 changes: 20 additions & 11 deletions app/code/Magento/Catalog/Test/Unit/Model/ObserverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,26 @@ public function setUp()

$layerResolver = $this->_getCleanMock('Magento\Catalog\Model\Layer\Resolver');
$layerResolver->expects($this->once())->method('get')->willReturn(null);
$this->_observer = (new ObjectManager($this))->getObject('Magento\Catalog\Model\Observer', [
'categoryResource' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Category'),
'catalogProduct' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Product'),
'storeManager' => $this->_storeManager,
'layerResolver' => $layerResolver,
'indexIndexer' => $this->_getCleanMock('\Magento\Index\Model\Indexer'),
'catalogCategory' => $this->_catalogCategory,
'catalogData' => $this->_getCleanMock('\Magento\Catalog\Helper\Data'),
'categoryFlatState' => $this->_categoryFlatState,
'productResourceFactory' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\ProductFactory'),
]);
$this->_observer = (new ObjectManager($this))->getObject(
'Magento\Catalog\Model\Observer',
[
'categoryResource' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Category'),
'catalogProduct' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Product'),
'storeManager' => $this->_storeManager,
'layerResolver' => $layerResolver,
'indexIndexer' => $this->_getCleanMock('\Magento\Index\Model\Indexer'),
'catalogCategory' => $this->_catalogCategory,
'catalogData' => $this->_getCleanMock('\Magento\Catalog\Helper\Data'),
'categoryFlatState' => $this->_categoryFlatState,
'productResourceFactory' => $this->getMock(
'Magento\Catalog\Model\Resource\ProductFactory',
['create'],
[],
'',
false
)
]
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp()
$this->_helper = $this->getMock('Magento\Catalog\Helper\Data', ['isPriceGlobal'], [], '', false);
$this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));

$currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', [], [], '', false);
$currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', ['create'], [], '', false);
$storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
$productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', [], [], '', false);
$configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function setUp()
->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4]));
$this->validatorFactoryMock = $this->getMock(
'Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory',
[],
['create'],
[],
'',
false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ protected function setUp()
->disableOriginalConstructor()->getMock();
$this->mimeTypeExtensionMapMock =
$this->getMockBuilder('Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap')->getMock();
$this->contentFactoryMock = $this->getMockBuilder(
'Magento\Framework\Api\Data\ImageContentInterfaceFactory'
)->disableOriginalConstructor()->setMethods(['create'])->getMockForAbstractClass();
$this->contentFactoryMock = $this->getMock('Magento\Framework\Api\Data\ImageContentInterfaceFactory', ['create'], [], '', false);
$this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface')
->disableOriginalConstructor()
->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp()
);
$attrSetColFactory = $this->getMock(
'\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory',
[],
['create'],
[],
'',
false
Expand All @@ -52,7 +52,7 @@ protected function setUp()
);
$attrColFactory = $this->getMock(
'\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory',
[],
['create'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected function setUp()
{
$stockRegistryMock = $this->getMock('\Magento\CatalogInventory\Api\StockRegistryInterface');
$this->productExtensionFactoryMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();

Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ protected function setUp()
false
);
$countryCollectionFactoryMock = $this->getMock(
'\Magento\Directory\Model\Resource\Country\CollectionFactory',
[],
'Magento\Directory\Model\Resource\Country\CollectionFactory',
['create'],
[],
'',
false
);
$regionCollectionFactoryMock = $this->getMock(
'\Magento\Directory\Model\Resource\Region\CollectionFactory',
[],
'Magento\Directory\Model\Resource\Region\CollectionFactory',
['create'],
[],
'',
false
Expand Down
24 changes: 12 additions & 12 deletions app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public function setUp()
*/
public function testGetLastRealOrder($orderId, $incrementId, $orderMock)
{
$orderFactory = $this->getMockBuilder(
'Magento\Sales\Model\OrderFactory'
)->disableOriginalConstructor()->setMethods(
['create']
)->getMock();
$orderFactory = $this->getMockBuilder('Magento\Sales\Model\OrderFactory')
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$orderFactory->expects($this->once())->method('create')->will($this->returnValue($orderMock));

$messageCollectionFactory = $this->getMockBuilder(
'Magento\Framework\Message\CollectionFactory'
)->disableOriginalConstructor()->getMock();
$quoteRepository = $this->getMockBuilder(
'Magento\Quote\Model\QuoteRepository'
)->disableOriginalConstructor()->getMock();
$messageCollectionFactory = $this->getMockBuilder('Magento\Framework\Message\CollectionFactory')
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$quoteRepository = $this->getMockBuilder('Magento\Quote\Model\QuoteRepository')
->disableOriginalConstructor()
->getMock();

$appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false);
$appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
Expand Down Expand Up @@ -323,7 +323,7 @@ public function testReplaceQuote()
$quoteIdMaskMock->expects($this->once())->method('setQuoteId')->with($replaceQuoteId)->willReturnSelf();
$quoteIdMaskMock->expects($this->once())->method('save');

$quoteIdMaskFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteIdMaskFactory', [], [], '', false);
$quoteIdMaskFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteIdMaskFactory', ['create'], [], '', false);
$quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock);

$session = $this->_helper->getObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function setUp()

$this->_storageCollectionFactoryMock = $this->getMock(
'Magento\Cms\Model\Wysiwyg\Images\Storage\CollectionFactory',
[],
['create'],
[],
'',
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ class AfterProductLoadTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->optionValueFactory = $this->getMockBuilder(
'\Magento\ConfigurableProduct\Api\Data\OptionValueInterfaceFactory'
)->disableOriginalConstructor()->getMock();
$this->optionValueFactory = $this->getMock(
'\Magento\ConfigurableProduct\Api\Data\OptionValueInterfaceFactory',
['create'],
[],
'',
false
);
$this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
->disableOriginalConstructor()
->getMock();
Expand All @@ -54,6 +58,7 @@ protected function setUp()
->method('getTypeInstance')
->willReturn($this->configurableProductTypeInstanceMock);
$this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();

Expand Down
Loading

0 comments on commit 932b845

Please sign in to comment.