Skip to content

Commit

Permalink
Category collection now use getStoreId and not directly the store man…
Browse files Browse the repository at this point in the history
…ager
  • Loading branch information
alepane21 authored and rostyslav-hymon committed Mar 27, 2018
1 parent f6a0a90 commit 29431e9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public function joinUrlRewrite()
['request_path'],
sprintf(
'{{table}}.is_autogenerated = 1 AND {{table}}.store_id = %d AND {{table}}.entity_type = \'%s\'',
$this->_storeManager->getStore()->getId(),
$this->getStoreId(),
CategoryUrlRewriteGenerator::ENTITY_TYPE
),
'left'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category\Collection;

class UrlRewriteTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $_model;

protected function setUp()
{
$this->_model = $this->getMockBuilder(
\Magento\Catalog\Model\ResourceModel\Category\Collection::class
)->disableOriginalConstructor()
->setMethodsExcept(['joinUrlRewrite', 'setStoreId', 'getStoreId'])
->getMock();
}


public function testStoreIdUsedByUrlRewrite()
{
$this->_model->expects($this->once())
->method('joinTable')
->with(
$this->anything(),
$this->anything(),
$this->anything(),
$this->equalTo('{{table}}.is_autogenerated = 1 AND {{table}}.store_id = 100 AND {{table}}.entity_type = \'category\''),
$this->anything()
);
$this->_model->setStoreId(100);
$this->_model->joinUrlRewrite();
}
}

0 comments on commit 29431e9

Please sign in to comment.