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