Fix manipulator tests

This commit is contained in:
Thibaud Fabre
2016-10-10 13:51:51 +02:00
parent 384982f40e
commit 7d39aa77d9

View File

@@ -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()
);
}
}