Move PubSubHubbub code as a default plugin
This commit is contained in:
parent
085efc33cc
commit
db90dfcbbc
12 changed files with 183 additions and 38 deletions
tests
|
@ -75,7 +75,6 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase
|
|||
$data = $feedBuilder->buildData();
|
||||
// Test headers (RSS)
|
||||
$this->assertEquals(self::$RSS_LANGUAGE, $data['language']);
|
||||
$this->assertEmpty($data['pubsubhub_url']);
|
||||
$this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']);
|
||||
$this->assertEquals(true, $data['show_dates']);
|
||||
$this->assertEquals('http://host.tld/index.php?do=feed', $data['self_link']);
|
||||
|
@ -210,19 +209,6 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertTrue($data['show_dates']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildData with hide dates settings.
|
||||
*/
|
||||
public function testBuildDataPubsubhub()
|
||||
{
|
||||
$feedBuilder = new FeedBuilder(self::$linkDB, FeedBuilder::$FEED_ATOM, self::$serverInfo, null, false);
|
||||
$feedBuilder->setLocale(self::$LOCALE);
|
||||
$feedBuilder->setPubsubhubUrl('http://pubsubhub.io');
|
||||
$data = $feedBuilder->buildData();
|
||||
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links']));
|
||||
$this->assertEquals('http://pubsubhub.io', $data['pubsubhub_url']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildData when Shaarli is served from a subdirectory
|
||||
*/
|
||||
|
|
54
tests/plugins/PluginPubsubhubbubTest.php
Normal file
54
tests/plugins/PluginPubsubhubbubTest.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
|
||||
require_once 'application/Router.php';
|
||||
|
||||
/**
|
||||
* Class PluginPubsubhubbubTest
|
||||
* Unit test for the pubsubhubbub plugin
|
||||
*/
|
||||
class PluginPubsubhubbubTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var string Config file path (without extension).
|
||||
*/
|
||||
protected static $configFile = 'tests/utils/config/configJson';
|
||||
|
||||
/**
|
||||
* Reset plugin path
|
||||
*/
|
||||
function setUp()
|
||||
{
|
||||
PluginManager::$PLUGINS_PATH = 'plugins';
|
||||
}
|
||||
|
||||
/**
|
||||
* Test render_feed hook with an RSS feed.
|
||||
*/
|
||||
function testPubSubRssRenderFeed()
|
||||
{
|
||||
$hub = 'http://domain.hub';
|
||||
$conf = new ConfigManager(self::$configFile);
|
||||
$conf->set('plugins.PUBSUBHUB_URL', $hub);
|
||||
$data['_PAGE_'] = Router::$PAGE_FEED_RSS;
|
||||
|
||||
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
||||
$expected = '<atom:link rel="hub" href="'. $hub .'" />';
|
||||
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test render_feed hook with an ATOM feed.
|
||||
*/
|
||||
function testPubSubAtomRenderFeed()
|
||||
{
|
||||
$hub = 'http://domain.hub';
|
||||
$conf = new ConfigManager(self::$configFile);
|
||||
$conf->set('plugins.PUBSUBHUB_URL', $hub);
|
||||
$data['_PAGE_'] = Router::$PAGE_FEED_ATOM;
|
||||
|
||||
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
||||
$expected = '<link rel="hub" href="'. $hub .'" />';
|
||||
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue