Skip to content

Commit eba13e4

Browse files
committed
MAGETWO-53858: Uncaught 'undefined property' notices in REST tests
1 parent f58a9f7 commit eba13e4

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
$integrationTestsDir = realpath("{$testsBaseDir}/../integration");
1515
$fixtureBaseDir = $integrationTestsDir . '/testsuite';
1616

17+
setCustomErrorHandler();
18+
1719
$logWriter = new \Zend_Log_Writer_Stream('php://output');
1820
$logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL));
1921
$logger = new \Zend_Log($logWriter);
@@ -102,3 +104,38 @@
102104
)
103105
);
104106
unset($bootstrap, $application, $settings, $shell);
107+
108+
/**
109+
* Set custom error handler
110+
*/
111+
function setCustomErrorHandler()
112+
{
113+
set_error_handler(
114+
function ($errNo, $errStr, $errFile, $errLine) {
115+
$errorNames = [
116+
E_ERROR => 'Error',
117+
E_WARNING => 'Warning',
118+
E_PARSE => 'Parse',
119+
E_NOTICE => 'Notice',
120+
E_CORE_ERROR => 'Core Error',
121+
E_CORE_WARNING => 'Core Warning',
122+
E_COMPILE_ERROR => 'Compile Error',
123+
E_COMPILE_WARNING => 'Compile Warning',
124+
E_USER_ERROR => 'User Error',
125+
E_USER_WARNING => 'User Warning',
126+
E_USER_NOTICE => 'User Notice',
127+
E_STRICT => 'Strict',
128+
E_RECOVERABLE_ERROR => 'Recoverable Error',
129+
E_DEPRECATED => 'Deprecated',
130+
E_USER_DEPRECATED => 'User Deprecated',
131+
];
132+
133+
$errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
134+
135+
throw new \PHPUnit_Framework_Exception(
136+
sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
137+
$errNo
138+
);
139+
}
140+
);
141+
}

dev/tests/integration/framework/bootstrap.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
}
1717

1818
try {
19+
setCustomErrorHandler();
20+
1921
/* Bootstrap the application */
2022
$settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
2123

@@ -89,3 +91,38 @@
8991
echo $e . PHP_EOL;
9092
exit(1);
9193
}
94+
95+
/**
96+
* Set custom error handler
97+
*/
98+
function setCustomErrorHandler()
99+
{
100+
set_error_handler(
101+
function ($errNo, $errStr, $errFile, $errLine) {
102+
$errorNames = [
103+
E_ERROR => 'Error',
104+
E_WARNING => 'Warning',
105+
E_PARSE => 'Parse',
106+
E_NOTICE => 'Notice',
107+
E_CORE_ERROR => 'Core Error',
108+
E_CORE_WARNING => 'Core Warning',
109+
E_COMPILE_ERROR => 'Compile Error',
110+
E_COMPILE_WARNING => 'Compile Warning',
111+
E_USER_ERROR => 'User Error',
112+
E_USER_WARNING => 'User Warning',
113+
E_USER_NOTICE => 'User Notice',
114+
E_STRICT => 'Strict',
115+
E_RECOVERABLE_ERROR => 'Recoverable Error',
116+
E_DEPRECATED => 'Deprecated',
117+
E_USER_DEPRECATED => 'User Deprecated',
118+
];
119+
120+
$errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
121+
122+
throw new \PHPUnit_Framework_Exception(
123+
sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
124+
$errNo
125+
);
126+
}
127+
);
128+
}

0 commit comments

Comments
 (0)