Skip to content

Commit

Permalink
Demonstrate that listener is called
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Apr 30, 2024
1 parent 382da88 commit 731f5d3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Tests/ORM/Tools/SchemaToolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Doctrine\ORM\Mapping\UniqueConstraint;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs;
use Doctrine\ORM\Tools\Event\SchemaChangedEventArgs;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\ToolEvents;
use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver;
Expand Down Expand Up @@ -172,6 +173,26 @@ public function testPostGenerateEvents(): void
self::assertTrue($listener->schemaCalled);
}

public function testSchemaChangedEvent(): void
{
$em = $this->getTestEntityManager();

$schemaTool = new SchemaTool($em);

$listener = new class ()
{
public bool $called = false;

public function postSchemaChanged(SchemaChangedEventArgs $eventArgs): void
{
$this->called = true;
}
};
$em->getEventManager()->addEventListener(ToolEvents::postSchemaChanged, $listener);
$schemaTool->updateSchema([]);
self::assertTrue($listener->called);
}

public function testNullDefaultNotAddedToPlatformOptions(): void
{
$em = $this->getTestEntityManager();
Expand Down

0 comments on commit 731f5d3

Please sign in to comment.