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