Skip to content

Commit b8abb27

Browse files
committed
Fix test for PHP 8
1 parent 3a29aa8 commit b8abb27

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/TestCase/ContainerTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types = 1);
4-
53
namespace Selective\Container\Test\TestCase;
64

75
use Exception;
@@ -289,11 +287,18 @@ public function testAutowireWithInvalidClasses(): void
289287
*/
290288
public function testAutowireWithInvalidInternalClass(): void
291289
{
292-
$this->expectException(InvalidDefinitionException::class);
293-
294290
$container = new Container();
295291
$container->addResolver(new ConstructorResolver($container));
296-
$container->get(Exception::class);
292+
293+
// https://3v4l.org/1AXpr
294+
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
295+
// PHP 8+
296+
$this->assertInstanceOf(Exception::class, $container->get(Exception::class));
297+
} else {
298+
// PHP 7.x
299+
$this->expectException(InvalidDefinitionException::class);
300+
$container->get(Exception::class);
301+
}
297302
}
298303

299304
/**

0 commit comments

Comments
 (0)