|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +declare(strict_types=1); |
6 | 7 |
|
7 | 8 | namespace tests\unit\Magento\FunctionalTestFramework\StaticCheck;
|
8 | 9 |
|
9 |
| -use AspectMock\Test as AspectMock; |
10 | 10 | use Magento\FunctionalTestingFramework\StaticCheck\AnnotationsCheck;
|
11 | 11 | use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
|
12 |
| -use tests\unit\Util\MagentoTestCase; |
13 | 12 | use ReflectionClass;
|
| 13 | +use tests\unit\Util\MagentoTestCase; |
14 | 14 |
|
15 | 15 | class AnnotationsCheckTest extends MagentoTestCase
|
16 | 16 | {
|
17 | 17 | /** @var AnnotationsCheck */
|
18 | 18 | private $staticCheck;
|
19 | 19 |
|
20 |
| - /** @var ReflectionClass*/ |
| 20 | + /** @var ReflectionClass */ |
21 | 21 | private $staticCheckClass;
|
22 | 22 |
|
23 | 23 | public function setUp(): void
|
24 | 24 | {
|
25 | 25 | $this->staticCheck = new AnnotationsCheck();
|
26 |
| - $this->staticCheckClass = new \ReflectionClass($this->staticCheck); |
27 |
| - } |
28 |
| - |
29 |
| - public function tearDown(): void |
30 |
| - { |
31 |
| - AspectMock::clean(); |
| 26 | + $this->staticCheckClass = new ReflectionClass($this->staticCheck); |
32 | 27 | }
|
33 | 28 |
|
34 | 29 | public function testValidateRequiredAnnotationsNoError()
|
@@ -56,11 +51,9 @@ public function testValidateRequiredAnnotationsNoError()
|
56 | 51 | ];
|
57 | 52 | $expected = [];
|
58 | 53 |
|
59 |
| - // mock test object |
60 |
| - $test = AspectMock::double( |
61 |
| - TestObject::class, |
62 |
| - ['getAnnotations' => $annotations, 'getName' => 'AnnotationsCheckTest'] |
63 |
| - )->make(); |
| 54 | + $test = $this->createMock(TestObject::class); |
| 55 | + |
| 56 | + $test->expects($this->once())->method('getAnnotations')->willReturn($annotations); |
64 | 57 |
|
65 | 58 | $validateRequiredAnnotations = $this->staticCheckClass->getMethod('validateRequiredAnnotations');
|
66 | 59 | $validateRequiredAnnotations->setAccessible(true);
|
@@ -99,11 +92,10 @@ public function testValidateRequiredAnnotationsMissing()
|
99 | 92 | ]
|
100 | 93 | ];
|
101 | 94 |
|
102 |
| - // mock test object |
103 |
| - $test = AspectMock::double( |
104 |
| - TestObject::class, |
105 |
| - ['getAnnotations' => $annotations, 'getName' => 'AnnotationsCheckTest'] |
106 |
| - )->make(); |
| 95 | + $test = $this->createMock(TestObject::class); |
| 96 | + |
| 97 | + $test->expects($this->once())->method('getAnnotations')->willReturn($annotations); |
| 98 | + $test->expects($this->once())->method('getName')->willReturn('AnnotationsCheckTest'); |
107 | 99 |
|
108 | 100 | $validateRequiredAnnotations = $this->staticCheckClass->getMethod('validateRequiredAnnotations');
|
109 | 101 | $validateRequiredAnnotations->setAccessible(true);
|
@@ -137,11 +129,10 @@ public function testValidateRequiredAnnotationsMissingNoTestCaseId()
|
137 | 129 | ]
|
138 | 130 | ];
|
139 | 131 |
|
140 |
| - // mock test object |
141 |
| - $test = AspectMock::double( |
142 |
| - TestObject::class, |
143 |
| - ['getAnnotations' => $annotations, 'getName' => 'AnnotationsCheckTest'] |
144 |
| - )->make(); |
| 132 | + $test = $this->createMock(TestObject::class); |
| 133 | + |
| 134 | + $test->expects($this->once())->method('getAnnotations')->willReturn($annotations); |
| 135 | + $test->expects($this->once())->method('getName')->willReturn('AnnotationsCheckTest'); |
145 | 136 |
|
146 | 137 | $validateRequiredAnnotations = $this->staticCheckClass->getMethod('validateRequiredAnnotations');
|
147 | 138 | $validateRequiredAnnotations->setAccessible(true);
|
@@ -179,11 +170,10 @@ public function testValidateRequiredAnnotationsEmpty()
|
179 | 170 | ]
|
180 | 171 | ];
|
181 | 172 |
|
182 |
| - // mock test object |
183 |
| - $test = AspectMock::double( |
184 |
| - TestObject::class, |
185 |
| - ['getAnnotations' => $annotations, 'getName' => 'AnnotationsCheckTest'] |
186 |
| - )->make(); |
| 173 | + $test = $this->createMock(TestObject::class); |
| 174 | + |
| 175 | + $test->expects($this->once())->method('getAnnotations')->willReturn($annotations); |
| 176 | + $test->expects($this->once())->method('getName')->willReturn('AnnotationsCheckTest'); |
187 | 177 |
|
188 | 178 | $validateRequiredAnnotations = $this->staticCheckClass->getMethod('validateRequiredAnnotations');
|
189 | 179 | $validateRequiredAnnotations->setAccessible(true);
|
|
0 commit comments