From 6fc14d530369740d27d6bd641369d4f5f5f04080 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 15 Jul 2015 11:42:15 +0200 Subject: Plugin system - CORE see shaarli/Shaarli#275 --- tests/plugins/test/test.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 tests/plugins/test/test.php (limited to 'tests/plugins') diff --git a/tests/plugins/test/test.php b/tests/plugins/test/test.php new file mode 100755 index 00000000..3d750c90 --- /dev/null +++ b/tests/plugins/test/test.php @@ -0,0 +1,21 @@ + Date: Thu, 16 Jul 2015 13:53:39 +0200 Subject: Unit tests for Router and PluginManager. --- tests/plugins/test/test.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/plugins/test/test.php (limited to 'tests/plugins') diff --git a/tests/plugins/test/test.php b/tests/plugins/test/test.php old mode 100755 new mode 100644 -- cgit v1.2.3 From abb3ff38f5aea6231f981fd2e6d417f09de7a6e6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 7 Nov 2015 16:13:08 +0100 Subject: Add unit tests for the QRCode plugin + coding style --- tests/plugins/PlugQrcodeTest.php | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/plugins/PlugQrcodeTest.php (limited to 'tests/plugins') diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PlugQrcodeTest.php new file mode 100644 index 00000000..86dc7f29 --- /dev/null +++ b/tests/plugins/PlugQrcodeTest.php @@ -0,0 +1,67 @@ + $str, + 'links' => array( + array( + 'url' => $str, + ) + ) + ); + + $data = hook_qrcode_render_linklist($data); + $link = $data['links'][0]; + // data shouldn't be altered + $this->assertEquals($str, $data['title']); + $this->assertEquals($str, $link['url']); + + // plugin data + $this->assertEquals(1, count($link['link_plugin'])); + $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); + } + + /** + * Test render_footer hook. + */ + function testQrcodeFooter() + { + $str = 'stuff'; + $data = array($str => $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + + $data = hook_qrcode_render_footer($data); + $this->assertEquals($str, $data[$str]); + $this->assertEquals(1, count($data['js_files'])); + + $data = array($str => $str); + $data['_PAGE_'] = $str; + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('js_files', $data); + } +} -- cgit v1.2.3 From 840caea64f8c37f035fb3525f63153eb68492731 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 7 Nov 2015 16:30:56 +0100 Subject: Add unit tests for Playvideos plugin + coding style --- tests/plugins/PluginPlayvideosTest.php | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/plugins/PluginPlayvideosTest.php (limited to 'tests/plugins') diff --git a/tests/plugins/PluginPlayvideosTest.php b/tests/plugins/PluginPlayvideosTest.php new file mode 100644 index 00000000..be1ef774 --- /dev/null +++ b/tests/plugins/PluginPlayvideosTest.php @@ -0,0 +1,61 @@ + $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + + $data = hook_playvideos_render_header($data); + $this->assertEquals($str, $data[$str]); + $this->assertEquals(1, count($data['buttons_toolbar'])); + + $data = array($str => $str); + $data['_PAGE_'] = $str; + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('buttons_toolbar', $data); + } + + /** + * Test render_footer hook. + */ + function testPlayvideosFooter() + { + $str = 'stuff'; + $data = array($str => $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + + $data = hook_playvideos_render_footer($data); + $this->assertEquals($str, $data[$str]); + $this->assertEquals(2, count($data['js_files'])); + + $data = array($str => $str); + $data['_PAGE_'] = $str; + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('js_files', $data); + } +} -- cgit v1.2.3 From 9a364c283e3e9b5ccb5fc7a9a8e2946b1918c6a5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 7 Nov 2015 16:37:23 +0100 Subject: Add unit test for archiveorg plugin + coding style --- tests/plugins/PluginArchiveorgTest.php | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/plugins/PluginArchiveorgTest.php (limited to 'tests/plugins') diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php new file mode 100644 index 00000000..dbc52bc8 --- /dev/null +++ b/tests/plugins/PluginArchiveorgTest.php @@ -0,0 +1,48 @@ + $str, + 'links' => array( + array( + 'url' => $str, + ) + ) + ); + + $data = hook_archiveorg_render_linklist($data); + $link = $data['links'][0]; + // data shouldn't be altered + $this->assertEquals($str, $data['title']); + $this->assertEquals($str, $link['url']); + + // plugin data + $this->assertEquals(1, count($link['link_plugin'])); + $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); + } +} -- cgit v1.2.3 From ff5bda8238b1914ac80c45ffb3fcb910c4b4568c Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 8 Nov 2015 12:40:14 +0100 Subject: unit test for addlink_toolbar + coding style --- tests/plugins/PluginAddlinkTest.php | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/plugins/PluginAddlinkTest.php (limited to 'tests/plugins') diff --git a/tests/plugins/PluginAddlinkTest.php b/tests/plugins/PluginAddlinkTest.php new file mode 100644 index 00000000..a2f25bec --- /dev/null +++ b/tests/plugins/PluginAddlinkTest.php @@ -0,0 +1,100 @@ + $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + $data['_LOGGEDIN_'] = true; + + $data = hook_addlink_toolbar_render_header($data); + $this->assertEquals($str, $data[$str]); + $this->assertEquals(1, count($data['fields_toolbar'])); + + $data = array($str => $str); + $data['_PAGE_'] = $str; + $data['_LOGGEDIN_'] = true; + $data = hook_addlink_toolbar_render_header($data); + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('fields_toolbar', $data); + } + + /** + * Test render_header hook while logged out. + */ + function testAddlinkHeaderLoggedOut() + { + $str = 'stuff'; + $data = array($str => $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + $data['_LOGGEDIN_'] = false; + + $data = hook_addlink_toolbar_render_header($data); + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('fields_toolbar', $data); + } + + /** + * Test render_includes hook while logged in. + */ + function testAddlinkIncludesLoggedIn() + { + $str = 'stuff'; + $data = array($str => $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + $data['_LOGGEDIN_'] = true; + + $data = hook_addlink_toolbar_render_includes($data); + $this->assertEquals($str, $data[$str]); + $this->assertEquals(1, count($data['css_files'])); + + $str = 'stuff'; + $data = array($str => $str); + $data['_PAGE_'] = $str; + $data['_LOGGEDIN_'] = true; + + $data = hook_addlink_toolbar_render_includes($data); + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('css_files', $data); + } + + /** + * Test render_includes hook. + * Should not affect css files while logged out. + */ + function testAddlinkIncludesLoggedOut() + { + $str = 'stuff'; + $data = array($str => $str); + $data['_PAGE_'] = Router::$PAGE_LINKLIST; + $data['_LOGGEDIN_'] = false; + + $data = hook_addlink_toolbar_render_includes($data); + $this->assertEquals($str, $data[$str]); + $this->assertArrayNotHasKey('css_files', $data); + } +} -- cgit v1.2.3 From b11c8f25dfe3c684f2f39352e3acdeb660a069ac Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 8 Nov 2015 12:16:55 +0100 Subject: unit tests for readityourself plugin + remove hard error --- tests/plugins/PluginReadityourselfTest.php | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/plugins/PluginReadityourselfTest.php (limited to 'tests/plugins') diff --git a/tests/plugins/PluginReadityourselfTest.php b/tests/plugins/PluginReadityourselfTest.php new file mode 100644 index 00000000..8bf17bf1 --- /dev/null +++ b/tests/plugins/PluginReadityourselfTest.php @@ -0,0 +1,75 @@ + $str, + 'links' => array( + array( + 'url' => $str, + ) + ) + ); + + $data = hook_readityourself_render_linklist($data); + $link = $data['links'][0]; + // data shouldn't be altered + $this->assertEquals($str, $data['title']); + $this->assertEquals($str, $link['url']); + + // plugin data + $this->assertEquals(1, count($link['link_plugin'])); + $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); + } + + /** + * Test without config: nothing should happened. + */ + function testReadityourselfLinklistWithoutConfig() + { + unset($GLOBALS['plugins']['READITYOUSELF_URL']); + $str = 'http://randomstr.com/test'; + $data = array( + 'title' => $str, + 'links' => array( + array( + 'url' => $str, + ) + ) + ); + + $data = hook_readityourself_render_linklist($data); + $link = $data['links'][0]; + // data shouldn't be altered + $this->assertEquals($str, $data['title']); + $this->assertEquals($str, $link['url']); + + // plugin data + $this->assertArrayNotHasKey('link_plugin', $link); + } +} -- cgit v1.2.3 From 1696f6aa07734c7502702cf810c9fdc93532ef56 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 8 Nov 2015 12:00:06 +0100 Subject: unit tests for the wallabag plugin + removed exit error if the config is not found + coding style --- tests/plugins/PluginWallabagTest.php | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/plugins/PluginWallabagTest.php (limited to 'tests/plugins') diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php new file mode 100644 index 00000000..7cc83f4f --- /dev/null +++ b/tests/plugins/PluginWallabagTest.php @@ -0,0 +1,49 @@ + $str, + 'links' => array( + array( + 'url' => $str, + ) + ) + ); + + $data = hook_wallabag_render_linklist($data); + $link = $data['links'][0]; + // data shouldn't be altered + $this->assertEquals($str, $data['title']); + $this->assertEquals($str, $link['url']); + + // plugin data + $this->assertEquals(1, count($link['link_plugin'])); + $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); + } +} -- cgit v1.2.3