2016-08-02 11:55:49 +02:00
|
|
|
<?php
|
2018-12-04 23:17:23 +01:00
|
|
|
namespace Shaarli\Plugin\Pubsubhubbub;
|
|
|
|
|
2017-03-03 23:06:12 +01:00
|
|
|
use Shaarli\Config\ConfigManager;
|
2018-12-04 00:26:50 +01:00
|
|
|
use Shaarli\Plugin\PluginManager;
|
2020-07-06 08:04:35 +02:00
|
|
|
use Shaarli\Render\TemplatePage;
|
2016-08-02 11:55:49 +02:00
|
|
|
|
|
|
|
require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class PluginPubsubhubbubTest
|
|
|
|
* Unit test for the pubsubhubbub plugin
|
|
|
|
*/
|
2018-12-04 23:17:23 +01:00
|
|
|
class PluginPubsubhubbubTest extends \PHPUnit\Framework\TestCase
|
2016-08-02 11:55:49 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string Config file path (without extension).
|
|
|
|
*/
|
|
|
|
protected static $configFile = 'tests/utils/config/configJson';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset plugin path
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function setUp()
|
2016-08-02 11:55:49 +02:00
|
|
|
{
|
|
|
|
PluginManager::$PLUGINS_PATH = 'plugins';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test render_feed hook with an RSS feed.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testPubSubRssRenderFeed()
|
2016-08-02 11:55:49 +02:00
|
|
|
{
|
|
|
|
$hub = 'http://domain.hub';
|
|
|
|
$conf = new ConfigManager(self::$configFile);
|
|
|
|
$conf->set('plugins.PUBSUBHUB_URL', $hub);
|
2020-07-06 08:04:35 +02:00
|
|
|
$data['_PAGE_'] = TemplatePage::FEED_RSS;
|
2016-08-02 11:55:49 +02:00
|
|
|
|
|
|
|
$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.
|
|
|
|
*/
|
2017-01-05 19:33:06 +01:00
|
|
|
public function testPubSubAtomRenderFeed()
|
2016-08-02 11:55:49 +02:00
|
|
|
{
|
|
|
|
$hub = 'http://domain.hub';
|
|
|
|
$conf = new ConfigManager(self::$configFile);
|
|
|
|
$conf->set('plugins.PUBSUBHUB_URL', $hub);
|
2020-07-06 08:04:35 +02:00
|
|
|
$data['_PAGE_'] = TemplatePage::FEED_ATOM;
|
2016-08-02 11:55:49 +02:00
|
|
|
|
|
|
|
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
|
|
|
$expected = '<link rel="hub" href="'. $hub .'" />';
|
|
|
|
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
|
|
|
}
|
|
|
|
}
|