Skip to content

Commit d909923

Browse files
committed
MC-32014: Remove google-shopping-ads module from core in 2.4.1
1 parent cea922a commit d909923

File tree

13 files changed

+285
-124
lines changed

13 files changed

+285
-124
lines changed

app/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,6 @@
209209
<preference for="Magento\Framework\MessageQueue\QueueFactoryInterface" type="Magento\Framework\MessageQueue\QueueFactory" />
210210
<preference for="Magento\Framework\Search\Request\IndexScopeResolverInterface" type="Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver"/>
211211
<preference for="Magento\Framework\HTTP\ClientInterface" type="Magento\Framework\HTTP\Client\Curl" />
212-
<preference for="Magento\Framework\Mview\TriggerCleanerInterface" type="\Magento\Framework\Mview\TriggerCleaner"/>
213-
<preference for="Magento\Framework\Indexer\ConfigInterface" type="\Magento\Framework\Indexer\Config"/>
214-
<preference for="Magento\Framework\Mview\View\State\CollectionInterface" type="Magento\Framework\Mview\View\State\Collection" />
215212
<type name="Magento\Framework\Model\ResourceModel\Db\TransactionManager" shared="false" />
216213
<type name="Magento\Framework\Acl\Data\Cache">
217214
<arguments>

dev/tests/integration/bin/magento

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* See COPYING.txt for license details.
66
*/
77

8+
use Magento\Framework\Console\Cli;
9+
use Magento\TestFramework\Console\CliProxy;
10+
811
if (PHP_SAPI !== 'cli') {
912
echo 'bin/magento must be run as a CLI application';
1013
exit(1);
@@ -21,15 +24,16 @@ if (isset($_SERVER['INTEGRATION_TEST_PARAMS'])) {
2124
}
2225

2326
try {
24-
require $_SERVER['MAGE_DIRS']['base']['path'] . '/app/bootstrap.php';
27+
require $_SERVER['INTEGRATION_TESTS_CLI_AUTOLOADER'] ??
28+
($_SERVER['MAGE_DIRS']['base']['path'] . '/app/bootstrap.php');
2529
} catch (\Exception $e) {
2630
echo 'Autoload error: ' . $e->getMessage();
2731
exit(1);
2832
}
2933
try {
3034
$handler = new \Magento\Framework\App\ErrorHandler();
3135
set_error_handler([$handler, 'handler']);
32-
$application = new Magento\Framework\Console\Cli('Magento CLI');
36+
$application = new CliProxy('Magento CLI');
3337
$application->run();
3438
} catch (\Exception $e) {
3539
while ($e) {
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Console;
9+
10+
use Magento\Framework\Console\Cli;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\ObjectManagerInterface;
13+
use Symfony\Component\Console\Input\InputInterface;
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
16+
class CliProxy implements \Magento\Framework\ObjectManager\NoninterceptableInterface
17+
{
18+
/**
19+
* @var Cli
20+
*/
21+
private $subject;
22+
23+
/**
24+
* @param string $name
25+
* @param string $version
26+
* @throws \ReflectionException
27+
* @throws LocalizedException
28+
*/
29+
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
30+
{
31+
$this->subject = new Cli($name, $version);
32+
$this->injectDiConfiguration($this->subject);
33+
}
34+
35+
/**
36+
* Runs the current application.
37+
*
38+
* @see \Magento\Framework\Console\Cli::doRun
39+
* @param InputInterface $input
40+
* @param OutputInterface $output
41+
* @return int|null
42+
* @throws \Exception
43+
*/
44+
public function doRun(InputInterface $input, OutputInterface $output)
45+
{
46+
return $this->getSubject()->doRun($input, $output);
47+
}
48+
49+
/**
50+
* Runs the current application.
51+
*
52+
* @see \Symfony\Component\Console\Application::run
53+
* @param InputInterface|null $input
54+
* @param OutputInterface|null $output
55+
* @return int
56+
* @throws \Exception
57+
*/
58+
public function run(InputInterface $input = null, OutputInterface $output = null)
59+
{
60+
return $this->getSubject()->run($input, $output);
61+
}
62+
63+
/**
64+
* Get subject
65+
*
66+
* @return Cli
67+
*/
68+
private function getSubject(): Cli
69+
{
70+
return $this->subject;
71+
}
72+
73+
/**
74+
* Inject additional DI configuration
75+
*
76+
* @param Cli $cli
77+
* @return bool
78+
* @throws LocalizedException
79+
* @throws \ReflectionException
80+
*/
81+
private function injectDiConfiguration(Cli $cli): bool
82+
{
83+
$diPreferences = $this->getDiPreferences();
84+
if ($diPreferences) {
85+
$object = new \ReflectionObject($cli);
86+
87+
$attribute = $object->getProperty('objectManager');
88+
$attribute->setAccessible(true);
89+
90+
/** @var ObjectManagerInterface $objectManager */
91+
$objectManager = $attribute->getValue($cli);
92+
$objectManager->configure($diPreferences);
93+
94+
$attribute->setAccessible(false);
95+
}
96+
97+
return true;
98+
}
99+
100+
/**
101+
* Get additional DI preferences
102+
*
103+
* @return array|array[]
104+
* @throws LocalizedException
105+
* @SuppressWarnings(PHPMD.Superglobals)
106+
*/
107+
private function getDiPreferences(): array
108+
{
109+
$diPreferences = [];
110+
$diPreferencesPath = $_SERVER['TESTS_BASE_DIR'] . '/etc/di/preferences/cli/';
111+
112+
$preferenceFiles = glob($diPreferencesPath . '*.php');
113+
114+
foreach ($preferenceFiles as $file) {
115+
if (!is_readable($file)) {
116+
throw new LocalizedException(__("'%1' is not readable file.", $file));
117+
}
118+
$diPreferences = array_replace($diPreferences, include $file);
119+
}
120+
121+
return $diPreferences ? ['preferences' => $diPreferences] : $diPreferences;
122+
}
123+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
return [
8+
'\Magento\Framework\Mview\TriggerCleaner' => '\Magento\TestFramework\Mview\DummyTriggerCleaner',
9+
];

dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
namespace Magento\TestFramework\Deploy;
77

88
use Magento\Framework\App\DeploymentConfig;
9+
use Magento\Framework\Exception\LocalizedException;
910
use Magento\Framework\Shell;
1011
use Magento\Framework\Shell\CommandRenderer;
1112
use Magento\Setup\Console\Command\InstallCommand;
1213

1314
/**
1415
* The purpose of this class is enable/disable module and upgrade commands execution.
16+
*
17+
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
1518
*/
1619
class CliCommand
1720
{
1821
/**
19-
* @var \Magento\Framework\Shell
22+
* @var Shell
2023
*/
2124
private $shell;
2225

@@ -36,10 +39,7 @@ class CliCommand
3639
private $deploymentConfig;
3740

3841
/**
39-
* ShellCommand constructor.
40-
*
41-
* @param TestModuleManager $testEnv
42-
* @param DeploymentConfig $deploymentConfig
42+
* @param TestModuleManager $testEnv
4343
* @internal param Shell $shell
4444
*/
4545
public function __construct(
@@ -53,8 +53,9 @@ public function __construct(
5353
/**
5454
* Copy Test module files and execute enable module command.
5555
*
56-
* @param string $moduleName
56+
* @param string $moduleName
5757
* @return string
58+
* @throws LocalizedException
5859
*/
5960
public function introduceModule($moduleName)
6061
{
@@ -65,13 +66,14 @@ public function introduceModule($moduleName)
6566
/**
6667
* Execute enable module command.
6768
*
68-
* @param string $moduleName
69+
* @param string $moduleName
6970
* @return string
71+
* @throws LocalizedException
7072
*/
7173
public function enableModule($moduleName)
7274
{
7375
$initParams = $this->parametersHolder->getInitParams();
74-
$enableModuleCommand = 'php -f ' . BP . '/bin/magento module:enable ' . $moduleName
76+
$enableModuleCommand = $this->getCliScriptCommand() . ' module:enable ' . $moduleName
7577
. ' -n -vvv --magento-init-params="' . $initParams['magento-init-params'] . '"';
7678
return $this->shell->execute($enableModuleCommand);
7779
}
@@ -81,11 +83,12 @@ public function enableModule($moduleName)
8183
*
8284
* @param array $installParams
8385
* @return string
86+
* @throws LocalizedException
8487
*/
8588
public function upgrade($installParams = [])
8689
{
8790
$initParams = $this->parametersHolder->getInitParams();
88-
$upgradeCommand = 'php -f ' . BP . '/bin/magento setup:upgrade -vvv -n --magento-init-params="'
91+
$upgradeCommand = $this->getCliScriptCommandWithDI() . 'setup:upgrade -vvv -n --magento-init-params="'
8992
. $initParams['magento-init-params'] . '"';
9093
$installParams = $this->toCliArguments($installParams);
9194
$upgradeCommand .= ' ' . implode(" ", array_keys($installParams));
@@ -96,13 +99,14 @@ public function upgrade($installParams = [])
9699
/**
97100
* Execute disable module command.
98101
*
99-
* @param string $moduleName
102+
* @param string $moduleName
100103
* @return string
104+
* @throws LocalizedException
101105
*/
102106
public function disableModule($moduleName)
103107
{
104108
$initParams = $this->parametersHolder->getInitParams();
105-
$disableModuleCommand = 'php -f ' . BP . '/bin/magento module:disable '. $moduleName
109+
$disableModuleCommand = $this->getCliScriptCommand() . ' module:disable ' . $moduleName
106110
. ' -vvv --magento-init-params="' . $initParams['magento-init-params'] . '"';
107111
return $this->shell->execute($disableModuleCommand);
108112
}
@@ -111,14 +115,15 @@ public function disableModule($moduleName)
111115
* Split quote db configuration.
112116
*
113117
* @return void
118+
* @throws LocalizedException
114119
*/
115120
public function splitQuote()
116121
{
117122
$initParams = $this->parametersHolder->getInitParams();
118123
$installParams = $this->toCliArguments(
119124
$this->parametersHolder->getDbData('checkout')
120125
);
121-
$command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-quote ' .
126+
$command = $this->getCliScriptCommand() . ' setup:db-schema:split-quote ' .
122127
implode(" ", array_keys($installParams)) .
123128
' -vvv --magento-init-params="' .
124129
$initParams['magento-init-params'] . '"';
@@ -130,14 +135,15 @@ public function splitQuote()
130135
* Split sales db configuration.
131136
*
132137
* @return void
138+
* @throws LocalizedException
133139
*/
134140
public function splitSales()
135141
{
136142
$initParams = $this->parametersHolder->getInitParams();
137143
$installParams = $this->toCliArguments(
138144
$this->parametersHolder->getDbData('sales')
139145
);
140-
$command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-sales ' .
146+
$command = $this->getCliScriptCommand() . ' setup:db-schema:split-sales ' .
141147
implode(" ", array_keys($installParams)) .
142148
' -vvv --magento-init-params="' .
143149
$initParams['magento-init-params'] . '"';
@@ -151,7 +157,7 @@ public function splitSales()
151157
public function cacheClean()
152158
{
153159
$initParams = $this->parametersHolder->getInitParams();
154-
$command = 'php -f ' . BP . '/bin/magento cache:clean ' .
160+
$command = $this->getCliScriptCommand() . ' cache:clean ' .
155161
' -vvv --magento-init-params=' .
156162
$initParams['magento-init-params'];
157163

@@ -162,11 +168,12 @@ public function cacheClean()
162168
* Uninstall module
163169
*
164170
* @param string $moduleName
171+
* @throws LocalizedException
165172
*/
166173
public function uninstallModule($moduleName)
167174
{
168175
$initParams = $this->parametersHolder->getInitParams();
169-
$command = 'php -f ' . BP . '/bin/magento module:uninstall ' . $moduleName . ' --remove-data ' .
176+
$command = $this->getCliScriptCommand() . ' module:uninstall ' . $moduleName . ' --remove-data ' .
170177
' -vvv --non-composer --magento-init-params="' .
171178
$initParams['magento-init-params'] . '"';
172179

@@ -240,4 +247,29 @@ public function afterInstall()
240247
->get(DeploymentConfig::class);
241248
$this->deploymentConfig->resetData();
242249
}
250+
251+
/**
252+
* Get custom magento-cli command with additional DI configuration
253+
*
254+
* @return string
255+
*/
256+
private function getCliScriptCommandWithDI(): string
257+
{
258+
$params['MAGE_DIRS']['base']['path'] = BP;
259+
$params['INTEGRATION_TESTS_CLI_AUTOLOADER'] = TESTS_BASE_DIR . '/framework/autoload.php';
260+
$params['TESTS_BASE_DIR'] = TESTS_BASE_DIR;
261+
return 'INTEGRATION_TEST_PARAMS="' . urldecode(http_build_query($params)) . '"'
262+
. ' ' . PHP_BINARY . ' -f ' . INTEGRATION_TESTS_BASE_DIR
263+
. '/bin/magento ';
264+
}
265+
266+
/**
267+
* Get basic magento-cli command
268+
*
269+
* @return string
270+
*/
271+
private function getCliScriptCommand()
272+
{
273+
return PHP_BINARY . ' -f ' . BP . '/bin/magento ';
274+
}
243275
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestFramework\Mview;
9+
10+
/**
11+
* Stub for \Magento\Framework\Mview\TriggerCleaner
12+
*/
13+
class DummyTriggerCleaner
14+
{
15+
/**
16+
* Remove the outdated trigger from the system
17+
*
18+
* @return bool
19+
*/
20+
public function removeTriggers(): bool
21+
{
22+
return true;
23+
}
24+
}

0 commit comments

Comments
 (0)