aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/PluginPubsubhubbubTest.php
blob: d30c370328df5042f713fb8fe9f3290e31d678a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Shaarli\Plugin\Pubsubhubbub;

use Shaarli\Config\ConfigManager;
use Shaarli\Plugin\PluginManager;
use Shaarli\Render\TemplatePage;

require_once 'plugins/pubsubhubbub/pubsubhubbub.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
     */
    protected function setUp(): void
    {
        PluginManager::$PLUGINS_PATH = 'plugins';
    }

    /**
     * Test render_feed hook with an RSS feed.
     */
    public function testPubSubRssRenderFeed()
    {
        $hub = 'http://domain.hub';
        $conf = new ConfigManager(self::$configFile);
        $conf->set('plugins.PUBSUBHUB_URL', $hub);
        $data['_PAGE_'] = TemplatePage::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.
     */
    public function testPubSubAtomRenderFeed()
    {
        $hub = 'http://domain.hub';
        $conf = new ConfigManager(self::$configFile);
        $conf->set('plugins.PUBSUBHUB_URL', $hub);
        $data['_PAGE_'] = TemplatePage::FEED_ATOM;

        $data = hook_pubsubhubbub_render_feed($data, $conf);
        $expected = '<link rel="hub" href="'. $hub .'" />';
        $this->assertEquals($expected, $data['feed_plugins_header'][0]);
    }
}