Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 3f8b857

Browse files
author
Oleksii Korshenko
authored
MAGETWO-82003: Ensure database is cleared/Magento reinstalled when TESTS_CLEANUP is enabled #11499
2 parents 6addbee + 4709276 commit 3f8b857

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ public function run()
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function install()
29+
public function install($cleanup)
3030
{
31+
if ($cleanup) {
32+
$this->cleanup();
33+
}
34+
3135
$installOptions = $this->getInstallConfig();
3236

3337
/* Install application */

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@
5858
);
5959

6060
if (defined('TESTS_MAGENTO_INSTALLATION') && TESTS_MAGENTO_INSTALLATION === 'enabled') {
61-
if (defined('TESTS_CLEANUP') && TESTS_CLEANUP === 'enabled') {
62-
$application->cleanup();
63-
}
64-
$application->install();
61+
$cleanup = (defined('TESTS_CLEANUP') && TESTS_CLEANUP === 'enabled');
62+
$application->install($cleanup);
6563
}
6664

6765
$bootstrap = new \Magento\TestFramework\Bootstrap(

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,11 @@ public function cleanup()
435435
/**
436436
* Install an application
437437
*
438+
* @param bool $cleanup
438439
* @return void
439440
* @throws \Magento\Framework\Exception\LocalizedException
440441
*/
441-
public function install()
442+
public function install($cleanup)
442443
{
443444
$dirs = \Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS;
444445
$this->_ensureDirExists($this->installDir);
@@ -453,8 +454,9 @@ public function install()
453454
$installParams = $this->getInstallCliParams();
454455

455456
// performance optimization: restore DB from last good dump to make installation on top of it (much faster)
457+
// do not restore from the database if the cleanup option is set to ensure we have a clean DB to test on
456458
$db = $this->getDbInstance();
457-
if ($db->isDbDumpExists()) {
459+
if ($db->isDbDumpExists() && !$cleanup) {
458460
$db->restoreFromDbDump();
459461
}
460462

dev/tests/integration/framework/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
$application->cleanup();
7575
}
7676
if (!$application->isInstalled()) {
77-
$application->install();
77+
$application->install($settings->getAsBoolean('TESTS_CLEANUP'));
7878
}
7979
$application->initialize([]);
8080

0 commit comments

Comments
 (0)