Skip to content

Commit fa5dadc

Browse files
committed
Upgrade to phpunit 8
Fix library related to unit tests
1 parent 1116437 commit fa5dadc

File tree

2 files changed

+13
-84
lines changed

2 files changed

+13
-84
lines changed

lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,98 +5,23 @@
55
*/
66
namespace Magento\Framework\TestFramework\Unit\Listener;
77

8-
use PHPUnit\Framework\Test;
9-
use PHPUnit\Framework\Warning;
8+
use PHPUnit\Framework\TestListener;
9+
use PHPUnit\Framework\TestSuite;
1010

1111
/**
1212
* Listener of PHPUnit built-in events that enforces cleanup of cyclic object references
1313
*
1414
*/
15-
class GarbageCleanup implements \PHPUnit\Framework\TestListener
15+
class GarbageCleanup implements TestListener
1616
{
17-
/**
18-
* {@inheritdoc}
19-
* @SuppressWarnings(PHPMD.ShortVariable)
20-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
21-
*/
22-
public function addError(\PHPUnit\Framework\Test $test, \Exception $e, $time)
23-
{
24-
}
25-
26-
/**
27-
* {@inheritdoc}
28-
* @SuppressWarnings(PHPMD.ShortVariable)
29-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
30-
*/
31-
public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, $time)
32-
{
33-
}
34-
35-
/**
36-
* {@inheritdoc}
37-
* @SuppressWarnings(PHPMD.ShortVariable)
38-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
39-
*/
40-
public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
41-
{
42-
}
43-
44-
/**
45-
* {@inheritdoc}
46-
* @SuppressWarnings(PHPMD.ShortVariable)
47-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
48-
*/
49-
public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
50-
{
51-
}
52-
53-
/**
54-
* {@inheritdoc}
55-
* @SuppressWarnings(PHPMD.ShortVariable)
56-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
57-
*/
58-
public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time)
59-
{
60-
}
61-
62-
/**
63-
* {@inheritdoc}
64-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
65-
*/
66-
public function startTestSuite(\PHPUnit\Framework\TestSuite $suite)
67-
{
68-
}
17+
use \PHPUnit\Framework\TestListenerDefaultImplementation;
6918

7019
/**
7120
* {@inheritdoc}
7221
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7322
*/
74-
public function endTestSuite(\PHPUnit\Framework\TestSuite $suite)
23+
public function endTestSuite(TestSuite $suite): void
7524
{
7625
gc_collect_cycles();
7726
}
78-
79-
/**
80-
* {@inheritdoc}
81-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
82-
*/
83-
public function startTest(\PHPUnit\Framework\Test $test)
84-
{
85-
}
86-
87-
/**
88-
* {@inheritdoc}
89-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
90-
*/
91-
public function endTest(\PHPUnit\Framework\Test $test, $time)
92-
{
93-
}
94-
95-
/**
96-
* {@inheritdoc}
97-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
98-
*/
99-
public function addWarning(Test $test, Warning $e, $time)
100-
{
101-
}
10227
}

lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\ObjectManagerInterface;
10+
use PHPUnit\Framework\Test;
11+
use PHPUnit\Framework\TestCase;
12+
use PHPUnit\Framework\TestListener;
1013

1114
/**
1215
* The event listener which instantiates ObjectManager before test run
1316
*/
14-
class ReplaceObjectManager extends \PHPUnit\Framework\BaseTestListener
17+
class ReplaceObjectManager implements TestListener
1518
{
19+
use \PHPUnit\Framework\TestListenerDefaultImplementation;
1620
/**
1721
* Replaces ObjectManager before run for each test
1822
*
@@ -21,13 +25,13 @@ class ReplaceObjectManager extends \PHPUnit\Framework\BaseTestListener
2125
* This avoids the issue with a not initialized ObjectManager
2226
* and makes working with ObjectManager predictable as it always contains clear mock for each test
2327
*
24-
* @param \PHPUnit\Framework\Test $test
28+
* @param Test $test
2529
* @return void
2630
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2731
*/
28-
public function startTest(\PHPUnit\Framework\Test $test)
32+
public function startTest(Test $test): void
2933
{
30-
if ($test instanceof \PHPUnit\Framework\TestCase) {
34+
if ($test instanceof TestCase) {
3135
$objectManagerMock = $test->getMockBuilder(ObjectManagerInterface::class)
3236
->getMockForAbstractClass();
3337
$createMockCallback = function ($type) use ($test) {

0 commit comments

Comments
 (0)