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

Commit d558f53

Browse files
committed
Fix method signitures for PHPUnit test listener
1 parent 1412d2c commit d558f53

File tree

1 file changed

+31
-22
lines changed
  • dev/tests/integration/framework/Magento/TestFramework/Event

1 file changed

+31
-22
lines changed

dev/tests/integration/framework/Magento/TestFramework/Event/PhpUnit.php

+31-22
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,50 @@
99
*/
1010
namespace Magento\TestFramework\Event;
1111

12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\TestFramework\EventManager;
14+
use PHPUnit\Framework\AssertionFailedError;
15+
use PHPUnit\Framework\DataProviderTestSuite;
16+
use PHPUnit\Framework\Test;
17+
use PHPUnit\Framework\TestCase;
18+
use PHPUnit\Framework\TestSuite;
19+
use PHPUnit\Framework\Warning;
20+
1221
class PhpUnit implements \PHPUnit\Framework\TestListener
1322
{
1423
/**
1524
* Used when PHPUnit framework instantiates the class on its own and passes nothing to the constructor
1625
*
17-
* @var \Magento\TestFramework\EventManager
26+
* @var EventManager
1827
*/
1928
protected static $_defaultEventManager;
2029

2130
/**
22-
* @var \Magento\TestFramework\EventManager
31+
* @var EventManager
2332
*/
2433
protected $_eventManager;
2534

2635
/**
2736
* Assign default event manager instance
2837
*
29-
* @param \Magento\TestFramework\EventManager $eventManager
38+
* @param EventManager $eventManager
3039
*/
31-
public static function setDefaultEventManager(\Magento\TestFramework\EventManager $eventManager = null)
40+
public static function setDefaultEventManager(EventManager $eventManager = null): void
3241
{
3342
self::$_defaultEventManager = $eventManager;
3443
}
3544

3645
/**
3746
* Constructor
3847
*
39-
* @param \Magento\TestFramework\EventManager $eventManager
40-
* @throws \Magento\Framework\Exception\LocalizedException
48+
* @param EventManager $eventManager
49+
* @throws LocalizedException
4150
*/
42-
public function __construct(\Magento\TestFramework\EventManager $eventManager = null)
51+
public function __construct(EventManager $eventManager = null)
4352
{
4453
$this->_eventManager = $eventManager ?: self::$_defaultEventManager;
4554
if (!$this->_eventManager) {
46-
throw new \Magento\Framework\Exception\LocalizedException(__('Instance of the event manager is required.'));
55+
throw new LocalizedException(__('Instance of the event manager is required.'));
4756
}
4857
}
4958

@@ -52,7 +61,7 @@ public function __construct(\Magento\TestFramework\EventManager $eventManager =
5261
* @SuppressWarnings(PHPMD.ShortVariable)
5362
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5463
*/
55-
public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time)
64+
public function addError(Test $test, \Throwable $e, float $time): void
5665
{
5766
}
5867

@@ -61,7 +70,7 @@ public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time)
6170
* @SuppressWarnings(PHPMD.ShortVariable)
6271
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6372
*/
64-
public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, $time)
73+
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
6574
{
6675
}
6776

@@ -70,7 +79,7 @@ public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Ass
7079
* @SuppressWarnings(PHPMD.ShortVariable)
7180
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7281
*/
73-
public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
82+
public function addIncompleteTest(Test $test, \Throwable $e, float $time): void
7483
{
7584
}
7685

@@ -79,7 +88,7 @@ public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e,
7988
* @SuppressWarnings(PHPMD.ShortVariable)
8089
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
8190
*/
82-
public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
91+
public function addRiskyTest(Test $test, \Throwable $e, float $time): void
8392
{
8493
}
8594

@@ -88,17 +97,17 @@ public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time
8897
* @SuppressWarnings(PHPMD.ShortVariable)
8998
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
9099
*/
91-
public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
100+
public function addSkippedTest(Test $test, \Throwable $e, float $time): void
92101
{
93102
}
94103

95104
/**
96105
* {@inheritdoc}
97106
*/
98-
public function startTestSuite(\PHPUnit\Framework\TestSuite $suite)
107+
public function startTestSuite(TestSuite $suite): void
99108
{
100109
/* PHPUnit runs tests with data provider in own test suite for each test, so just skip such test suites */
101-
if ($suite instanceof \PHPUnit\Framework\DataProviderTestSuite) {
110+
if ($suite instanceof DataProviderTestSuite) {
102111
return;
103112
}
104113
$this->_eventManager->fireEvent('startTestSuite');
@@ -107,9 +116,9 @@ public function startTestSuite(\PHPUnit\Framework\TestSuite $suite)
107116
/**
108117
* {@inheritdoc}
109118
*/
110-
public function endTestSuite(\PHPUnit\Framework\TestSuite $suite)
119+
public function endTestSuite(TestSuite $suite): void
111120
{
112-
if ($suite instanceof \PHPUnit\Framework\DataProviderTestSuite) {
121+
if ($suite instanceof DataProviderTestSuite) {
113122
return;
114123
}
115124
$this->_eventManager->fireEvent('endTestSuite', [$suite], true);
@@ -118,9 +127,9 @@ public function endTestSuite(\PHPUnit\Framework\TestSuite $suite)
118127
/**
119128
* {@inheritdoc}
120129
*/
121-
public function startTest(\PHPUnit\Framework\Test $test)
130+
public function startTest(Test $test): void
122131
{
123-
if (!$test instanceof \PHPUnit\Framework\TestCase || $test instanceof \PHPUnit\Framework\Warning) {
132+
if (!$test instanceof TestCase || $test instanceof Warning) {
124133
return;
125134
}
126135
$this->_eventManager->fireEvent('startTest', [$test]);
@@ -130,9 +139,9 @@ public function startTest(\PHPUnit\Framework\Test $test)
130139
* {@inheritdoc}
131140
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
132141
*/
133-
public function endTest(\PHPUnit\Framework\Test $test, $time)
142+
public function endTest(Test $test, float $time): void
134143
{
135-
if (!$test instanceof \PHPUnit\Framework\TestCase || $test instanceof \PHPUnit\Framework\Warning) {
144+
if (!$test instanceof TestCase || $test instanceof Warning) {
136145
return;
137146
}
138147
$this->_eventManager->fireEvent('endTest', [$test], true);
@@ -141,7 +150,7 @@ public function endTest(\PHPUnit\Framework\Test $test, $time)
141150
/**
142151
* {@inheritdoc}
143152
*/
144-
public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, $time)
153+
public function addWarning(Test $test, Warning $e, float $time): void
145154
{
146155
}
147156
}

0 commit comments

Comments
 (0)