-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(NFC) SettingsStack - Add test coverage for new helper
This class was recently added as a helper for another unit-test, but it didn't have its own coverage. This is a quick/simple test for it.
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace Civi\Core; | ||
|
||
class SettingsStackTest extends \CiviUnitTestCase { | ||
|
||
protected function setUp() { | ||
parent::setUp(); | ||
$this->useTransaction(TRUE); | ||
} | ||
|
||
public function tearDown() { | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* Temporarily modify -- then restore -- settings. | ||
*/ | ||
public function testStack() { | ||
$origVal = \Civi::settings()->get('show_events'); | ||
|
||
$settingsStack = new \Civi\Core\SettingsStack(); | ||
|
||
$settingsStack->push('show_events', 9); | ||
$this->assertEquals(9, \Civi::settings()->get('show_events')); | ||
|
||
$settingsStack->push('show_events', 8); | ||
$this->assertEquals(8, \Civi::settings()->get('show_events')); | ||
|
||
$settingsStack->popAll(); | ||
$this->assertEquals($origVal, \Civi::settings()->get('show_events')); | ||
} | ||
|
||
} |