forked from KnpLabs/DoctrineBehaviors
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make:entity dispatches event with incomplete argument
Resolves issue KnpLabs#481 by checking for a null reflection class pointer before using the pointer, in each of the event subscribers.
- Loading branch information
Edward Barnard
committed
Jan 19, 2020
1 parent
0259a78
commit 060fc53
Showing
9 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/vendor | ||
composer.lock | ||
|
||
.idea | ||
.phpunit.result.cache | ||
|
||
config/secrets/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Knp\DoctrineBehaviors\Tests\ORM; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
use Doctrine\ORM\Event\LoadClassMetadataEventArgs; | ||
use Doctrine\ORM\Events; | ||
use Doctrine\ORM\Mapping\ClassMetadata; | ||
use Knp\DoctrineBehaviors\Tests\AbstractBehaviorTestCase; | ||
|
||
/** | ||
* When console make:entity creates a new class, the event arguments are not fully populated | ||
* | ||
* This test emulates the event dispatch near the end of method | ||
* Doctrine\ORM\Mapping\ClassMetadataFactory::doLoadMetadata() | ||
* | ||
* @property EntityManager $entityManager | ||
*/ | ||
final class TimestampableMakeEntityTest extends AbstractBehaviorTestCase | ||
{ | ||
public function testMakeEntityEmptyEvent(): void | ||
{ | ||
$className = 'App\Entity\MyClass'; | ||
$class = new ClassMetadata($className); | ||
$eventArgs = new LoadClassMetadataEventArgs($class, $this->entityManager); | ||
$doctrineEventManager = $this->entityManager->getEventManager(); | ||
$doctrineEventManager->dispatchEvent(Events::loadClassMetadata, $eventArgs); | ||
$this->expectNotToPerformAssertions(); | ||
} | ||
|
||
protected function provideCustomConfig(): ?string | ||
{ | ||
return __DIR__ . '/../config/config_test_with_timestampable_entity.yaml'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
services: | ||
_defaults: | ||
public: true | ||
autowire: true | ||
|
||
Knp\DoctrineBehaviors\EventSubscriber\BlameableSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } | ||
Knp\DoctrineBehaviors\EventSubscriber\LoggableSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } | ||
Knp\DoctrineBehaviors\EventSubscriber\SluggableSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } | ||
Knp\DoctrineBehaviors\EventSubscriber\SoftDeletableSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } | ||
Knp\DoctrineBehaviors\EventSubscriber\TimestampableSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } | ||
Knp\DoctrineBehaviors\EventSubscriber\TreeSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } | ||
Knp\DoctrineBehaviors\EventSubscriber\UuidableSubscriber: | ||
tags: | ||
- { name: 'doctrine.event_subscriber' } |