PluginWallabagTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * PluginWallabagTest.php.php
  4. */
  5. require_once 'plugins/wallabag/wallabag.php';
  6. /**
  7. * Class PluginWallabagTest
  8. * Unit test for the Wallabag plugin
  9. */
  10. class PluginWallabagTest extends PHPUnit_Framework_TestCase
  11. {
  12. /**
  13. * Reset plugin path
  14. */
  15. function setUp()
  16. {
  17. PluginManager::$PLUGINS_PATH = 'plugins';
  18. }
  19. /**
  20. * Test render_linklist hook.
  21. */
  22. function testWallabagLinklist()
  23. {
  24. $GLOBALS['plugins']['WALLABAG_URL'] = 'value';
  25. $str = 'http://randomstr.com/test';
  26. $data = array(
  27. 'title' => $str,
  28. 'links' => array(
  29. array(
  30. 'url' => $str,
  31. )
  32. )
  33. );
  34. $data = hook_wallabag_render_linklist($data);
  35. $link = $data['links'][0];
  36. // data shouldn't be altered
  37. $this->assertEquals($str, $data['title']);
  38. $this->assertEquals($str, $link['url']);
  39. // plugin data
  40. $this->assertEquals(1, count($link['link_plugin']));
  41. $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
  42. $this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL']));
  43. }
  44. }