Add third party application webhook event

This commit is contained in:
Nicolas Le Goff
2014-06-23 17:48:42 +02:00
parent 1645d914af
commit 0d040519f3
26 changed files with 1106 additions and 195 deletions

View File

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

View File

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