1717use PHPUnit \Framework \MockObject \MockObject ;
1818use PHPUnit \Framework \TestCase ;
1919use Xiidea \EasyAuditBundle \Subscriber \DoctrineSubscriber ;
20- use Xiidea \EasyAuditBundle \Tests \Fixtures \ORM \DummyEntity ;
20+ use Xiidea \EasyAuditBundle \Tests \Fixtures \ORM \Book ;
21+ use Xiidea \EasyAuditBundle \Tests \Fixtures \ORM \Machine ;
2122use Xiidea \EasyAuditBundle \Tests \Fixtures \ORM \Movie ;
22- use Xiidea \EasyAuditBundle \Tests \Fixtures \ORM \TestMovie ;
2323
2424class DoctrineSubscriberTest extends TestCase
2525{
2626 /** @var MockObject */
2727 private $ dispatcher ;
2828
29-
3029 /** @var MockObject */
3130 private $ entityManager ;
3231
@@ -46,74 +45,79 @@ public function setUp(): void
4645
4746 public function testCreateEventForAttributedEntity ()
4847 {
49- $ subscriber = new DoctrineSubscriber (array () );
48+ $ subscriber = new DoctrineSubscriber ([] );
5049
5150 $ this ->invokeCreatedEventCall ($ subscriber );
51+ $ this ->assertTrue (true );
5252 }
5353
5454 public function testCreateEventForEntityNotConfiguredToTrack ()
5555 {
56- $ subscriber = new DoctrineSubscriber (array ());
57- $ this ->invokeCreatedEventCall ($ subscriber , new DummyEntity ());
56+ $ subscriber = new DoctrineSubscriber ([]);
57+ $ this ->invokeCreatedEventCall ($ subscriber );
58+ $ this ->assertTrue (true );
5859 }
5960
6061 public function testCreateEventForEntityConfiguredToTrack ()
6162 {
62- $ subscriber = new DoctrineSubscriber (
63- array ('Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie ' => array ('created ' ))
64- );
63+ $ subscriber = new DoctrineSubscriber (['Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie ' => ['created ' ]]);
6564
6665 $ this ->invokeCreatedEventCall ($ subscriber );
66+ $ this ->assertTrue (true );
6767 }
6868
6969 public function testCreateEventForEntityConfiguredToTrackAllEvents ()
7070 {
71- $ subscriber = new DoctrineSubscriber (array ( 'Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie ' => array ()) );
71+ $ subscriber = new DoctrineSubscriber ([ 'Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie ' => []] );
7272
7373 $ this ->invokeCreatedEventCall ($ subscriber );
74- $ this ->invokeCreatedEventCall ( $ subscriber , new TestMovie () );
74+ $ this ->assertTrue ( true );
7575 }
7676
7777 public function testUpdateEventForEntityNotConfiguredToTrack ()
7878 {
79- $ subscriber = new DoctrineSubscriber (array () );
80- $ this ->invokeUpdatedEventCall ($ subscriber, new DummyEntity () );
81- $ this ->invokeUpdatedEventCall ( $ subscriber , new TestMovie () );
79+ $ subscriber = new DoctrineSubscriber ([] );
80+ $ this ->invokeUpdatedEventCall ($ subscriber );
81+ $ this ->assertTrue ( true );
8282 }
8383
8484 public function testRemovedEventForEntityNotConfiguredToTrack ()
8585 {
86- $ subscriber = new DoctrineSubscriber (array () );
86+ $ subscriber = new DoctrineSubscriber ([] );
8787 $ this ->invokeDeletedEventCall ($ subscriber );
88+ $ this ->assertTrue (true );
8889 }
8990
9091 public function testRemovedEventForEntityConfiguredToTrackAllEvent ()
9192 {
9293 $ this ->mockMetaData ();
93- $ subscriber = new DoctrineSubscriber (array ( 'Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie ' => array ()) );
94+ $ subscriber = new DoctrineSubscriber ([ 'Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie ' => []] );
9495 $ this ->invokeDeletedEventCall ($ subscriber );
96+ $ this ->assertTrue (true );
9597 }
9698
9799
98100 /**
99101 * @param DoctrineSubscriber $subscriber
100102 */
101- private function invokeCreatedEventCall ($ subscriber, $ entity = null )
103+ private function invokeCreatedEventCall ($ subscriber )
102104 {
103105 $ subscriber ->setDispatcher ($ this ->dispatcher );
104- $ subscriber ->postPersist (new LifecycleEventArgs ($ entity ?? new Movie (), $ this ->entityManager ));
106+
107+ $ subscriber ->postPersist (new LifecycleEventArgs (new Movie (), $ this ->entityManager ));
108+ $ subscriber ->postPersist (new LifecycleEventArgs (new Machine (), $ this ->entityManager ));
105109 $ this ->assertTrue (true );
106110 }
107111
108112 /**
109113 * @param DoctrineSubscriber $subscriber
110114 */
111- private function invokeUpdatedEventCall ($ subscriber, $ entity = null )
115+ private function invokeUpdatedEventCall ($ subscriber )
112116 {
113117 $ subscriber ->setDispatcher ($ this ->dispatcher );
114118
115- $ subscriber ->postUpdate (new LifecycleEventArgs ($ entity ?? new Movie (), $ this ->entityManager ));
116- $ this -> assertTrue ( true );
119+ $ subscriber ->postUpdate (new LifecycleEventArgs (new Book (), $ this ->entityManager ));
120+ $ subscriber -> postUpdate ( new LifecycleEventArgs ( new Machine (), $ this -> entityManager ) );
117121 }
118122
119123 /**
@@ -122,11 +126,11 @@ private function invokeUpdatedEventCall($subscriber, $entity = null)
122126 private function invokeDeletedEventCall ($ subscriber )
123127 {
124128 $ subscriber ->setDispatcher ($ this ->dispatcher );
129+
125130 $ movie = new Movie ();
126131 $ subscriber ->preRemove (new LifecycleEventArgs ($ movie , $ this ->entityManager ));
127132 $ subscriber ->postRemove (new LifecycleEventArgs ($ movie , $ this ->entityManager ));
128133 $ this ->assertTrue (true );
129- $ subscriber ->postRemove (new LifecycleEventArgs (new TestMovie (), $ this ->entityManager ));
130134 }
131135
132136 private function mockMetaData ($ data = ['id ' => 1 ])
0 commit comments