PluginQrcodeTest.php 1.6 KB

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