PluginQrcodeTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. {
  18. PluginManager::$PLUGINS_PATH = 'plugins';
  19. }
  20. /**
  21. * Test render_linklist hook.
  22. */
  23. public function testQrcodeLinklist()
  24. {
  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_qrcode_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], $str));
  42. }
  43. /**
  44. * Test render_footer hook.
  45. */
  46. public function testQrcodeFooter()
  47. {
  48. $str = 'stuff';
  49. $data = array($str => $str);
  50. $data['_PAGE_'] = Router::$PAGE_LINKLIST;
  51. $data = hook_qrcode_render_footer($data);
  52. $this->assertEquals($str, $data[$str]);
  53. $this->assertEquals(1, count($data['js_files']));
  54. $data = array($str => $str);
  55. $data['_PAGE_'] = $str;
  56. $this->assertEquals($str, $data[$str]);
  57. $this->assertArrayNotHasKey('js_files', $data);
  58. }
  59. }