Skip to content

Commit fc73ae2

Browse files
committed
Category collection now use getStoreId and not directly the store manager
1 parent 9d9a6c3 commit fc73ae2

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function joinUrlRewrite()
313313
['request_path'],
314314
sprintf(
315315
'{{table}}.is_autogenerated = 1 AND {{table}}.store_id = %d AND {{table}}.entity_type = \'%s\'',
316-
$this->_storeManager->getStore()->getId(),
316+
$this->getStoreId(),
317317
CategoryUrlRewriteGenerator::ENTITY_TYPE
318318
),
319319
'left'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category\Collection;
8+
9+
class UrlRewriteTest extends \PHPUnit\Framework\TestCase
10+
{
11+
/**
12+
* @var \PHPUnit_Framework_MockObject_MockObject
13+
*/
14+
protected $_model;
15+
16+
protected function setUp()
17+
{
18+
$this->_model = $this->getMockBuilder(
19+
\Magento\Catalog\Model\ResourceModel\Category\Collection::class
20+
)->disableOriginalConstructor()
21+
->setMethodsExcept(['joinUrlRewrite', 'setStoreId', 'getStoreId'])
22+
->getMock();
23+
}
24+
25+
26+
public function testStoreIdUsedByUrlRewrite()
27+
{
28+
$this->_model->expects($this->once())
29+
->method('joinTable')
30+
->with(
31+
$this->anything(),
32+
$this->anything(),
33+
$this->anything(),
34+
$this->equalTo('{{table}}.is_autogenerated = 1 AND {{table}}.store_id = 100 AND {{table}}.entity_type = \'category\''),
35+
$this->anything()
36+
);
37+
$this->_model->setStoreId(100);
38+
$this->_model->joinUrlRewrite();
39+
}
40+
}

0 commit comments

Comments
 (0)