]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | /** | |
3 | * PluginQrcodeTest.php | |
4 | */ | |
5 | ||
6 | use Shaarli\Router; | |
7 | ||
8 | require_once 'plugins/qrcode/qrcode.php'; | |
9 | require_once 'application/Router.php'; | |
10 | ||
11 | /** | |
12 | * Class PluginQrcodeTest | |
13 | * Unit test for the QR-Code plugin | |
14 | */ | |
15 | class PluginQrcodeTest extends PHPUnit_Framework_TestCase | |
16 | { | |
17 | /** | |
18 | * Reset plugin path | |
19 | */ | |
20 | public function setUp() | |
21 | { | |
22 | PluginManager::$PLUGINS_PATH = 'plugins'; | |
23 | } | |
24 | ||
25 | /** | |
26 | * Test render_linklist hook. | |
27 | */ | |
28 | public function testQrcodeLinklist() | |
29 | { | |
30 | $str = 'http://randomstr.com/test'; | |
31 | $data = array( | |
32 | 'title' => $str, | |
33 | 'links' => array( | |
34 | array( | |
35 | 'url' => $str, | |
36 | ) | |
37 | ) | |
38 | ); | |
39 | ||
40 | $data = hook_qrcode_render_linklist($data); | |
41 | $link = $data['links'][0]; | |
42 | // data shouldn't be altered | |
43 | $this->assertEquals($str, $data['title']); | |
44 | $this->assertEquals($str, $link['url']); | |
45 | ||
46 | // plugin data | |
47 | $this->assertEquals(1, count($link['link_plugin'])); | |
48 | $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); | |
49 | } | |
50 | ||
51 | /** | |
52 | * Test render_footer hook. | |
53 | */ | |
54 | public function testQrcodeFooter() | |
55 | { | |
56 | $str = 'stuff'; | |
57 | $data = array($str => $str); | |
58 | $data['_PAGE_'] = Router::$PAGE_LINKLIST; | |
59 | ||
60 | $data = hook_qrcode_render_footer($data); | |
61 | $this->assertEquals($str, $data[$str]); | |
62 | $this->assertEquals(1, count($data['js_files'])); | |
63 | ||
64 | $data = array($str => $str); | |
65 | $data['_PAGE_'] = $str; | |
66 | $this->assertEquals($str, $data[$str]); | |
67 | $this->assertArrayNotHasKey('js_files', $data); | |
68 | } | |
69 | } |