SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/tests/pageTest.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. use Sprout\Helpers\Page;
  15. use Sprout\Helpers\Pdb;
  16.  
  17.  
  18. class pageTest extends PHPUnit_Framework_TestCase
  19. {
  20.  
  21. public function testUrl()
  22. {
  23. $pages = Pdb::lookup('pages');
  24.  
  25. if (count($pages) === 0) {
  26. $this->markTestSkipped('Cannot test page URLs without any pages in the database');
  27. }
  28.  
  29. $integer = Page::url((int) key($pages));
  30. $this->assertTrue(is_string($integer));
  31.  
  32. $string = Page::url((string) key($pages));
  33. $this->assertTrue(is_string($string));
  34.  
  35. $this->assertTrue($integer == $string);
  36.  
  37. $url = Page::url(2362728);
  38. $this->assertTrue($url == 'page/view_by_id/2362728');
  39.  
  40. $url = Page::url('2362728');
  41. $this->assertTrue($url == 'page/view_by_id/2362728');
  42.  
  43. $url = Page::url('abcde');
  44. $this->assertNull($url);
  45.  
  46. $url = Page::url(array());
  47. $this->assertNull($url);
  48. }
  49.  
  50. }