Commit | Line | Data |
---|---|---|
01d70c56 TO |
1 | <?php |
2 | namespace Civi\Core; | |
3 | ||
4 | class CiviFacadeTest extends \CiviUnitTestCase { | |
5 | ||
6 | protected $origSetting; | |
7 | ||
8 | protected function setUp() { | |
9 | $this->origSetting = $GLOBALS['civicrm_setting']; | |
10 | ||
11 | parent::setUp(); | |
12 | $this->useTransaction(TRUE); | |
13 | ||
9099cab3 | 14 | $this->mandates = []; |
01d70c56 TO |
15 | } |
16 | ||
17 | public function tearDown() { | |
18 | $GLOBALS['civicrm_setting'] = $this->origSetting; | |
19 | parent::tearDown(); | |
20 | } | |
21 | ||
22 | /** | |
23 | * Get the the settingsbag for a logged-in user. | |
24 | */ | |
25 | public function testContactSettings_loggedIn() { | |
26 | $this->createLoggedInUser(); | |
27 | $settingsBag = \Civi::contactSettings(); | |
28 | $settingsBag->set('foo', 'bar'); | |
29 | $this->assertEquals('bar', $settingsBag->get('foo')); | |
30 | } | |
31 | ||
32 | /** | |
33 | * Anonymous users don't have a SettingsBag. | |
34 | * @expectedException \CRM_Core_Exception | |
35 | */ | |
36 | public function testContactSettings_anonFail() { | |
37 | \Civi::contactSettings(); | |
38 | } | |
39 | ||
40 | /** | |
41 | * Get the SettingsBag for a specific user. | |
42 | */ | |
43 | public function testContactSettings_byId() { | |
44 | $cid = \CRM_Core_DAO::singleValueQuery('SELECT MIN(id) FROM civicrm_contact'); | |
45 | $settingsBag = \Civi::contactSettings($cid); | |
46 | $settingsBag->set('foo', 'bar'); | |
47 | $this->assertEquals('bar', $settingsBag->get('foo')); | |
48 | } | |
49 | ||
50 | } |