Skip to content

Commit 60e35f5

Browse files
author
Sergii Kovalenko
committed
Merge branch 'MAGETWO-53858' into BUGS
2 parents 4943ef5 + f502455 commit 60e35f5

File tree

14 files changed

+207
-13
lines changed

14 files changed

+207
-13
lines changed

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

Lines changed: 39 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,40 @@
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+
if (error_reporting()) {
116+
$errorNames = [
117+
E_ERROR => 'Error',
118+
E_WARNING => 'Warning',
119+
E_PARSE => 'Parse',
120+
E_NOTICE => 'Notice',
121+
E_CORE_ERROR => 'Core Error',
122+
E_CORE_WARNING => 'Core Warning',
123+
E_COMPILE_ERROR => 'Compile Error',
124+
E_COMPILE_WARNING => 'Compile Warning',
125+
E_USER_ERROR => 'User Error',
126+
E_USER_WARNING => 'User Warning',
127+
E_USER_NOTICE => 'User Notice',
128+
E_STRICT => 'Strict',
129+
E_RECOVERABLE_ERROR => 'Recoverable Error',
130+
E_DEPRECATED => 'Deprecated',
131+
E_USER_DEPRECATED => 'User Deprecated',
132+
];
133+
134+
$errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
135+
136+
throw new \PHPUnit_Framework_Exception(
137+
sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
138+
$errNo
139+
);
140+
}
141+
}
142+
);
143+
}

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementCustomAttributesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function tearDown()
103103
$this->assertTrue($response);
104104
}
105105
}
106-
unset($this->accountManagement);
106+
$this->accountManagement = null;
107107
$mediaDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA);
108108
$mediaDirectory->delete(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER);
109109
}

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function setUp()
9494
*/
9595
public function tearDown()
9696
{
97-
unset($this->customerRepository);
97+
$this->customerRepository = null;
9898

9999
/** @var \Magento\Framework\Registry $registry */
100100
$registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry');

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ public function tearDown()
154154
$this->configValue
155155
);
156156
$this->config->save();
157-
unset($this->accountManagement);
158-
unset($this->subscriber);
157+
$this->accountManagement = null;
158+
$this->subscriber = null;
159159
}
160160

161-
private function initSubscriber() {
161+
private function initSubscriber()
162+
{
162163
$this->subscriber = Bootstrap::getObjectManager()->create(
163164
'Magento\Newsletter\Model\Subscriber'
164165
);

dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function tearDown()
139139
$this->assertTrue($response);
140140
}
141141
}
142-
unset($this->customerRepository);
142+
$this->customerRepository = null;
143143
}
144144

145145
/**

dev/tests/api-functional/testsuite/Magento/Integration/Model/IntegrationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class IntegrationTest extends \Magento\TestFramework\TestCase\WebapiAbstract
1313
/** @var \Magento\Integration\Model\Integration */
1414
protected $integration;
1515

16-
1716
protected function setUp()
1817
{
1918
$objectManager = Bootstrap::getObjectManager();
@@ -32,7 +31,7 @@ protected function setUp()
3231

3332
protected function tearDown()
3433
{
35-
unset($this->integration);
34+
$this->integration = null;
3635
OauthHelper::clearApiAccessCredentials();
3736
parent::tearDown();
3837
}

dev/tests/functional/bootstrap.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,42 @@
1212
require_once __DIR__ . '/../../../app/bootstrap.php';
1313
restore_error_handler();
1414
require_once __DIR__ . '/vendor/autoload.php';
15+
16+
setCustomErrorHandler();
17+
18+
/**
19+
* Set custom error handler
20+
*/
21+
function setCustomErrorHandler()
22+
{
23+
set_error_handler(
24+
function ($errNo, $errStr, $errFile, $errLine) {
25+
if (error_reporting()) {
26+
$errorNames = [
27+
E_ERROR => 'Error',
28+
E_WARNING => 'Warning',
29+
E_PARSE => 'Parse',
30+
E_NOTICE => 'Notice',
31+
E_CORE_ERROR => 'Core Error',
32+
E_CORE_WARNING => 'Core Warning',
33+
E_COMPILE_ERROR => 'Compile Error',
34+
E_COMPILE_WARNING => 'Compile Warning',
35+
E_USER_ERROR => 'User Error',
36+
E_USER_WARNING => 'User Warning',
37+
E_USER_NOTICE => 'User Notice',
38+
E_STRICT => 'Strict',
39+
E_RECOVERABLE_ERROR => 'Recoverable Error',
40+
E_DEPRECATED => 'Deprecated',
41+
E_USER_DEPRECATED => 'User Deprecated',
42+
];
43+
44+
$errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
45+
46+
throw new \PHPUnit_Framework_Exception(
47+
sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
48+
$errNo
49+
);
50+
}
51+
}
52+
);
53+
}

dev/tests/integration/framework/bootstrap.php

Lines changed: 39 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,40 @@
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+
if (error_reporting()) {
103+
$errorNames = [
104+
E_ERROR => 'Error',
105+
E_WARNING => 'Warning',
106+
E_PARSE => 'Parse',
107+
E_NOTICE => 'Notice',
108+
E_CORE_ERROR => 'Core Error',
109+
E_CORE_WARNING => 'Core Warning',
110+
E_COMPILE_ERROR => 'Compile Error',
111+
E_COMPILE_WARNING => 'Compile Warning',
112+
E_USER_ERROR => 'User Error',
113+
E_USER_WARNING => 'User Warning',
114+
E_USER_NOTICE => 'User Notice',
115+
E_STRICT => 'Strict',
116+
E_RECOVERABLE_ERROR => 'Recoverable Error',
117+
E_DEPRECATED => 'Deprecated',
118+
E_USER_DEPRECATED => 'User Deprecated',
119+
];
120+
121+
$errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
122+
123+
throw new \PHPUnit_Framework_Exception(
124+
sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
125+
$errNo
126+
);
127+
}
128+
}
129+
);
130+
}

dev/tests/integration/testsuite/Magento/Framework/Code/GeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function setUp()
6868
protected function tearDown()
6969
{
7070
$this->varDirectory->delete('generation');
71-
unset($this->_generator);
71+
$this->_generator = null;
7272
}
7373

7474
protected function _clearDocBlock($classBody)

dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterQueueTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function tearDown()
3333
)->getMessages(
3434
true
3535
);
36-
unset($this->_model);
36+
$this->_model = null;
3737
}
3838

3939
/**

0 commit comments

Comments
 (0)