WallabagInstanceTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. require_once 'plugins/wallabag/WallabagInstance.php';
  3. /**
  4. * Class WallabagInstanceTest
  5. */
  6. class WallabagInstanceTest extends PHPUnit_Framework_TestCase
  7. {
  8. /**
  9. * @var string wallabag url.
  10. */
  11. private $instance;
  12. /**
  13. * Reset plugin path
  14. */
  15. public function setUp()
  16. {
  17. $this->instance = 'http://some.url';
  18. }
  19. /**
  20. * Test WallabagInstance with API V1.
  21. */
  22. public function testWallabagInstanceV1()
  23. {
  24. $instance = new WallabagInstance($this->instance, 1);
  25. $expected = $this->instance . '/?plainurl=';
  26. $result = $instance->getWallabagUrl();
  27. $this->assertEquals($expected, $result);
  28. }
  29. /**
  30. * Test WallabagInstance with API V2.
  31. */
  32. public function testWallabagInstanceV2()
  33. {
  34. $instance = new WallabagInstance($this->instance, 2);
  35. $expected = $this->instance . '/bookmarklet?url=';
  36. $result = $instance->getWallabagUrl();
  37. $this->assertEquals($expected, $result);
  38. }
  39. /**
  40. * Test WallabagInstance with an invalid API version.
  41. */
  42. public function testWallabagInstanceInvalidVersion()
  43. {
  44. $instance = new WallabagInstance($this->instance, false);
  45. $expected = $this->instance . '/?plainurl=';
  46. $result = $instance->getWallabagUrl();
  47. $this->assertEquals($expected, $result);
  48. $instance = new WallabagInstance($this->instance, 3);
  49. $expected = $this->instance . '/?plainurl=';
  50. $result = $instance->getWallabagUrl();
  51. $this->assertEquals($expected, $result);
  52. }
  53. }