Skip to content

Commit c0f4002

Browse files
authored
Merge pull request #469 from magento-troll/troll_bugfix
MAGETWO-59144 [FT] Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest failed MAGETWO-56052 MySQL triggers for Indexers not removed after upgrade from 2.0.7ce to 2.1ce MAGETWO-59304 Test Magento\Test\Legacy\ModuleDBChangeTest:testModuleSetupFiles fails on developer branch MAGETWO-56676 Related Products Target Rule not working
2 parents b4ab1f9 + 0fb698f commit c0f4002

File tree

6 files changed

+132
-20
lines changed

6 files changed

+132
-20
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Indexer\Setup;
8+
9+
use Magento\Framework\Setup\InstallDataInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Indexer\Model\IndexerFactory;
13+
use Magento\Framework\Indexer\ConfigInterface;
14+
15+
/**
16+
* Recurring data upgrade for indexer module
17+
*/
18+
class RecurringData implements InstallDataInterface
19+
{
20+
/**
21+
* @var IndexerFactory
22+
*/
23+
private $indexerFactory;
24+
25+
/**
26+
* @var ConfigInterface
27+
*/
28+
private $configInterface;
29+
30+
/**
31+
* RecurringData constructor.
32+
*
33+
* @param IndexerFactory $indexerFactory
34+
* @param ConfigInterface $configInterface
35+
*/
36+
public function __construct(
37+
IndexerFactory $indexerFactory,
38+
ConfigInterface $configInterface
39+
) {
40+
$this->indexerFactory = $indexerFactory;
41+
$this->configInterface = $configInterface;
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
48+
{
49+
foreach (array_keys($this->configInterface->getIndexers()) as $indexerId) {
50+
$indexer = $this->indexerFactory->create()->load($indexerId);
51+
if ($indexer->isScheduled()) {
52+
$indexer->getView()->unsubscribe()->subscribe();
53+
}
54+
}
55+
}
56+
}

app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ public function getBindArgumentValue()
602602
*/
603603
public function getMappedSqlField()
604604
{
605-
if (!$this->isAttributeSetOrCategory()) {
605+
if ($this->getAttribute() == 'sku') {
606+
$mappedSqlField = 'e.sku';
607+
} elseif (!$this->isAttributeSetOrCategory()) {
606608
$mappedSqlField = $this->getEavAttributeTableAlias() . '.value';
607609
} elseif ($this->getAttribute() == 'category_ids') {
608610
$mappedSqlField = 'e.entity_id';

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductPage" />
111111
</variation>
112112
<variation name="CreateConfigurableProductEntityTestVariation6" summary="Create Configurable Product with Creating New Category and New Attribute (Required Fields Only)" ticketId="MAGETWO-13361">
113-
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
113+
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
114114
<data name="product/data/configurable_attributes_data/dataset" xsi:type="string">two_searchable_options</data>
115115
<data name="product/data/name" xsi:type="string">Configurable Product %isolation%</data>
116116
<data name="product/data/sku" xsi:type="string">configurable_sku_%isolation%</data>

dev/tests/static/testsuite/Magento/Test/Legacy/ModuleDBChangeTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ class ModuleDBChangeTest extends \PHPUnit_Framework_TestCase
2222
*/
2323
protected static $changedFileList = '';
2424

25+
/**
26+
* @var string Path for Magento's composer.json
27+
*/
28+
protected static $composerFilePath = BP . '/composer.json';
29+
30+
/**
31+
* @var bool Is tests executes on develop branch
32+
*/
33+
protected static $isOnDevVersion = false;
34+
2535
/**
2636
* Set changed files paths and list for all projects
2737
*/
@@ -30,13 +40,23 @@ public static function setUpBeforeClass()
3040
foreach (glob(self::$changedFilesPattern) as $changedFile) {
3141
self::$changedFileList .= file_get_contents($changedFile) . PHP_EOL;
3242
}
43+
44+
if (file_exists(self::$composerFilePath)) {
45+
$jsonData = json_decode(file_get_contents(self::$composerFilePath));
46+
if (substr((string) $jsonData->version, -4) == '-dev') {
47+
self::$isOnDevVersion = true;
48+
}
49+
}
3350
}
3451

3552
/**
3653
* Test changes for module.xml files
3754
*/
3855
public function testModuleXmlFiles()
3956
{
57+
if (self::$isOnDevVersion) {
58+
$this->markTestSkipped('This test isn\'t applicable to the developer version of Magento');
59+
}
4060
preg_match_all('|etc/module\.xml$|mi', self::$changedFileList, $matches);
4161
$this->assertEmpty(
4262
reset($matches),
@@ -50,6 +70,9 @@ public function testModuleXmlFiles()
5070
*/
5171
public function testModuleSetupFiles()
5272
{
73+
if (self::$isOnDevVersion) {
74+
$this->markTestSkipped('This test isn\'t applicable to the developer version of Magento');
75+
}
5376
preg_match_all('|app/code/Magento/[^/]+/Setup/[^/]+$|mi', self::$changedFileList, $matches);
5477
$this->assertEmpty(
5578
reset($matches),

lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ class SubscriptionTest extends \PHPUnit_Framework_TestCase
4040
protected function setUp()
4141
{
4242
$this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false);
43-
$this->resourceMock = $this->getMock(
44-
\Magento\Framework\App\ResourceConnection::class,
45-
[],
46-
[],
47-
'',
48-
false,
49-
false
43+
$this->resourceMock = $this->getMock(
44+
\Magento\Framework\App\ResourceConnection::class,
45+
[],
46+
[],
47+
'',
48+
false,
49+
false
5050
);
5151

5252
$this->connectionMock->expects($this->any())
@@ -57,19 +57,19 @@ protected function setUp()
5757
->method('getConnection')
5858
->willReturn($this->connectionMock);
5959

60-
$this->triggerFactoryMock = $this->getMock(
60+
$this->triggerFactoryMock = $this->getMock(
6161
\Magento\Framework\DB\Ddl\TriggerFactory::class, [], [], '', false, false
6262
);
63-
$this->viewCollectionMock = $this->getMockForAbstractClass(
63+
$this->viewCollectionMock = $this->getMockForAbstractClass(
6464
\Magento\Framework\Mview\View\CollectionInterface::class, [], '', false, false, true, []
6565
);
66-
$this->viewMock = $this->getMockForAbstractClass(
66+
$this->viewMock = $this->getMockForAbstractClass(
6767
\Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, []
6868
);
6969

7070
$this->resourceMock->expects($this->any())
7171
->method('getTableName')
72-
->willReturn($this->tableName);
72+
->will($this->returnArgument(0));
7373

7474
$this->model = new Subscription(
7575
$this->resourceMock,
@@ -96,11 +96,15 @@ public function testGetColumnName()
9696
$this->assertEquals('columnName', $this->model->getColumnName());
9797
}
9898

99+
/**
100+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101+
*/
99102
public function testCreate()
100103
{
101104
$triggerName = 'trigger_name';
102105
$this->resourceMock->expects($this->atLeastOnce())->method('getTriggerName')->willReturn($triggerName);
103106
$triggerMock = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Trigger::class)
107+
->setMethods(['setName', 'getName', 'setTime', 'setEvent', 'setTable', 'addStatement'])
104108
->disableOriginalConstructor()
105109
->getMock();
106110
$triggerMock->expects($this->exactly(3))
@@ -121,11 +125,38 @@ public function testCreate()
121125
->method('setTable')
122126
->with($this->tableName)
123127
->will($this->returnSelf());
124-
$triggerMock->expects($this->exactly(6))
128+
129+
$triggerMock->expects($this->at(4))
130+
->method('addStatement')
131+
->with("INSERT IGNORE INTO test_view_cl (entity_id) VALUES (NEW.columnName);")
132+
->will($this->returnSelf());
133+
134+
$triggerMock->expects($this->at(5))
135+
->method('addStatement')
136+
->with("INSERT IGNORE INTO other_test_view_cl (entity_id) VALUES (NEW.columnName);")
137+
->will($this->returnSelf());
138+
139+
$triggerMock->expects($this->at(11))
140+
->method('addStatement')
141+
->with("INSERT IGNORE INTO test_view_cl (entity_id) VALUES (NEW.columnName);")
142+
->will($this->returnSelf());
143+
144+
$triggerMock->expects($this->at(12))
145+
->method('addStatement')
146+
->with("INSERT IGNORE INTO other_test_view_cl (entity_id) VALUES (NEW.columnName);")
147+
->will($this->returnSelf());
148+
149+
$triggerMock->expects($this->at(18))
150+
->method('addStatement')
151+
->with("INSERT IGNORE INTO test_view_cl (entity_id) VALUES (OLD.columnName);")
152+
->will($this->returnSelf());
153+
154+
$triggerMock->expects($this->at(19))
125155
->method('addStatement')
156+
->with("INSERT IGNORE INTO other_test_view_cl (entity_id) VALUES (OLD.columnName);")
126157
->will($this->returnSelf());
127158

128-
$changelogMock = $this->getMockForAbstractClass(
159+
$changelogMock = $this->getMockForAbstractClass(
129160
\Magento\Framework\Mview\View\ChangelogInterface::class, [], '', false, false, true, []
130161
);
131162
$changelogMock->expects($this->exactly(3))
@@ -143,7 +174,7 @@ public function testCreate()
143174
->method('create')
144175
->will($this->returnValue($triggerMock));
145176

146-
$otherChangelogMock = $this->getMockForAbstractClass(
177+
$otherChangelogMock = $this->getMockForAbstractClass(
147178
\Magento\Framework\Mview\View\ChangelogInterface::class, [], '', false, false, true, []
148179
);
149180
$otherChangelogMock->expects($this->exactly(3))
@@ -153,7 +184,7 @@ public function testCreate()
153184
->method('getColumnName')
154185
->will($this->returnValue('entity_id'));
155186

156-
$otherViewMock = $this->getMockForAbstractClass(
187+
$otherViewMock = $this->getMockForAbstractClass(
157188
\Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, []
158189
);
159190
$otherViewMock->expects($this->exactly(1))
@@ -216,7 +247,7 @@ public function testRemove()
216247
->method('create')
217248
->will($this->returnValue($triggerMock));
218249

219-
$otherChangelogMock = $this->getMockForAbstractClass(
250+
$otherChangelogMock = $this->getMockForAbstractClass(
220251
\Magento\Framework\Mview\View\ChangelogInterface::class, [], '', false, false, true, []
221252
);
222253
$otherChangelogMock->expects($this->exactly(3))
@@ -226,7 +257,7 @@ public function testRemove()
226257
->method('getColumnName')
227258
->will($this->returnValue('entity_id'));
228259

229-
$otherViewMock = $this->getMockForAbstractClass(
260+
$otherViewMock = $this->getMockForAbstractClass(
230261
\Magento\Framework\Mview\ViewInterface::class, [], '', false, false, true, []
231262
);
232263
$otherViewMock->expects($this->exactly(1))

lib/internal/Magento/Framework/Mview/etc/mview.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<xs:simpleType name="subscriptionModelType">
107107
<xs:annotation>
108108
<xs:documentation>
109-
Subscription model must be a valid PHP class or interface name.
109+
DEPRECATED. Subscription model must be a valid PHP class or interface name.
110110
</xs:documentation>
111111
</xs:annotation>
112112
<xs:restriction base="xs:string">

0 commit comments

Comments
 (0)