Merge pull request #11010 from seamuslee001/CRM-21206
[civicrm-core.git] / tests / phpunit / CRM / Utils / SystemTest.php
CommitLineData
6a488035
TO
1<?php
2
aba1cd8b
EM
3/**
4 * Class CRM_Utils_SystemTest
acb109b7 5 * @group headless
aba1cd8b 6 */
6a488035
TO
7class CRM_Utils_SystemTest extends CiviUnitTestCase {
8
00be9182 9 public function setUp() {
6a488035
TO
10 parent::setUp();
11 }
12
00be9182 13 public function testUrlQueryString() {
6a488035
TO
14 $config = CRM_Core_Config::singleton();
15 $this->assertTrue($config->userSystem instanceof CRM_Utils_System_UnitTests);
16 $expected = '/index.php?q=civicrm/foo/bar&foo=ab&bar=cd%26ef';
6c6e6187 17 $actual = CRM_Utils_System::url('civicrm/foo/bar', 'foo=ab&bar=cd%26ef', FALSE, NULL, FALSE);
6a488035
TO
18 $this->assertEquals($expected, $actual);
19 }
b6708aeb 20
00be9182 21 public function testUrlQueryArray() {
6a488035
TO
22 $config = CRM_Core_Config::singleton();
23 $this->assertTrue($config->userSystem instanceof CRM_Utils_System_UnitTests);
24 $expected = '/index.php?q=civicrm/foo/bar&foo=ab&bar=cd%26ef';
25 $actual = CRM_Utils_System::url('civicrm/foo/bar', array(
26 'foo' => 'ab',
27 'bar' => 'cd&ef',
6c6e6187 28 ), FALSE, NULL, FALSE);
6a488035
TO
29 $this->assertEquals($expected, $actual);
30 }
efceedd4
TO
31
32 public function testEvalUrl() {
33 $this->assertEquals(FALSE, CRM_Utils_System::evalUrl(FALSE));
34 $this->assertEquals('http://example.com/', CRM_Utils_System::evalUrl('http://example.com/'));
35 $this->assertEquals('http://example.com/?cms=UnitTests', CRM_Utils_System::evalUrl('http://example.com/?cms={uf}'));
36 }
96025800 37
6a488035 38}