Ian province abbreviation patch - issue 724
[civicrm-core.git] / tests / phpunit / CRM / Utils / SystemTest.php
1 <?php
2
3 require_once 'CiviTest/CiviUnitTestCase.php';
4
5 /**
6 * Class CRM_Utils_SystemTest
7 */
8 class CRM_Utils_SystemTest extends CiviUnitTestCase {
9
10 public function setUp() {
11 parent::setUp();
12 }
13
14 public function testUrlQueryString() {
15 $config = CRM_Core_Config::singleton();
16 $this->assertTrue($config->userSystem instanceof CRM_Utils_System_UnitTests);
17 $expected = '/index.php?q=civicrm/foo/bar&foo=ab&bar=cd%26ef';
18 $actual = CRM_Utils_System::url('civicrm/foo/bar', 'foo=ab&bar=cd%26ef', FALSE, NULL, FALSE);
19 $this->assertEquals($expected, $actual);
20 }
21
22 public function testUrlQueryArray() {
23 $config = CRM_Core_Config::singleton();
24 $this->assertTrue($config->userSystem instanceof CRM_Utils_System_UnitTests);
25 $expected = '/index.php?q=civicrm/foo/bar&foo=ab&bar=cd%26ef';
26 $actual = CRM_Utils_System::url('civicrm/foo/bar', array(
27 'foo' => 'ab',
28 'bar' => 'cd&ef',
29 ), FALSE, NULL, FALSE);
30 $this->assertEquals($expected, $actual);
31 }
32
33 public function testEvalUrl() {
34 $this->assertEquals(FALSE, CRM_Utils_System::evalUrl(FALSE));
35 $this->assertEquals('http://example.com/', CRM_Utils_System::evalUrl('http://example.com/'));
36 $this->assertEquals('http://example.com/?cms=UnitTests', CRM_Utils_System::evalUrl('http://example.com/?cms={uf}'));
37 }
38
39 }