]>
Commit | Line | Data |
---|---|---|
db90dfcb | 1 | <?php |
95854417 V |
2 | namespace Shaarli\Plugin\Pubsubhubbub; |
3 | ||
3c66e564 | 4 | use Shaarli\Config\ConfigManager; |
e1850388 | 5 | use Shaarli\Plugin\PluginManager; |
1a8ac737 | 6 | use Shaarli\Render\TemplatePage; |
db90dfcb A |
7 | |
8 | require_once 'plugins/pubsubhubbub/pubsubhubbub.php'; | |
db90dfcb A |
9 | |
10 | /** | |
11 | * Class PluginPubsubhubbubTest | |
12 | * Unit test for the pubsubhubbub plugin | |
13 | */ | |
a5a9cf23 | 14 | class PluginPubsubhubbubTest extends \Shaarli\TestCase |
db90dfcb A |
15 | { |
16 | /** | |
17 | * @var string Config file path (without extension). | |
18 | */ | |
19 | protected static $configFile = 'tests/utils/config/configJson'; | |
20 | ||
21 | /** | |
22 | * Reset plugin path | |
23 | */ | |
8f60e120 | 24 | protected function setUp(): void |
db90dfcb A |
25 | { |
26 | PluginManager::$PLUGINS_PATH = 'plugins'; | |
27 | } | |
28 | ||
29 | /** | |
30 | * Test render_feed hook with an RSS feed. | |
31 | */ | |
93b1fe54 | 32 | public function testPubSubRssRenderFeed() |
db90dfcb A |
33 | { |
34 | $hub = 'http://domain.hub'; | |
35 | $conf = new ConfigManager(self::$configFile); | |
36 | $conf->set('plugins.PUBSUBHUB_URL', $hub); | |
1a8ac737 | 37 | $data['_PAGE_'] = TemplatePage::FEED_RSS; |
db90dfcb A |
38 | |
39 | $data = hook_pubsubhubbub_render_feed($data, $conf); | |
40 | $expected = '<atom:link rel="hub" href="'. $hub .'" />'; | |
41 | $this->assertEquals($expected, $data['feed_plugins_header'][0]); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Test render_feed hook with an ATOM feed. | |
46 | */ | |
93b1fe54 | 47 | public function testPubSubAtomRenderFeed() |
db90dfcb A |
48 | { |
49 | $hub = 'http://domain.hub'; | |
50 | $conf = new ConfigManager(self::$configFile); | |
51 | $conf->set('plugins.PUBSUBHUB_URL', $hub); | |
1a8ac737 | 52 | $data['_PAGE_'] = TemplatePage::FEED_ATOM; |
db90dfcb A |
53 | |
54 | $data = hook_pubsubhubbub_render_feed($data, $conf); | |
55 | $expected = '<link rel="hub" href="'. $hub .'" />'; | |
56 | $this->assertEquals($expected, $data['feed_plugins_header'][0]); | |
57 | } | |
58 | } |