29 $this->config = $this->createMock(\
Magento\Eav\Model\Config::class);
30 $this->select = $this->getMockBuilder(\
Magento\Framework\DB\Select::class)
31 ->setMethods([
'select',
'from',
'where',
'join'])
32 ->disableOriginalConstructor()
34 $this->connection = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
35 ->disableOriginalConstructor()
36 ->getMockForAbstractClass();
37 $this->resource = $this->createMock(\
Magento\Framework\
App\ResourceConnection::class);
38 $this->resource->expects($this->any())->method(
'getConnection')->willReturn($this->connection);
40 $this->storeViewService = (
new ObjectManager($this))->getObject(
41 \
Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class,
43 'eavConfig' => $this->config,
44 'resource' => $this->resource,
83 $attribute = $this->getMockBuilder(\
Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
84 ->disableOriginalConstructor()
85 ->setMethods([
'__wakeup',
'getBackendTable',
'getId',
'getEntity'])
86 ->getMockForAbstractClass();
87 $this->config->expects($this->once())->method(
'getAttribute')->with(
$entityType,
'url_key')
89 $entity = $this->getMockBuilder(\
Magento\Eav\Model\Entity\AbstractEntity::class)
90 ->disableOriginalConstructor()
93 $entity->expects($this->once())->method(
'getEntityTable')->will($this->returnValue(
'entity_table'));
94 $entity->expects($this->once())->method(
'getLinkField')->willReturn(
'link_field');
95 $attribute->expects($this->once())->method(
'getBackendTable')->will($this->returnValue(
'backend_table'));
96 $attribute->expects($this->once())->method(
'getId')->will($this->returnValue(
'attribute-id'));
97 $this->select->expects($this->once())->method(
'from')->with([
'e' =>
'entity_table'], [])
98 ->will($this->returnSelf());
99 $this->select->expects($this->any())->method(
'where')->will($this->returnSelf());
100 $this->select->expects($this->once())->method(
'join')->with(
101 [
'e_attr' =>
'backend_table'],
102 "e.link_field = e_attr.link_field",
104 )->will($this->returnSelf());
105 $this->connection->expects($this->once())->method(
'select')->will($this->returnValue($this->select));
106 $this->connection->expects($this->once())->method(
'fetchCol')->will($this->returnValue($fetchedStoreIds));
120 $invalidEntityType =
'invalid_type';
121 $this->config->expects($this->once())->method(
'getAttribute')->will($this->returnValue(
false));
123 $this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore(1, 1, $invalidEntityType);
testInvalidAttributeRetrieve()
overriddenUrlKeyForStoreDataProvider()
isRootCategoryForStoreDataProvider()
testDoesEntityHaveOverriddenUrlKeyForStore($storeId, $fetchedStoreIds, $result)