Add an integration test for fetch() in settings controller [MAILPOET-1483]

This commit is contained in:
wxa
2019-04-01 21:43:35 +03:00
committed by M. Shull
parent 3a34d28daa
commit 26cbd79535
2 changed files with 10 additions and 1 deletions

View File

@@ -39,6 +39,15 @@ class SettingsControllerTest extends \MailPoetTest {
$this->assertEquals('default', $this->controller->get('test_key.wrong_subkey', 'default'));
}
function testItCanFetchValuesFromDB() {
$this->assertEquals(null, $this->controller->fetch('test_key'));
$this->assertEquals(null, $this->controller->fetch('test_key.sub_key'));
$this->assertEquals('default', $this->controller->fetch('test_key.wrong_subkey', 'default'));
Setting::createOrUpdate(['name' => 'test_key', 'value' => serialize(['sub_key' => 'value'])]);
$this->assertEquals('default', $this->controller->get('test_key.sub_key', 'default'));
$this->assertEquals('value', $this->controller->fetch('test_key.sub_key', 'default'));
}
function testItReturnsDefaultValueAsFallback() {
$settings = Stub::make($this->controller, [
'getAllDefaults' => function () {