|
62 | 62 | * * ssl_cipher - list of one or more permissible ciphers to use for SSL encryption (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher)
|
63 | 63 | * * databases - include more database configs and switch between them in tests.
|
64 | 64 | * * initial_queries - list of queries to be executed right after connection to the database has been initiated, i.e. creating the database if it does not exist or preparing the database collation
|
65 |
| - * |
| 65 | + * * skip_cleanup_if_failed - Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running |
66 | 66 | * ## Example
|
67 | 67 | *
|
68 | 68 | * modules:
|
|
76 | 76 | * cleanup: true
|
77 | 77 | * reconnect: true
|
78 | 78 | * waitlock: 10
|
| 79 | + * skip_cleanup_if_failed: true |
79 | 80 | * ssl_key: '/path/to/client-key.pem'
|
80 | 81 | * ssl_cert: '/path/to/client-cert.pem'
|
81 | 82 | * ssl_ca: '/path/to/ca-cert.pem'
|
@@ -260,6 +261,7 @@ class Db extends Module implements DbInterface
|
260 | 261 | 'waitlock' => 0,
|
261 | 262 | 'dump' => null,
|
262 | 263 | 'populator' => null,
|
| 264 | + 'skip_cleanup_if_failed' => false, |
263 | 265 | ];
|
264 | 266 |
|
265 | 267 | /**
|
@@ -635,6 +637,15 @@ public function _before(TestInterface $test): void
|
635 | 637 | parent::_before($test);
|
636 | 638 | }
|
637 | 639 |
|
| 640 | + public function _failed(TestInterface $test, $fail) |
| 641 | + { |
| 642 | + foreach ($this->getDatabases() as $databaseKey => $databaseConfig) { |
| 643 | + if ($databaseConfig['skip_cleanup_if_failed'] ?? false) { |
| 644 | + $this->insertedRows[$databaseKey] = []; |
| 645 | + } |
| 646 | + } |
| 647 | + } |
| 648 | + |
638 | 649 | public function _after(TestInterface $test): void
|
639 | 650 | {
|
640 | 651 | $this->removeInsertedForDatabases();
|
@@ -748,7 +759,8 @@ protected function loadDumpUsingDriver(string $databaseKey): void
|
748 | 759 | }
|
749 | 760 |
|
750 | 761 | /**
|
751 |
| - * Inserts an SQL record into a database. This record will be erased after the test. |
| 762 | + * Inserts an SQL record into a database. This record will be erased after the test, |
| 763 | + * unless you've configured "skip_cleanup_if_failed", and the test fails. |
752 | 764 | *
|
753 | 765 | * ```php
|
754 | 766 | * <?php
|
|
0 commit comments