mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add third party application webhook event
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Webhook;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
|
||||
use Alchemy\Phrasea\Webhook\EventProcessorFactory;
|
||||
|
||||
class EventProcessorFactoryTest extends \PhraseanetTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider eventProvider
|
||||
*/
|
||||
public function testGet($type, $expected)
|
||||
{
|
||||
$factory = new EventProcessorFactory(self::$DI['app']);
|
||||
$event = new WebhookEvent();
|
||||
$event->setType($type);
|
||||
$this->assertInstanceOf($expected, $factory->get($event));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testUnknownProcessor()
|
||||
{
|
||||
$factory = new EventProcessorFactory(self::$DI['app']);
|
||||
$event = new WebhookEvent();
|
||||
$factory->get($event);
|
||||
}
|
||||
|
||||
public function eventProvider()
|
||||
{
|
||||
return array(
|
||||
array(WebhookEvent::FEED_ENTRY_TYPE, 'Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor'),
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Webhook;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
|
||||
use Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor;
|
||||
|
||||
class FeedEntryProcessorTest extends \PhraseanetTestCase
|
||||
{
|
||||
|
||||
public function testProcessWithNoFeedId()
|
||||
{
|
||||
$event = new WebhookEvent();
|
||||
$event->setData(array(
|
||||
'feed_id' => 0,
|
||||
'entry_id' => 0
|
||||
));
|
||||
$event->setName(WebhookEvent::NEW_FEED_ENTRY);
|
||||
$event->setType(WebhookEvent::FEED_ENTRY_TYPE);
|
||||
$processor = new FeedEntryProcessor($event, self::$DI['app']);
|
||||
$this->assertEquals($processor->process(), null);
|
||||
}
|
||||
|
||||
public function testProcessWithMissingDataProperty()
|
||||
{
|
||||
$event = new WebhookEvent();
|
||||
$event->setData(array(
|
||||
'feed_id' => 0,
|
||||
));
|
||||
$event->setName(WebhookEvent::NEW_FEED_ENTRY);
|
||||
$event->setType(WebhookEvent::FEED_ENTRY_TYPE);
|
||||
$processor = new FeedEntryProcessor($event, self::$DI['app']);
|
||||
$this->assertEquals($processor->process(), null);
|
||||
}
|
||||
|
||||
|
||||
public function testProcess()
|
||||
{
|
||||
$event = new WebhookEvent();
|
||||
$event->setData(array(
|
||||
'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(),
|
||||
'entry_id' => self::$DI['feed_public_entry']->getId()
|
||||
));
|
||||
$event->setName(WebhookEvent::NEW_FEED_ENTRY);
|
||||
$event->setType(WebhookEvent::FEED_ENTRY_TYPE);
|
||||
$processor = new FeedEntryProcessor($event, self::$DI['app']);
|
||||
$this->assertEquals($processor->process(), null);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user