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