(NFC) SettingsStack - Add test coverage for new helper
[civicrm-core.git] / tests / phpunit / Civi / Core / SettingsStackTest.php
1 <?php
2 namespace Civi\Core;
3
4 class SettingsStackTest extends \CiviUnitTestCase {
5
6 protected function setUp() {
7 parent::setUp();
8 $this->useTransaction(TRUE);
9 }
10
11 public function tearDown() {
12 parent::tearDown();
13 }
14
15 /**
16 * Temporarily modify -- then restore -- settings.
17 */
18 public function testStack() {
19 $origVal = \Civi::settings()->get('show_events');
20
21 $settingsStack = new \Civi\Core\SettingsStack();
22
23 $settingsStack->push('show_events', 9);
24 $this->assertEquals(9, \Civi::settings()->get('show_events'));
25
26 $settingsStack->push('show_events', 8);
27 $this->assertEquals(8, \Civi::settings()->get('show_events'));
28
29 $settingsStack->popAll();
30 $this->assertEquals($origVal, \Civi::settings()->get('show_events'));
31 }
32
33 }