|
4 | 4 | * See COPYING.txt for license details. |
5 | 5 | */ |
6 | 6 |
|
| 7 | +namespace Magento\TestFramework\Event; |
| 8 | + |
7 | 9 | /** |
8 | 10 | * Database transaction events manager |
9 | 11 | */ |
10 | | -namespace Magento\TestFramework\Event; |
11 | | - |
12 | 12 | class Transaction |
13 | 13 | { |
14 | 14 | /** |
@@ -86,14 +86,29 @@ protected function _processTransactionRequests($eventName, \PHPUnit\Framework\Te |
86 | 86 | * Start transaction and fire 'startTransaction' event |
87 | 87 | * |
88 | 88 | * @param \PHPUnit\Framework\TestCase $test |
| 89 | + * @SuppressWarnings(PHPMD.UnusedLocalVariable) |
89 | 90 | */ |
90 | 91 | protected function _startTransaction(\PHPUnit\Framework\TestCase $test) |
91 | 92 | { |
92 | 93 | if (!$this->_isTransactionActive) { |
93 | 94 | $this->_getConnection()->beginTransparentTransaction(); |
94 | 95 | $this->_isTransactionActive = true; |
95 | 96 | try { |
| 97 | + /** |
| 98 | + * Add any warning during transaction execution as a failure. |
| 99 | + */ |
| 100 | + set_error_handler( |
| 101 | + function ($errNo, $errStr, $errFile, $errLine) use ($test) { |
| 102 | + $errMsg = sprintf("%s: %s in %s:%s.", "Warning", $errStr, $errFile, $errLine); |
| 103 | + $test->getTestResultObject()->addError($test, new \PHPUnit\Framework\Warning($errMsg), 0); |
| 104 | + |
| 105 | + // Allow error to be handled by next error handler |
| 106 | + return false; |
| 107 | + }, |
| 108 | + E_WARNING |
| 109 | + ); |
96 | 110 | $this->_eventManager->fireEvent('startTransaction', [$test]); |
| 111 | + restore_error_handler(); |
97 | 112 | } catch (\Exception $e) { |
98 | 113 | $test->getTestResultObject()->addFailure( |
99 | 114 | $test, |
|
0 commit comments