Skip to content

Commit 21aa619

Browse files
authored
Merge pull request #7040 from magento-arcticfoxes/B2B-1875
B2B-1875: Cannot import table rates CSV when S3 Remote Storage is enabled
2 parents 63100b3 + f4f8a54 commit 21aa619

File tree

9 files changed

+73
-30
lines changed

9 files changed

+73
-30
lines changed

app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ public function getConditionName(\Magento\Framework\DataObject $object)
321321
private function getCsvFile($filePath)
322322
{
323323
$pathInfo = pathinfo($filePath);
324-
$dirName = isset($pathInfo['dirname']) ? $pathInfo['dirname'] : '';
325-
$fileName = isset($pathInfo['basename']) ? $pathInfo['basename'] : '';
324+
$dirName = $pathInfo['dirname'] ?? '';
325+
$fileName = $pathInfo['basename'] ?? '';
326326

327-
$directoryRead = $this->filesystem->getDirectoryReadByPath($dirName);
327+
$directoryRead = $this->filesystem->getDirectoryReadByPath($dirName, Filesystem\DriverPool::FILE);
328328

329329
return $directoryRead->openFile($fileName);
330330
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
// List of bin/magento setup CLI commands to run after setup:install
8+
return [
9+
/*
10+
[
11+
'command' => 'setup:config:set',
12+
'config' => [
13+
'--remote-storage-driver' => 'aws-s3',
14+
'--remote-storage-bucket' => 'myBucket',
15+
'--remote-storage-region' => 'us-east-1',
16+
]
17+
]
18+
*/
19+
];

dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public function install($cleanup)
5050
}
5151
$this->_shell->execute($installCmd, $installArgs);
5252
}
53+
54+
$this->runPostInstallCommands();
5355
}
5456

5557
/**

dev/tests/api-functional/framework/bootstrap.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@
5050
if (!file_exists($installConfigFile)) {
5151
$installConfigFile = $installConfigFile . '.dist';
5252
}
53+
$postInstallConfigFile = $settings->getAsConfigFile('TESTS_POST_INSTALL_SETUP_COMMAND_CONFIG_FILE');
54+
if (!file_exists($postInstallConfigFile)) {
55+
$postInstallConfigFile = $postInstallConfigFile . '.dist';
56+
}
5357
$globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE');
54-
if (!file_exists($installConfigFile)) {
55-
$installConfigFile = $installConfigFile . '.dist';
58+
if (!file_exists($globalConfigFile)) {
59+
$globalConfigFile = $globalConfigFile . '.dist';
5660
}
5761
$dirList = new \Magento\Framework\App\Filesystem\DirectoryList(BP);
5862
$application = new \Magento\TestFramework\WebApiApplication(
@@ -62,7 +66,9 @@
6266
$globalConfigFile,
6367
BP . '/app/etc/',
6468
$settings->get('TESTS_MAGENTO_MODE'),
65-
AutoloaderRegistry::getAutoloader()
69+
AutoloaderRegistry::getAutoloader(),
70+
false,
71+
$postInstallConfigFile
6672
);
6773

6874
if (defined('TESTS_MAGENTO_INSTALLATION') && TESTS_MAGENTO_INSTALLATION === 'enabled') {

dev/tests/api-functional/phpunit_graphql.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
<php>
3131
<includePath>./testsuite</includePath>
3232
<const name="TESTS_INSTALL_CONFIG_FILE" value="config/install-config-mysql.php"/>
33+
<!-- Local XML post installation configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
34+
<const name="TESTS_POST_INSTALL_SETUP_COMMAND_CONFIG_FILE" value="config/post-install-setup-command-config.php"/>
3335
<const name="TESTS_GLOBAL_CONFIG_FILE" value="config/config-global.php"/>
3436
<!-- Webserver URL -->
3537
<const name="TESTS_BASE_URL" value="http://magento.url"/>

dev/tests/api-functional/phpunit_rest.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<php>
3333
<includePath>./testsuite</includePath>
3434
<const name="TESTS_INSTALL_CONFIG_FILE" value="config/install-config-mysql.php"/>
35+
<!-- Local XML post installation configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
36+
<const name="TESTS_POST_INSTALL_SETUP_COMMAND_CONFIG_FILE" value="config/post-install-setup-command-config.php"/>
3537
<const name="TESTS_GLOBAL_CONFIG_FILE" value="config/config-global.php"/>
3638
<!-- WebSerivice Type -->
3739
<const name="TESTS_WEB_API_ADAPTER" value="rest"/>

dev/tests/api-functional/phpunit_soap.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<php>
3333
<includePath>./testsuite</includePath>
3434
<const name="TESTS_INSTALL_CONFIG_FILE" value="config/install-config-mysql.php"/>
35+
<!-- Local XML post installation configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
36+
<const name="TESTS_POST_INSTALL_SETUP_COMMAND_CONFIG_FILE" value="config/post-install-setup-command-config.php"/>
3537
<const name="TESTS_GLOBAL_CONFIG_FILE" value="config/config-global.php"/>
3638
<!-- WebSerivice Type -->
3739
<const name="TESTS_WEB_API_ADAPTER" value="soap"/>

dev/tests/integration/framework/Magento/TestFramework/Application.php

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,39 @@ public function install($cleanup)
559559
array_merge([BP . '/bin/magento'], array_values($installParams))
560560
);
561561

562+
$this->runPostInstallCommands();
563+
564+
// enable only specified list of caches
565+
$initParamsQuery = $this->getInitParamsQuery();
566+
$this->_shell->execute(
567+
PHP_BINARY . ' -f %s cache:disable -vvv --bootstrap=%s',
568+
[BP . '/bin/magento', $initParamsQuery]
569+
);
570+
$this->_shell->execute(
571+
PHP_BINARY . ' -f %s cache:enable -vvv %s %s %s %s --bootstrap=%s',
572+
[
573+
BP . '/bin/magento',
574+
\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER,
575+
\Magento\Framework\App\Cache\Type\Layout::TYPE_IDENTIFIER,
576+
\Magento\Framework\App\Cache\Type\Translate::TYPE_IDENTIFIER,
577+
\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER,
578+
$initParamsQuery,
579+
]
580+
);
581+
582+
// right after a clean installation, store DB dump for future reuse in tests or running the test suite again
583+
if (!$db->isDbDumpExists() && $this->dumpDb) {
584+
$this->getDbInstance()->storeDbDump();
585+
}
586+
}
587+
588+
/**
589+
* Run commands after installation configured in post-install-setup-command-config.php
590+
*
591+
* @throws \Magento\Framework\Exception\LocalizedException
592+
*/
593+
protected function runPostInstallCommands()
594+
{
562595
// run post-install setup commands
563596
$postInstallSetupCommands = $this->getPostInstallSetupCommands();
564597

@@ -595,29 +628,6 @@ public function install($cleanup)
595628
),
596629
);
597630
}
598-
599-
// enable only specified list of caches
600-
$initParamsQuery = $this->getInitParamsQuery();
601-
$this->_shell->execute(
602-
PHP_BINARY . ' -f %s cache:disable -vvv --bootstrap=%s',
603-
[BP . '/bin/magento', $initParamsQuery]
604-
);
605-
$this->_shell->execute(
606-
PHP_BINARY . ' -f %s cache:enable -vvv %s %s %s %s --bootstrap=%s',
607-
[
608-
BP . '/bin/magento',
609-
\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER,
610-
\Magento\Framework\App\Cache\Type\Layout::TYPE_IDENTIFIER,
611-
\Magento\Framework\App\Cache\Type\Translate::TYPE_IDENTIFIER,
612-
\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER,
613-
$initParamsQuery,
614-
]
615-
);
616-
617-
// right after a clean installation, store DB dump for future reuse in tests or running the test suite again
618-
if (!$db->isDbDumpExists() && $this->dumpDb) {
619-
$this->getDbInstance()->storeDbDump();
620-
}
621631
}
622632

623633
/**

dev/tests/integration/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<ini name="xdebug.max_nesting_level" value="200"/>
5353
<!-- Local XML configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
5454
<const name="TESTS_INSTALL_CONFIG_FILE" value="etc/install-config-mysql.php"/>
55-
<!-- Local XML configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
55+
<!-- Local XML post installation configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
5656
<const name="TESTS_POST_INSTALL_SETUP_COMMAND_CONFIG_FILE" value="etc/post-install-setup-command-config.php"/>
5757
<!-- Local XML configuration file ('.dist' extension will be added, if the specified file doesn't exist) -->
5858
<const name="TESTS_GLOBAL_CONFIG_FILE" value="etc/config-global.php"/>

0 commit comments

Comments
 (0)