Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed merging bug: merging with empty array caused error
- Loading branch information
Showing
6 changed files
with
115 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Sallyx\Nette\DI\Config\Adapters\XmlAdapter | ||
*/ | ||
|
||
use Nette\DI\Config; | ||
use Nette\DI\Statement; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
$config = new Config\Loader; | ||
$config->addAdapter('xml','Sallyx\Nette\DI\Config\Adapters\XmlAdapter'); | ||
$data = $config->load('files/xmlAdapter.merge.xml', 'production'); | ||
Assert::same(array( | ||
'webname' => 'the example', | ||
'extensions' => array( | ||
'redis' => 'Kdyby\\Redis\\DI\\RedisExtension', | ||
'streamWrappers' => 'Sallyx\\Bridges\\StreamWrappers\\Nette\\DI\\StreamWrappersExtension', | ||
), | ||
'redis' => array( | ||
'journal' => TRUE, | ||
'storage' => TRUE, | ||
'session' => array('native' => FALSE, 'debugger' => TRUE), | ||
), | ||
), $data); | ||
|
||
$data = $config->load('files/xmlAdapter.merge2.xml', 'development'); | ||
Assert::same(array( | ||
'webname' => 'the example', | ||
'extensions' => array( | ||
), | ||
'redis' => array( | ||
), | ||
), $data); |
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,45 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Sallyx\Nette\DI\Config\Adapters\XmlAdapter | ||
*/ | ||
|
||
use Nette\DI\Config; | ||
use Nette\DI\Statement; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
define('TEMP_FILE', TEMP_DIR . '/cfg.xml'); | ||
|
||
|
||
$config = new Config\Loader; | ||
$config->addAdapter('xml','Sallyx\Nette\DI\Config\Adapters\XmlAdapter'); | ||
|
||
$data = $config->load('files/xmlAdapter.entity.xml'); | ||
Assert::equal(array( | ||
new Statement('ent', array(1)), | ||
new Statement(array( | ||
new Statement('ent', array(2)), | ||
'inner', | ||
), | ||
array('3', '4') | ||
), | ||
new Statement(array( | ||
new Statement('ent', array('3')), | ||
'inner', | ||
), | ||
array('5','6') | ||
), | ||
), $data); | ||
|
||
$data = $config->load('files/xmlAdapter.entity.xml'); | ||
$config->save($data, TEMP_FILE); | ||
$actual = file_get_contents(TEMP_FILE); | ||
$actual = preg_replace('/\<([^\s\/>]+)(\s*[^\/>]*)\/\s*\>/i', '<$1$2></$1>', $actual); | ||
Assert::match(<<<EOD | ||
<?xml version="1.0"?> | ||
<config xmlns:nc="http://www.sallyx.org/xmlns/nette/config/1.0" xmlns="http://www.sallyx.org/xmlns/nette/config/1.0" array="numeric"><item statement="statement"><s><ent>ent</ent><args array="numeric"><item number="1"></item></args></s></item><item statement="statement"><s><ent>ent</ent><args array="numeric"><item number="2"></item></args></s><s><ent>inner</ent><args array="numeric"><item>3</item><item>4</item></args></s></item><item statement="statement"><s><ent>ent</ent><args array="numeric"><item>3</item></args></s><s><ent>inner</ent><args array="numeric"><item>5</item><item>6</item></args></s></item></config> | ||
EOD | ||
, $actual); |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<config xmlns:nc="http://www.sallyx.org/xmlns/nette/config/1.0" xmlns="http://www.sallyx.org/xmlns/nette/config/1.0"> | ||
<production> | ||
<webname>the example</webname> | ||
<extensions> | ||
<redis>Kdyby\Redis\DI\RedisExtension</redis> | ||
<streamWrappers>Sallyx\Bridges\StreamWrappers\Nette\DI\StreamWrappersExtension</streamWrappers> | ||
</extensions> | ||
<redis> | ||
<journal bool="true" /> | ||
<storage bool="true" /> | ||
<session><native bool="false" /><debugger bool="true" /></session> | ||
</redis> | ||
</production> | ||
</config> |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<config xmlns:nc="http://www.sallyx.org/xmlns/nette/config/1.0" xmlns="http://www.sallyx.org/xmlns/nette/config/1.0"> | ||
<development> | ||
<webname>the example</webname> | ||
<extensions array="number" merging="replace"> </extensions> | ||
<redis array="number"> </redis> | ||
</development> | ||
</config> |