Skip to content

Commit b08d800

Browse files
committed
MC-17251: Creating a preference for category product indexer breaks setup:di:compile
- Added integration test
1 parent fc66706 commit b08d800

File tree

2 files changed

+75
-0
lines changed
  • dev/tests/integration
    • framework/Magento/TestFramework/Catalog/Model/Indexer/Category/Product/Action
    • testsuite/Magento/Catalog/Model/Indexer/Category/Product/Action

2 files changed

+75
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TestFramework\Catalog\Model\Indexer\Category\Product\Action;
10+
11+
use Magento\Catalog\Model\Indexer\Category\Product\Action\Full as OriginFull;
12+
13+
/**
14+
* Class Full reindex action
15+
*
16+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
*/
18+
class Full extends OriginFull
19+
{
20+
//
21+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Indexer\Category\Product\Action;
7+
8+
use Magento\Catalog\Model\Indexer\Category\Product\Action\Full as OriginObject;
9+
use Magento\TestFramework\Catalog\Model\Indexer\Category\Product\Action\Full as PreferenceObject;
10+
use Magento\Framework\Interception\PluginListInterface;
11+
12+
/**
13+
* Class FullTest
14+
* @package Magento\Catalog\Model\Indexer\Category\Product\Action
15+
*/
16+
class FullTest extends \PHPUnit\Framework\TestCase
17+
{
18+
/**
19+
* @var PreferenceObject
20+
*/
21+
private $interceptor;
22+
23+
/**
24+
* List of plugins
25+
*
26+
* @var PluginListInterface
27+
*/
28+
private $pluginList;
29+
30+
/**
31+
* Prepare data for test
32+
*/
33+
protected function setUp()
34+
{
35+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
36+
$objectManager->configure(['preferences' => [OriginObject::class => PreferenceObject::class]]);
37+
$this->interceptor = $objectManager->get(OriginObject::class);
38+
$this->pluginList = $objectManager->get(PluginListInterface::class);
39+
}
40+
41+
/**
42+
* Test possibility to add object preference
43+
*/
44+
public function testPreference()
45+
{
46+
$interceptorClassName = get_class($this->interceptor);
47+
48+
// Check interceptor class name
49+
$this->assertEquals($interceptorClassName, PreferenceObject::class . '\Interceptor');
50+
51+
//check that there are no fatal errors
52+
$this->pluginList->getNext($interceptorClassName, 'execute');
53+
}
54+
}

0 commit comments

Comments
 (0)