Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a9f1bac

Browse files
committed
Work around data provider issue
When testing without the ORM, the Events class does not exist and this causes an exception when executing the data provider.
1 parent 8338286 commit a9f1bac

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/DependencyInjection/Compiler/EntityListenerPassTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use stdClass;
1313
use Symfony\Component\DependencyInjection\ContainerBuilder;
1414

15+
use function class_exists;
1516
use function interface_exists;
1617

1718
class EntityListenerPassTest extends TestCase
@@ -59,6 +60,13 @@ public function testEntityListenersAreRegistered(string|null $event, string|null
5960
/** @return iterable<array{0: ?string, 1: ?string, 2: ?string}> */
6061
public static function provideEvents(): iterable
6162
{
63+
if (! class_exists(Events::class)) {
64+
// If ORM is not available, return fake data to make the data provider valid
65+
yield 'Without ORM' => [null, null, null];
66+
67+
return;
68+
}
69+
6270
yield 'With event and matching method' => [Events::prePersist, null, null];
6371
yield 'Without event' => [null, null, null];
6472
yield 'With event and custom method' => [Events::postLoad, 'postLoadHandler', 'postLoadHandler'];

0 commit comments

Comments
 (0)