-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provides ways to ignore configuration keys (and functions entirely) #11
- Loading branch information
1 parent
f821333
commit 63f407c
Showing
9 changed files
with
207 additions
and
0 deletions.
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
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
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,46 @@ | ||
<?php | ||
|
||
require_once 'ProteusTestCase.php'; | ||
|
||
use Stillat\Proteus\ConfigUpdater; | ||
use Stillat\Proteus\Document\Transformer; | ||
|
||
class IgnoreConfigurationItemsTest extends ProteusTestCase | ||
{ | ||
public function testThatFunctionCallsWereIgnored() | ||
{ | ||
$updater = new ConfigUpdater(); | ||
$updater->setIgnoreFunctions(true); | ||
$updater->open(__DIR__ . '/configs/withenv.php'); | ||
$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__ . '/expected/withenv.php')); | ||
$updater->update([ | ||
'some_key' => 'new-value', | ||
'nested.key.value' => 'inserted-value' | ||
]); | ||
|
||
$doc = $updater->getDocument(); | ||
|
||
$this->assertEquals($expected, $doc); | ||
} | ||
|
||
public function testConfigurationItemsCanBeIgnored() | ||
{ | ||
$updater = new ConfigUpdater(); | ||
$updater->setPreserveKeys([ | ||
'some_key', | ||
'nested.key.value' | ||
]); | ||
|
||
$updater->open(__DIR__ . '/configs/withenv.php'); | ||
$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__ . '/expected/withenv_preserve.php')); | ||
$updater->update([ | ||
'some_key' => 'new-value', | ||
'nested.key.value' => 'inserted-value', | ||
'nested.key.append' => 'Hello, universe!' | ||
]); | ||
|
||
$doc = $updater->getDocument(); | ||
|
||
$this->assertEquals($expected, $doc); | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
return [ | ||
'some_key' => env('SOME_ENV_KEY', false), | ||
|
||
'nested' => [ | ||
'key' => [ | ||
'value' => 'test' | ||
], | ||
], | ||
|
||
]; |
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,12 @@ | ||
<?php | ||
|
||
return [ | ||
'some_key' => env('SOME_ENV_KEY', false), | ||
|
||
'nested' => [ | ||
'key' => [ | ||
'value' => 'inserted-value' | ||
], | ||
], | ||
|
||
]; |
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,12 @@ | ||
<?php | ||
|
||
return [ | ||
'some_key' => env('SOME_ENV_KEY', false), | ||
|
||
'nested' => [ | ||
'key' => [ | ||
'value' => 'test', 'append' => 'Hello, universe!' | ||
], | ||
], | ||
|
||
]; |