-
-
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.
- Loading branch information
1 parent
85b64f7
commit 89c28b6
Showing
7 changed files
with
214 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
require_once 'ProteusTestCase.php'; | ||
|
||
use Stillat\Proteus\ConfigUpdater; | ||
use Stillat\Proteus\Document\Transformer; | ||
|
||
class IgnoreFunctionsWriteManyPreserveTest extends ProteusTestCase | ||
{ | ||
public function testFunctionsAreRestoredWhenWritingItemsAndPreservingKeys() | ||
{ | ||
$updater = new ConfigUpdater(); | ||
$updater->setIgnoreFunctions(true); | ||
$updater->open(__DIR__ . '/configs/issues/014.php'); | ||
$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__ . '/expected/issues/014.php')); | ||
$updater->setPreserveKeys([ | ||
'stripe' => [ | ||
'api_base', | ||
'dg_price_1', | ||
'dg_product_1', | ||
'dg_product_2', | ||
'public', | ||
'secret', | ||
'webhook', | ||
'query_params', | ||
] | ||
])->update([ | ||
'stripe' => [ | ||
'reports' => [ | ||
[ | ||
'id' => 'a new thing', | ||
'frequency' => 'daily', | ||
'email_addresses' => '[email protected]', | ||
], | ||
], | ||
] | ||
], false); // The false merge should get overridden internally. | ||
|
||
$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,52 @@ | ||
<?php | ||
|
||
require_once 'ProteusTestCase.php'; | ||
|
||
use Stillat\Proteus\ConfigUpdater; | ||
use Stillat\Proteus\Document\Transformer; | ||
|
||
class PreserveArrayKeysTest extends ProteusTestCase | ||
{ | ||
public function testUsingArraysForKeyPreservationWorks() | ||
{ | ||
$updater = new ConfigUpdater(); | ||
$updater->setIgnoreFunctions(true); | ||
$updater->open(__DIR__ . '/configs/merge.php'); | ||
$expected = Transformer::normalizeLineEndings(file_get_contents(__DIR__ . '/expected/merge.php')); | ||
$updater->setPreserveKeys([ | ||
'stripe' => [ | ||
'leave', | ||
] | ||
])->update([ | ||
'stripe' => [ | ||
'leave' => 'hello, there!', | ||
'reports' => [ | ||
[ | ||
'frequency' => 'daily', | ||
'email_addresses' => 'entry1', | ||
], | ||
[ | ||
'frequency' => 'daily', | ||
'email_addresses' => 'entry2', | ||
], | ||
[ | ||
'frequency' => 'daily', | ||
'email_addresses' => 'entry3', | ||
], | ||
], | ||
'test' => [ | ||
'what' => [ | ||
'nested' => 'value', | ||
'happens' => [ | ||
1, 2, 3, 'four', 'five', 5, 'six', 'seven' => [8] | ||
] | ||
] | ||
] | ||
] | ||
], true); | ||
|
||
$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,33 @@ | ||
<?php | ||
|
||
return [ | ||
'stripe' => [ | ||
'api_base' => env('STRIPE_API_BASE'), | ||
'dg_price_1' => env('STRIPE_PRICE_ONE'), | ||
'dg_product_1' => env('STRIPE_PRODUCT_ONE'), | ||
'dg_product_2' => env('STRIPE_PRODUCT_TWO'), | ||
'public' => env('STRIPE_PUBLIC_KEY'), | ||
'secret' => env('STRIPE_SECRET_KEY'), | ||
'webhook' => env('STRIPE_WEBHOOK_SECRET'), | ||
|
||
'reports' => [ | ||
[ | ||
'id' => 'eq48Qzwt', | ||
'frequency' => 'daily', | ||
'email_addresses' => '[email protected],[email protected]', | ||
], | ||
[ | ||
'id' => 'firstid', | ||
'frequency' => 'monthly', | ||
'email_addresses' => '[email protected],[email protected]', | ||
], | ||
], | ||
|
||
// Misc | ||
'query_params' => [ | ||
'utm_source', | ||
'utm_medium', | ||
'utm_campaign', | ||
], | ||
], | ||
]; |
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,28 @@ | ||
<?php | ||
|
||
return [ | ||
'stripe' => [ | ||
'api_base' => env('STRIPE_API_BASE'), | ||
'dg_price_1' => env('STRIPE_PRICE_ONE'), | ||
'dg_product_1' => env('STRIPE_PRODUCT_ONE'), | ||
'dg_product_2' => env('STRIPE_PRODUCT_TWO'), | ||
'public' => env('STRIPE_PUBLIC_KEY'), | ||
'secret' => env('STRIPE_SECRET_KEY'), | ||
'webhook' => env('STRIPE_WEBHOOK_SECRET'), | ||
|
||
'reports' => [ | ||
[ | ||
'id' => 'a new thing', | ||
'frequency' => 'daily', | ||
'email_addresses' => '[email protected]', | ||
], | ||
], | ||
|
||
// Misc | ||
'query_params' => [ | ||
'utm_source', | ||
'utm_medium', | ||
'utm_campaign', | ||
], | ||
], | ||
]; |