From 7d39aa77d9708646559ebb9dc533a7cb693fbf70 Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Mon, 10 Oct 2016 13:51:51 +0200 Subject: [PATCH] Fix manipulator tests --- .../WebhookEventManipulatorTest.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php index 46948000f9..3d8c661580 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php @@ -4,6 +4,7 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Model\Manipulator\WebhookEventManipulator; use Alchemy\Phrasea\Model\Entities\WebhookEvent; +use Alchemy\Phrasea\Webhook\WebhookPublisher; /** * @group functional @@ -13,7 +14,7 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase { public function testCreate() { - $manipulator = new WebhookEventManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.webhook-delivery']); + $manipulator = $this->createManipulator(); $nbEvents = count(self::$DI['app']['repo.webhook-event']->findAll()); $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() @@ -23,7 +24,7 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase public function testDelete() { - $manipulator = new WebhookEventManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.webhook-event']); + $manipulator = $this->createManipulator(); $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() ]); @@ -34,7 +35,7 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase public function testUpdate() { - $manipulator = new WebhookEventManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.webhook-event']); + $manipulator = $this->createManipulator(); $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() ]); @@ -46,11 +47,23 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase public function testProcessed() { - $manipulator = new WebhookEventManipulator(self::$DI['app']['orm.em'], self::$DI['app']['repo.webhook-event']); + $manipulator = $this->createManipulator(); $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() ]); $manipulator->processed($event); $this->assertTrue($event->isProcessed()); } + + /** + * @return WebhookEventManipulator + */ + protected function createManipulator() + { + return new WebhookEventManipulator( + self::$DI['app']['orm.em'], + self::$DI['app']['repo.webhook-delivery'], + $this->prophesize(WebhookPublisher::class)->reveal() + ); + } }