minor tidy ups
[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 /**
11 * @return array
12 */
13 function get_info() {
14 return array(
15 'name' => 'System Test',
16 'description' => 'Test system functions',
17 'group' => 'CiviCRM BAO Tests',
18 );
19 }
20
21 function setUp() {
22 parent::setUp();
23 }
24
25 function testUrlQueryString() {
26 $config = CRM_Core_Config::singleton();
27 $this->assertTrue($config->userSystem instanceof CRM_Utils_System_UnitTests);
28 $expected = '/index.php?q=civicrm/foo/bar&foo=ab&bar=cd%26ef';
29 $actual = CRM_Utils_System::url('civicrm/foo/bar', 'foo=ab&bar=cd%26ef', false, null, false);
30 $this->assertEquals($expected, $actual);
31 }
32
33 function testUrlQueryArray() {
34 $config = CRM_Core_Config::singleton();
35 $this->assertTrue($config->userSystem instanceof CRM_Utils_System_UnitTests);
36 $expected = '/index.php?q=civicrm/foo/bar&foo=ab&bar=cd%26ef';
37 $actual = CRM_Utils_System::url('civicrm/foo/bar', array(
38 'foo' => 'ab',
39 'bar' => 'cd&ef',
40 ), false, null, false);
41 $this->assertEquals($expected, $actual);
42 }
43
44 public function testEvalUrl() {
45 $this->assertEquals(FALSE, CRM_Utils_System::evalUrl(FALSE));
46 $this->assertEquals('http://example.com/', CRM_Utils_System::evalUrl('http://example.com/'));
47 $this->assertEquals('http://example.com/?cms=UnitTests', CRM_Utils_System::evalUrl('http://example.com/?cms={uf}'));
48 }
49 }