Skip to content

Commit

Permalink
Merge pull request #59 from saifulferoz/feature/increase-test-coverage
Browse files Browse the repository at this point in the history
test: increase test coverage
  • Loading branch information
ronisaha authored Oct 18, 2024
2 parents fa88673 + 6a683d2 commit 55bd969
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build:
image: default-bionic
nodes:
analysis:
tests:
Expand Down
14 changes: 7 additions & 7 deletions Tests/Subscriber/DoctrineSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Xiidea\EasyAuditBundle\Subscriber\DoctrineSubscriber;
use Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\DummyEntity;
use Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie;
use Doctrine\Persistence\ObjectManager;

Expand Down Expand Up @@ -52,7 +53,7 @@ public function testCreateEventForAttributedEntity()
public function testCreateEventForEntityNotConfiguredToTrack()
{
$subscriber = new DoctrineSubscriber(array());
$this->invokeCreatedEventCall($subscriber);
$this->invokeCreatedEventCall($subscriber, new DummyEntity());
}

public function testCreateEventForEntityConfiguredToTrack()
Expand All @@ -66,7 +67,6 @@ public function testCreateEventForEntityConfiguredToTrack()

public function testCreateEventForEntityConfiguredToTrackAllEvents()
{

$subscriber = new DoctrineSubscriber(array('Xiidea\EasyAuditBundle\Tests\Fixtures\ORM\Movie' => array()));

$this->invokeCreatedEventCall($subscriber);
Expand All @@ -75,7 +75,7 @@ public function testCreateEventForEntityConfiguredToTrackAllEvents()
public function testUpdateEventForEntityNotConfiguredToTrack()
{
$subscriber = new DoctrineSubscriber(array());
$this->invokeUpdatedEventCall($subscriber);
$this->invokeUpdatedEventCall($subscriber, new DummyEntity());
}

public function testRemovedEventForEntityNotConfiguredToTrack()
Expand All @@ -95,21 +95,21 @@ public function testRemovedEventForEntityConfiguredToTrackAllEvent()
/**
* @param DoctrineSubscriber $subscriber
*/
private function invokeCreatedEventCall($subscriber)
private function invokeCreatedEventCall($subscriber, $entity = null)
{
$subscriber->setDispatcher($this->dispatcher);
$subscriber->postPersist(new LifecycleEventArgs(new Movie(), $this->entityManager));
$subscriber->postPersist(new LifecycleEventArgs($entity ?? new Movie(), $this->entityManager));
$this->assertTrue(true);
}

/**
* @param DoctrineSubscriber $subscriber
*/
private function invokeUpdatedEventCall($subscriber)
private function invokeUpdatedEventCall($subscriber, $entity = null)
{
$subscriber->setDispatcher($this->dispatcher);

$subscriber->postUpdate(new LifecycleEventArgs(new Movie(), $this->entityManager));
$subscriber->postUpdate(new LifecycleEventArgs($entity ?? new Movie(), $this->entityManager));
$this->assertTrue(true);
}

Expand Down

0 comments on commit 55bd969

Please sign in to comment.