diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 21d57da..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "tools/phptools"] - path = tools/phptools - url = git://github.com/ralphschindler/PHPTools.git diff --git a/composer.json b/composer.json index 8cb3981..29d2be1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "zendframework/zend-config", - "description": "Zend\\Config component", + "description": "provides a nested object property based user interface for accessing this configuration data within application code", "license": "BSD-3-Clause", "keywords": [ "zf2", @@ -9,11 +9,11 @@ "homepage": "https://github.com/zendframework/zend-config", "autoload": { "psr-4": { - "Zend\\Config\\": "src/" + "Zend\\Config": "src/" } }, "require": { - "php": ">=5.3.23", + "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, "require-dev": { diff --git a/src/Config.php b/src/Config.php index a36341f..ece2b09 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1,36 +1,30 @@ data; + /** @var self $value */ foreach ($data as $key => $value) { if ($value instanceof self) { $array[$key] = $value->toArray(); @@ -200,6 +193,7 @@ public function __isset($name) * * @param string $name * @return void + * @throws Exception\InvalidArgumentException */ public function __unset($name) { @@ -342,11 +336,12 @@ public function offsetUnset($offset) * - Items in $merge with INTEGER keys will be appended. * - Items in $merge with STRING keys will overwrite current values. * - * @param Config $replace + * @param Config $merge * @return Config */ public function merge(self $merge) { + /** @var Config $value */ foreach ($merge as $key => $value) { if (array_key_exists($key, $this->data)) { if (is_int($key)) { @@ -384,6 +379,7 @@ public function setReadOnly() { $this->allowModifications = false; + /** @var Config $value */ foreach ($this->data as $value) { if ($value instanceof self) { $value->setReadOnly(); diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index a167476..81b0132 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -1,21 +1,11 @@ 'Ini', - 'xml' => 'Xml' + protected static $extensions = array( + 'ini' => 'ini', + 'json' => 'json', + 'xml' => 'xml', + 'yaml' => 'yaml', ); + /** * Read a config from a file. * * @param string $filename - * @param boolean $returnConfigObject + * @param boolean $returnConfigObject * @return array|Config + * @throws Exception\InvalidArgumentException + * @throws Exception\RuntimeException */ public static function fromFile($filename, $returnConfigObject = false) { $pathinfo = pathinfo($filename); - + if (!isset($pathinfo['extension'])) { throw new Exception\RuntimeException(sprintf( 'Filename "%s" is missing an extension and cannot be auto-detected', $filename )); } - + $extension = strtolower($pathinfo['extension']); - + if ($extension === 'php') { if (!is_file($filename) || !is_readable($filename)) { - throw new Exception\RuntimeException(sprintf('Filename "%s" is either not a file or not readable', $filename)); + throw new Exception\RuntimeException(sprintf( + "File '%s' doesn't exist or not readable", + $filename + )); } - + $config = include $filename; - } elseif (isset(self::$readers[$extension])) { - if (is_string(self::$readers[$extension])) { - $classname = __NAMESPACE__ . '\\Reader\\' . self::$readers[$extension]; - self::$readers[$extension] = new $classname(); + } elseif (isset(self::$extensions[$extension])) { + $reader = self::$extensions[$extension]; + if (!$reader instanceof Reader\ReaderInterface) { + $reader = self::getReaderPluginManager()->get($reader); + self::$extensions[$extension] = $reader; } - - $config = self::$readers[$extension]->fromFile($filename); + + /** @var Reader\ReaderInterface $reader */ + $config = $reader->fromFile($filename); } else { throw new Exception\RuntimeException(sprintf( 'Unsupported config file extension: .%s', @@ -89,7 +93,7 @@ public static function fromFile($filename, $returnConfigObject = false) * Read configuration from multiple files and merge them. * * @param array $files - * @param boolean $returnConfigObject + * @param boolean $returnConfigObject * @return array|Config */ public static function fromFiles(array $files, $returnConfigObject = false) @@ -102,4 +106,50 @@ public static function fromFiles(array $files, $returnConfigObject = false) return ($returnConfigObject) ? new Config($config) : $config; } + + /** + * Set reader plugin manager + * + * @param ReaderPluginManager $readers + */ + public static function setReaderPluginManager(ReaderPluginManager $readers) + { + self::$readers = $readers; + } + + /** + * Get the reader plugin manager + * + * @return ReaderPluginManager + */ + public static function getReaderPluginManager() + { + if (static::$readers === null) { + static::$readers = new ReaderPluginManager(); + } + return static::$readers; + } + + /** + * Set config reader for file extension + * + * @param string $extension + * @param string|Reader\ReaderInterface $reader + * @throws Exception\InvalidArgumentException + */ + public static function registerReader($extension, $reader) + { + $extension = strtolower($extension); + + if (!is_string($reader) && !$reader instanceof Reader\ReaderInterface) { + throw new Exception\InvalidArgumentException(sprintf( + 'Reader should be plugin name, class name or ' . + 'instance of %s\Reader\ReaderInterface; recieved "%s"', + __NAMESPACE__, + (is_object($reader) ? get_class($reader) : gettype($reader)) + )); + } + + self::$extensions[$extension] = $reader; + } } diff --git a/src/Processor/Constant.php b/src/Processor/Constant.php index ed85d2f..9fbae8d 100644 --- a/src/Processor/Constant.php +++ b/src/Processor/Constant.php @@ -1,35 +1,19 @@ userOnly = $userOnly; + $this->userOnly = (bool) $userOnly; + return $this; } /** @@ -101,5 +86,4 @@ public function getTokens() { return $this->tokens; } - } diff --git a/src/Processor/Filter.php b/src/Processor/Filter.php index 58accc8..1ed0f31 100644 --- a/src/Processor/Filter.php +++ b/src/Processor/Filter.php @@ -1,36 +1,23 @@ filter; + $this->filter = $filter; + return $this; } /** - * @param ZendFilter $filter + * @return ZendFilter */ - public function setFilter(ZendFilter $filter) + public function getFilter() { - $this->filter = $filter; + return $this->filter; } /** * Process - * + * * @param Config $config - * @return Config + * @return Config + * @throws Exception\InvalidArgumentException */ public function process(Config $config) { if ($config->isReadOnly()) { - throw new Exception\InvalidArgumentException('Cannot parse config because it is read-only'); + throw new Exception\InvalidArgumentException('Cannot process config because it is read-only'); } /** @@ -94,7 +84,7 @@ public function process(Config $config) /** * Process a single value * - * @param $value + * @param mixed $value * @return mixed */ public function processValue($value) diff --git a/src/Processor/ProcessorInterface.php b/src/Processor/ProcessorInterface.php index 0994ba2..520a18b 100644 --- a/src/Processor/ProcessorInterface.php +++ b/src/Processor/ProcessorInterface.php @@ -1,21 +1,11 @@ isReadOnly()) { - throw new InvalidArgumentException('Cannot parse config because it is read-only'); + throw new Exception\InvalidArgumentException('Cannot process config because it is read-only'); } foreach ($this as $parser) { - /** @var $parser \Zend\Config\Processor\ProcessorInterface */ + /** @var $parser ProcessorInterface */ $parser->process($config); } } @@ -53,13 +43,13 @@ public function process(Config $config) /** * Process a single value * - * @param $value + * @param mixed $value * @return mixed */ public function processValue($value) { foreach ($this as $parser) { - /** @var $parser \Zend\Config\Processor\ProcessorInterface */ + /** @var $parser ProcessorInterface */ $value = $parser->processValue($value); } diff --git a/src/Processor/Token.php b/src/Processor/Token.php index 24b6aec..022daf5 100644 --- a/src/Processor/Token.php +++ b/src/Processor/Token.php @@ -1,35 +1,23 @@ value - * to replace it with - * @param string $prefix - * @param string $suffix + * @param array|Config|Traversable $tokens Associative array of TOKEN => value + * to replace it with + * @param string $prefix + * @param string $suffix * @internal param array $options - * @return \Zend\Config\Processor\Token + * @return Token */ public function __construct($tokens = array(), $prefix = '', $suffix = '') { @@ -80,51 +68,53 @@ public function __construct($tokens = array(), $prefix = '', $suffix = '') } /** - * @return string + * @param string $prefix + * @return Token */ - public function getPrefix() + public function setPrefix($prefix) { - return $this->prefix; + // reset map + $this->map = null; + $this->prefix = $prefix; + return $this; } /** * @return string */ - public function getSuffix() + public function getPrefix() { - return $this->suffix; + return $this->prefix; } /** - * @param string $prefix - * @return mixed + * @param string $suffix + * @return Token */ - public function setPrefix($prefix) + public function setSuffix($suffix) { // reset map $this->map = null; + $this->suffix = $suffix; - return $this->prefix = $prefix; + return $this; } /** - * @param string $suffix * @return string */ - public function setSuffix($suffix) + public function getSuffix() { - // reset map - $this->map = null; - - return $this->suffix = $suffix; + return $this->suffix; } /** * Set token registry. * - * @param array|\Zend\Config\Config|\ArrayObject|\Traversable $tokens Associative array of TOKEN => value - * to replace it with - * @throws \Zend\Config\Exception\InvalidArgumentException + * @param array|Config|Traversable $tokens Associative array of TOKEN => value + * to replace it with + * @return Token + * @throws Exception\InvalidArgumentException */ public function setTokens($tokens) { @@ -132,7 +122,7 @@ public function setTokens($tokens) $this->tokens = $tokens; } elseif ($tokens instanceof Config) { $this->tokens = $tokens->toArray(); - } elseif ($tokens instanceof \Traversable) { + } elseif ($tokens instanceof Traversable) { $this->tokens = array(); foreach ($tokens as $key => $val) { $this->tokens[$key] = $val; @@ -143,10 +133,13 @@ public function setTokens($tokens) // reset map $this->map = null; + + return $this; } /** * Get current token registry. + * * @return array */ public function getTokens() @@ -157,9 +150,10 @@ public function getTokens() /** * Add new token. * - * @param $token - * @param $value - * @throws \Zend\Config\Exception\InvalidArgumentException + * @param string $token + * @param mixed $value + * @return Token + * @throws Exception\InvalidArgumentException */ public function addToken($token, $value) { @@ -170,14 +164,16 @@ public function addToken($token, $value) // reset map $this->map = null; + + return $this; } /** * Add new token. * - * @param $token - * @param $value - * @throws \Zend\Config\Exception\InvalidArgumentException + * @param string $token + * @param mixed $value + * @return Token */ public function setToken($token, $value) { @@ -204,11 +200,12 @@ protected function buildMap() * * @param Config $config * @return Config + * @throws InvalidArgumentException */ public function process(Config $config) { if ($config->isReadOnly()) { - throw new Exception\InvalidArgumentException('Cannot parse config because it is read-only'); + throw new Exception\InvalidArgumentException('Cannot process config because it is read-only'); } if ($this->map === null) { @@ -244,6 +241,7 @@ public function processValue($value) } $keys = array_keys($this->map); $values = array_values($this->map); + return str_replace($keys, $values, $value); } } diff --git a/src/Processor/Translator.php b/src/Processor/Translator.php index 4bcf899..bb2c623 100644 --- a/src/Processor/Translator.php +++ b/src/Processor/Translator.php @@ -1,37 +1,23 @@ setTranslator($translator); + $this->setTextDomain($textDomain); $this->setLocale($locale); } + /** + * @param ZendTranslator $translator + * @return Translator + */ + public function setTranslator(ZendTranslator $translator) + { + $this->translator = $translator; + return $this; + } + /** * @return ZendTranslator */ @@ -68,15 +70,17 @@ public function getTranslator() } /** - * @param ZendTranslator $translator + * @param string|null $locale + * @return Translator */ - public function setTranslator(ZendTranslator $translator) + public function setLocale($locale) { - $this->translator = $translator; + $this->locale = $locale; + return $this; } /** - * @return Locale|string|null + * @return string|null */ public function getLocale() { @@ -84,24 +88,34 @@ public function getLocale() } /** - * @param Locale|string|null $locale + * @param string $textDomain + * @return Translator */ - public function setLocale($locale) + public function setTextDomain($textDomain) { - $this->locale = $locale; + $this->textDomain = $textDomain; + return $this; + } + + /** + * @return string + */ + public function getTextDomain() + { + return $this->textDomain; } /** * Process * - * @param Config $config + * @param Config $config * @return Config - * @throws InvalidArgumentException + * @throws Exception\InvalidArgumentException */ public function process(Config $config) { if ($config->isReadOnly()) { - throw new InvalidArgumentException('Cannot parse config because it is read-only'); + throw new Exception\InvalidArgumentException('Cannot process config because it is read-only'); } /** @@ -111,7 +125,7 @@ public function process(Config $config) if ($val instanceof Config) { $this->process($val); } else { - $config->$key = $this->translator->translate($val, $this->locale); + $config->{$key} = $this->translator->translate($val, $this->textDomain, $this->locale); } } @@ -126,7 +140,7 @@ public function process(Config $config) */ public function processValue($value) { - return $this->translator->translate($value, $this->locale); + return $this->translator->translate($value, $this->textDomain, $this->locale); } } diff --git a/src/Reader/Ini.php b/src/Reader/Ini.php index 34d6412..6498c0f 100644 --- a/src/Reader/Ini.php +++ b/src/Reader/Ini.php @@ -1,22 +1,11 @@ directory = dirname($filename); set_error_handler( @@ -94,16 +86,16 @@ function($error, $message = '', $file = '', $line = 0) use ($filename) { ); $ini = parse_ini_file($filename, true); restore_error_handler(); - + return $this->process($ini); } /** * fromString(): defined by Reader interface. * - * @see ReaderInterface::fromString() * @param string $string - * @return array + * @return array|bool + * @throws Exception\RuntimeException */ public function fromString($string) { @@ -122,7 +114,7 @@ function($error, $message = '', $file = '', $line = 0) { ); $ini = parse_ini_string($string, true); restore_error_handler(); - + return $this->process($ini); } @@ -171,6 +163,7 @@ protected function processSection(array $section) * @param string $value * @param array $config * @return array + * @throws Exception\RuntimeException */ protected function processKey($key, $value, array &$config) { @@ -186,7 +179,9 @@ protected function processKey($key, $value, array &$config) $config[$pieces[0]] = array(); } } elseif (!is_array($config[$pieces[0]])) { - throw new Exception\RuntimeException(sprintf('Cannot create sub-key for "%s", as key already exists', $pieces[0])); + throw new Exception\RuntimeException(sprintf( + 'Cannot create sub-key for "%s", as key already exists', $pieces[0] + )); } $this->processKey($pieces[1], $value, $config[$pieces[0]]); diff --git a/src/Reader/Json.php b/src/Reader/Json.php index 3f93a28..5d6b7bd 100644 --- a/src/Reader/Json.php +++ b/src/Reader/Json.php @@ -1,37 +1,25 @@ directory = dirname($filename); - + try { $config = JsonFormat::decode(file_get_contents($filename), JsonFormat::TYPE_ARRAY); - } catch (\Zend\Json\Exception\RuntimeException $e) { + } catch (JsonException\RuntimeException $e) { throw new Exception\RuntimeException($e->getMessage()); - } - + } + return $this->process($config); } @@ -70,42 +63,47 @@ public function fromFile($filename) * * @see ReaderInterface::fromString() * @param string $string - * @return array + * @return array|bool + * @throws Exception\RuntimeException */ public function fromString($string) { if (empty($string)) { return array(); } + $this->directory = null; - + try { $config = JsonFormat::decode($string, JsonFormat::TYPE_ARRAY); - } catch (\Zend\Json\Exception\RuntimeException $e) { + } catch (JsonException\RuntimeException $e) { throw new Exception\RuntimeException($e->getMessage()); - } - + } + return $this->process($config); } + /** * Process the array for @include - * + * * @param array $data - * @return array + * @return array + * @throws Exception\RuntimeException */ - protected function process(array $data) { + protected function process(array $data) + { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->process($value); } - if (trim($key)==='@include') { + if (trim($key) === '@include') { if ($this->directory === null) { - throw new Exception\RuntimeException('Cannot process @include statement for a json string'); + throw new Exception\RuntimeException('Cannot process @include statement for a JSON string'); } $reader = clone $this; unset($data[$key]); $data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value)); - } + } } return $data; } diff --git a/src/Reader/ReaderInterface.php b/src/Reader/ReaderInterface.php index e10280c..4ecaf8d 100644 --- a/src/Reader/ReaderInterface.php +++ b/src/Reader/ReaderInterface.php @@ -1,30 +1,19 @@ reader = new XMLReader(); - $this->reader->open($filename, null, LIBXML_XINCLUDE); + $this->reader = new XMLReader(); + $this->reader->open($filename, null, LIBXML_XINCLUDE); $this->directory = dirname($filename); @@ -87,7 +80,7 @@ function($error, $message = '', $file = '', $line = 0) use ($filename) { ); $return = $this->process(); restore_error_handler(); - + return $return; } @@ -96,7 +89,8 @@ function($error, $message = '', $file = '', $line = 0) use ($filename) { * * @see ReaderInterface::fromString() * @param string $string - * @return array + * @return array|bool + * @throws Exception\RuntimeException */ public function fromString($string) { @@ -104,7 +98,7 @@ public function fromString($string) return array(); } $this->reader = new XMLReader(); - + $this->reader->xml($string, null, LIBXML_XINCLUDE); $this->directory = null; @@ -119,7 +113,7 @@ function($error, $message = '', $file = '', $line = 0) { ); $return = $this->process(); restore_error_handler(); - + return $return; } @@ -181,7 +175,7 @@ protected function processNextElement() $text .= $this->reader->value; } } - + return $children ?: $text; } diff --git a/src/Reader/Yaml.php b/src/Reader/Yaml.php index 5f173a7..c33ef29 100644 --- a/src/Reader/Yaml.php +++ b/src/Reader/Yaml.php @@ -1,22 +1,11 @@ setYamlDecoder($yamlDecoder); } else { if (function_exists('yaml_parse')) { @@ -60,52 +50,63 @@ public function __construct($yamlDecoder=null) { } } } - /** - * Get callback for decoding YAML - * - * @return callable - */ - public function getYamlDecoder() - { - return $this->yamlDecoder; - } + /** * Set callback for decoding YAML * - * @param callable $yamlDecoder the decoder to set + * @param string|callable $yamlDecoder the decoder to set * @return Yaml + * @throws Exception\InvalidArgumentException */ public function setYamlDecoder($yamlDecoder) { if (!is_callable($yamlDecoder)) { - throw new Exception\InvalidArgumentException('Invalid parameter to setYamlDecoder() - must be callable'); + throw new Exception\RuntimeException( + 'Invalid parameter to setYamlDecoder() - must be callable' + ); } $this->yamlDecoder = $yamlDecoder; return $this; } + + /** + * Get callback for decoding YAML + * + * @return callable + */ + public function getYamlDecoder() + { + return $this->yamlDecoder; + } + /** * fromFile(): defined by Reader interface. * * @see ReaderInterface::fromFile() * @param string $filename * @return array + * @throws Exception\RuntimeException */ public function fromFile($filename) { - if (!file_exists($filename)) { - throw new Exception\RuntimeException("The file $filename doesn't exists."); + if (!is_file($filename) || !is_readable($filename)) { + throw new Exception\RuntimeException(sprintf( + "File '%s' doesn't exist or not readable", + $filename + )); } + if (null === $this->getYamlDecoder()) { throw new Exception\RuntimeException("You didn't specify a Yaml callback decoder"); } - + $this->directory = dirname($filename); - + $config = call_user_func($this->getYamlDecoder(), file_get_contents($filename)); if (null === $config) { throw new Exception\RuntimeException("Error parsing YAML data"); - } - + } + return $this->process($config); } @@ -114,7 +115,8 @@ public function fromFile($filename) * * @see ReaderInterface::fromString() * @param string $string - * @return array + * @return array|bool + * @throws Exception\RuntimeException */ public function fromString($string) { @@ -124,35 +126,38 @@ public function fromString($string) if (empty($string)) { return array(); } - + $this->directory = null; - + $config = call_user_func($this->getYamlDecoder(), $string); if (null === $config) { throw new Exception\RuntimeException("Error parsing YAML data"); - } - + } + return $this->process($config); } + /** * Process the array for @include - * + * * @param array $data - * @return array + * @return array + * @throws Exception\RuntimeException */ - protected function process(array $data) { + protected function process(array $data) + { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->process($value); } - if (trim($key)==='@include') { + if (trim($key) === '@include') { if ($this->directory === null) { throw new Exception\RuntimeException('Cannot process @include statement for a json string'); } $reader = clone $this; unset($data[$key]); $data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value)); - } + } } return $data; } diff --git a/src/ReaderPluginManager.php b/src/ReaderPluginManager.php new file mode 100644 index 0000000..2614fd0 --- /dev/null +++ b/src/ReaderPluginManager.php @@ -0,0 +1,54 @@ + 'Zend\Config\Reader\Ini', + 'json' => 'Zend\Config\Reader\Json', + 'xml' => 'Zend\Config\Reader\Xml', + 'yaml' => 'Zend\Config\Reader\Yaml', + ); + + /** + * Validate the plugin + * Checks that the reader loaded is an instance of Reader\ReaderInterface. + * + * @param Reader\ReaderInterface $plugin + * @return void + * @throws Exception\InvalidArgumentException if invalid + */ + public function validatePlugin($plugin) + { + if ($plugin instanceof Reader\ReaderInterface) { + // we're okay + return; + } + + throw new Exception\InvalidArgumentException(sprintf( + 'Plugin of type %s is invalid; must implement %s\Reader\ReaderInterface', + (is_object($plugin) ? get_class($plugin) : gettype($plugin)), + __NAMESPACE__ + )); + } +} diff --git a/src/Writer/AbstractWriter.php b/src/Writer/AbstractWriter.php index 7b77a63..4726075 100644 --- a/src/Writer/AbstractWriter.php +++ b/src/Writer/AbstractWriter.php @@ -1,35 +1,24 @@ toString($config), $exclusiveLock); + file_put_contents($filename, $this->toString($config), $flags); restore_error_handler(); } @@ -71,7 +61,8 @@ function($error, $message = '', $file = '', $line = 0) use ($filename) { * * @see WriterInterface::toString() * @param mixed $config - * @return void + * @return string + * @throws Exception\InvalidArgumentException */ public function toString($config) { @@ -85,8 +76,7 @@ public function toString($config) } /** - * Process an array configuration. - * + * @param array $config * @return string */ abstract protected function processConfig(array $config); diff --git a/src/Writer/Ini.php b/src/Writer/Ini.php index 164097f..cae2dc0 100644 --- a/src/Writer/Ini.php +++ b/src/Writer/Ini.php @@ -1,21 +1,11 @@ startElement($branchName); $branchType = 'string'; } - } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) { + } elseif ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) { throw new Exception\RuntimeException('Mixing of string and numeric keys is not allowed'); } diff --git a/src/Writer/Yaml.php b/src/Writer/Yaml.php index 6a5c1a0..9d4c309 100644 --- a/src/Writer/Yaml.php +++ b/src/Writer/Yaml.php @@ -1,21 +1,11 @@ setYamlEncoder($yamlEncoder); } else { - if (function_exists('yaml_parse')) { - $this->setYamlEncoder('yaml_parse'); + if (function_exists('yaml_emit')) { + $this->setYamlEncoder('yaml_emit'); } } } + /** * Get callback for decoding YAML * @@ -59,11 +51,13 @@ public function getYamlEncoder() { return $this->yamlEncoder; } + /** * Set callback for decoding YAML * * @param callable $yamlEncoder the decoder to set * @return Yaml + * @throws Exception\InvalidArgumentException */ public function setYamlEncoder($yamlEncoder) { @@ -73,23 +67,25 @@ public function setYamlEncoder($yamlEncoder) $this->yamlEncoder = $yamlEncoder; return $this; } + /** * processConfig(): defined by AbstractWriter. * * @param array $config * @return string + * @throws Exception\RuntimeException */ public function processConfig(array $config) { if (null === $this->getYamlEncoder()) { throw new Exception\RuntimeException("You didn't specify a Yaml callback encoder"); } - + $config = call_user_func($this->getYamlEncoder(), $config); if (null === $config) { throw new Exception\RuntimeException("Error generating YAML data"); } - + return $config; } } diff --git a/test/ConfigTest.php b/test/ConfigTest.php index c67efc2..25eac99 100644 --- a/test/ConfigTest.php +++ b/test/ConfigTest.php @@ -1,34 +1,21 @@ merge($config); - try { - $config2->key2 = 'no'; - } catch (\Zend\Config\Exception\RuntimeException $e) { - $this->fail('Unexpected exception at top level has been raised: ' . $e->getMessage()); - } + + $config2->key2 = 'no'; + $this->assertEquals('no', $config2->key2); - try { - $config2->key->nested = 'no'; - } catch (\Zend\Config\Exception\RuntimeException $e) { - $this->fail('Unexpected exception on nested object has been raised: ' . $e->getMessage()); - } - $this->assertEquals('no', $config2->key->nested); + $config2->key->nested = 'no'; + $this->assertEquals('no', $config2->key->nested); } /** @@ -502,8 +483,7 @@ public function testUnsettingFirstElementDuringForeachDoesNotSkipAnElement() ), true); $keyList = array(); - foreach ($config as $key => $value) - { + foreach ($config as $key => $value) { $keyList[] = $key; if ($key == 'first') { unset($config->$key); // uses magic Zend\Config\Config::__unset() method @@ -528,8 +508,7 @@ public function testUnsettingAMiddleElementDuringForeachDoesNotSkipAnElement() ), true); $keyList = array(); - foreach ($config as $key => $value) - { + foreach ($config as $key => $value) { $keyList[] = $key; if ($key == 'second') { unset($config->$key); // uses magic Zend\Config\Config::__unset() method @@ -554,8 +533,7 @@ public function testUnsettingLastElementDuringForeachDoesNotSkipAnElement() ), true); $keyList = array(); - foreach ($config as $key => $value) - { + foreach ($config as $key => $value) { $keyList[] = $key; if ($key == 'third') { unset($config->$key); // uses magic Zend\Config\Config::__unset() method @@ -595,7 +573,8 @@ public function testZF6995_toArrayDoesNotDisturbInternalIterator() * @depends testMerge * @link http://framework.zend.com/issues/browse/ZF2-186 */ - public function testZF2_186_mergeReplacingUnnamedConfigSettings(){ + public function testZF2_186_mergeReplacingUnnamedConfigSettings() + { $arrayA = array( 'flag' => true, 'text' => 'foo', diff --git a/test/FactoryTest.php b/test/FactoryTest.php index d7de536..ffd4836 100644 --- a/test/FactoryTest.php +++ b/test/FactoryTest.php @@ -1,91 +1,75 @@ assertEquals('bar', $config['base']['foo']); } - + public function testFromXml() { $config = Factory::fromFile(__DIR__ . '/TestAssets/Xml/include-base.xml'); - + $this->assertEquals('bar', $config['base']['foo']); } - + public function testFromIniFiles() { $files = array ( __DIR__ . '/TestAssets/Ini/include-base.ini', __DIR__ . '/TestAssets/Ini/include-base2.ini' ); - $config = Factory::fromFiles($files); + $this->assertEquals('bar', $config['base']['foo']); $this->assertEquals('baz', $config['test']['bar']); } - + public function testFromXmlFiles() { $files = array ( __DIR__ . '/TestAssets/Xml/include-base.xml', __DIR__ . '/TestAssets/Xml/include-base2.xml' ); - $config = Factory::fromFiles($files); + $this->assertEquals('bar', $config['base']['foo']); $this->assertEquals('baz', $config['test']['bar']); } - + public function testFromPhpFiles() { $files = array ( __DIR__ . '/TestAssets/Php/include-base.php', __DIR__ . '/TestAssets/Php/include-base2.php' ); - $config = Factory::fromFiles($files); + $this->assertEquals('bar', $config['base']['foo']); $this->assertEquals('baz', $config['test']['bar']); } - + public function testFromIniAndXmlAndPhpFiles() { $files = array ( @@ -93,8 +77,8 @@ public function testFromIniAndXmlAndPhpFiles() __DIR__ . '/TestAssets/Xml/include-base2.xml', __DIR__ . '/TestAssets/Php/include-base3.php', ); - $config = Factory::fromFiles($files); + $this->assertEquals('bar', $config['base']['foo']); $this->assertEquals('baz', $config['test']['bar']); $this->assertEquals('baz', $config['last']['bar']); @@ -105,7 +89,7 @@ public function testReturnsConfigObjectIfRequestedAndArrayOtherwise() $files = array ( __DIR__ . '/TestAssets/Ini/include-base.ini', ); - + $configArray = Factory::fromFile($files[0]); $this->assertTrue(is_array($configArray)); @@ -125,10 +109,35 @@ public function testNonExistentFileThrowsRuntimeException() $config = Factory::fromFile('foo.bar'); } - public function testInvalidFileExtensionThrowsInvalidArgumentException() + public function testUnsupportedFileExtensionThrowsRuntimeException() { $this->setExpectedException('RuntimeException'); $config = Factory::fromFile(__DIR__ . '/TestAssets/bad.ext'); } + + public function testFactoryCanRegisterCustomReaderInstance() + { + Factory::registerReader('dum', new Reader\TestAssets\DummyReader()); + + $configObject = Factory::fromFile(__DIR__ . '/TestAssets/dummy.dum', true); + $this->assertInstanceOf('Zend\Config\Config', $configObject); + + $this->assertEquals($configObject['one'], 1); + } + + public function testFactoryCanRegisterCustomReaderPlugn() + { + $dummyReader = new Reader\TestAssets\DummyReader(); + Factory::getReaderPluginManager()->setService('DummyReader',$dummyReader); + + Factory::registerReader('dum', 'DummyReader'); + + $configObject = Factory::fromFile(__DIR__ . '/TestAssets/dummy.dum', true); + $this->assertInstanceOf('Zend\Config\Config', $configObject); + + $this->assertEquals($configObject['one'], 1); + } + + } diff --git a/test/ProcessorTest.php b/test/ProcessorTest.php index 42cf335..aaeb368 100644 --- a/test/ProcessorTest.php +++ b/test/ProcessorTest.php @@ -1,51 +1,38 @@ translator = array( + $this->translatorData = array( 'pages' => array( array( 'id' => 'oneDog', @@ -131,10 +118,7 @@ public function setUp() ) ); - $this->translatorStrings = array( - 'one dog' => 'ein Hund', - 'two dogs' => 'zwei Hunde' - ); + $this->translatorFile = realpath(__DIR__ . '/_files/translations-de_DE.php'); $this->filter = array( 'simple' => 'some MixedCase VALue', @@ -143,11 +127,6 @@ public function setUp() ), ); - if (ArrayAdapter::hasCache()) { - ArrayAdapter::clearCache(); - ArrayAdapter::removeCache(); - } - $this->userConstants = array( 'simple' => 'SOME_USERLAND_CONSTANT', 'inside' => 'some text with SOME_USERLAND_CONSTANT inside', @@ -198,10 +177,11 @@ public function testBareTokenPost() public function testAddInvalidToken() { $processor = new TokenProcessor(); - $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'Cannot use ' . gettype(array()) . ' as token name.'); + $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', + 'Cannot use ' . gettype(array()) . ' as token name.'); $processor->addToken(array(), 'bar'); } - + public function testSingleValueToken() { $processor = new TokenProcessor(); @@ -210,17 +190,18 @@ public function testSingleValueToken() $out = $processor->processValue($data); $this->assertEquals($out, 'test'); } - + public function testTokenReadOnly() { $config = new Config($this->tokenBare, false); $processor = new TokenProcessor(); $processor->addToken('BARETOKEN', 'some replaced value'); - - $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'Cannot parse config because it is read-only'); + + $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', + 'Cannot process config because it is read-only'); $processor->process($config); } - + public function testTokenPrefix() { $config = new Config($this->tokenPrefix, true); @@ -306,7 +287,7 @@ public function testUserConstants() $this->assertTrue(is_array($tokens)); $this->assertTrue(in_array('SOME_USERLAND_CONSTANT', $tokens)); $this->assertTrue(!$processor->getUserOnly()); - + $this->assertEquals('some constant value', $config->simple); $this->assertEquals('some text with some constant value inside', $config->inside); $this->assertEquals('some constant value', $config->nested->simple); @@ -324,17 +305,17 @@ public function testUserOnlyConstants() $processor->process($config); $tokens = $processor->getTokens(); - + $this->assertTrue(is_array($tokens)); $this->assertTrue(in_array('SOME_USERLAND_CONSTANT', $tokens)); $this->assertTrue($processor->getUserOnly()); - + $this->assertEquals('some constant value', $config->simple); $this->assertEquals('some text with some constant value inside', $config->inside); $this->assertEquals('some constant value', $config->nested->simple); $this->assertEquals('some text with some constant value inside', $config->nested->inside); } - + /** * @depends testTokenSurround */ @@ -352,42 +333,45 @@ public function testPHPConstants() public function testTranslator() { - $config = new Config($this->translator, true); - $translator = new Translator(Translator::AN_ARRAY, $this->translatorStrings, 'de_DE'); - $processor = new TranslatorProcessor($translator); + $config = new Config($this->translatorData, true); + $translator = new Translator(); + $translator->addTranslationFile('phparray', $this->translatorFile); + $processor = new TranslatorProcessor($translator); $processor->process($config); $this->assertEquals('oneDog', $config->pages[0]->id); $this->assertEquals('ein Hund', $config->pages[0]->label); - $this->assertEquals('twoDogs', $config->pages[1]->id); $this->assertEquals('zwei Hunde', $config->pages[1]->label); } - + public function testTranslatorReadOnly() { - $config = new Config($this->translator, false); - $translator = new Translator(Translator::AN_ARRAY, $this->translatorStrings, 'de_DE'); - $processor = new TranslatorProcessor($translator); - $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'Cannot parse config because it is read-only'); + $config = new Config($this->translatorData, false); + $translator = new Translator(); + $processor = new TranslatorProcessor($translator); + + $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', + 'Cannot process config because it is read-only'); $processor->process($config); } public function testTranslatorSingleValue() - { - $translator = new Translator(Translator::AN_ARRAY, $this->translatorStrings, 'de_DE'); - $processor = new TranslatorProcessor($translator); - $word = 'one dog'; - $this->assertEquals('ein Hund', $processor->processValue($word)); + { + $translator = new Translator(); + $translator->addTranslationFile('phparray', $this->translatorFile); + $processor = new TranslatorProcessor($translator); + + $this->assertEquals('ein Hund', $processor->processValue('one dog')); } - + public function testFilter() { $config = new Config($this->filter, true); $filter = new StringToLower(); $processor = new FilterProcessor($filter); - + $this->assertTrue($processor->getFilter() instanceof StringToLower); $processor->process($config); @@ -400,20 +384,21 @@ public function testFilterReadOnly() $config = new Config($this->filter, false); $filter = new StringToLower(); $processor = new FilterProcessor($filter); - - $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'Cannot parse config because it is read-only'); + + $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', + 'Cannot process config because it is read-only'); $processor->process($config); } - + public function testFilterValue() { $filter = new StringToLower(); $processor = new FilterProcessor($filter); - + $value = 'TEST'; $this->assertEquals('test', $processor->processValue($value)); } - + /** * @depends testFilter */ @@ -436,7 +421,7 @@ public function testQueueFIFO() $this->assertEquals('some mixedcase value', $config->simple); $this->assertEquals('other mixed case value', $config->nested->simple); } - + public function testQueueReadOnly() { $config = new Config($this->filter, false); @@ -448,8 +433,9 @@ public function testQueueReadOnly() */ $queue = new Queue(); $queue->insert($lowerProcessor); - - $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'Cannot parse config because it is read-only'); + + $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', + 'Cannot process config because it is read-only'); $queue->process($config); } @@ -466,11 +452,12 @@ public function testQueueSingleValue() $queue = new Queue(); $queue->insert($upperProcessor); $queue->insert($lowerProcessor); - + $data ='TeSt'; $this->assertEquals('test', $queue->processValue($data)); - + } + /** * @depends testQueueFIFO */ diff --git a/test/Reader/AbstractReaderTestCase.php b/test/Reader/AbstractReaderTestCase.php index 1f4a99d..1e45a5c 100644 --- a/test/Reader/AbstractReaderTestCase.php +++ b/test/Reader/AbstractReaderTestCase.php @@ -1,36 +1,23 @@ getTestAssetPath('no-file'); - $this->setExpectedException('Zend\Config\Exception\RuntimeException', "The file $filename doesn't exists."); - $config = $this->reader->fromFile($filename); + $this->setExpectedException('Zend\Config\Exception\RuntimeException', "doesn't exist or not readable"); + $config = $this->reader->fromFile($filename); } - + public function testFromFile() { $config = $this->reader->fromFile($this->getTestAssetPath('include-base')); $this->assertEquals('foo', $config['foo']); } - + public function testFromEmptyString() { $config = $this->reader->fromString(''); diff --git a/test/Reader/IniTest.php b/test/Reader/IniTest.php index 82b101e..f814218 100644 --- a/test/Reader/IniTest.php +++ b/test/Reader/IniTest.php @@ -1,34 +1,21 @@ reader = new Ini(); } - + /** * getTestAssetPath(): defined by AbstractReaderTestCase. - * + * * @see AbstractReaderTestCase::getTestAssetPath() * @return string */ @@ -48,14 +35,14 @@ protected function getTestAssetPath($name) { return __DIR__ . '/TestAssets/Ini/' . $name . '.ini'; } - + public function testInvalidIniFile() { $this->reader = new Ini(); $this->setExpectedException('Zend\Config\Exception\RuntimeException'); $arrayIni = $this->reader->fromFile($this->getTestAssetPath('invalid')); } - + public function testFromString() { $ini = <<reader->fromString($ini); $this->assertEquals($arrayIni['test'], 'foo'); $this->assertEquals($arrayIni['bar'][0], 'baz'); $this->assertEquals($arrayIni['bar'][1], 'foo'); } - + public function testInvalidString() { $ini = <<setExpectedException('Zend\Config\Exception\RuntimeException'); $arrayIni = $this->reader->fromString($ini); } - + public function testFromStringWithSection() { $ini = <<reader->fromString($ini); $this->assertEquals($arrayIni['all']['test'], 'foo'); $this->assertEquals($arrayIni['all']['bar'][0], 'baz'); diff --git a/test/Reader/JsonTest.php b/test/Reader/JsonTest.php index b52bb2d..20cc681 100644 --- a/test/Reader/JsonTest.php +++ b/test/Reader/JsonTest.php @@ -1,34 +1,21 @@ reader = new Json(); } - + /** * getTestAssetPath(): defined by AbstractReaderTestCase. - * + * * @see AbstractReaderTestCase::getTestAssetPath() * @return string */ @@ -48,36 +35,36 @@ protected function getTestAssetPath($name) { return __DIR__ . '/TestAssets/Json/' . $name . '.json'; } - + public function testInvalidJsonFile() { $this->setExpectedException('Zend\Config\Exception\RuntimeException'); $arrayJson = $this->reader->fromFile($this->getTestAssetPath('invalid')); } - + public function testIncludeAsElement() { $arrayJson = $this->reader->fromFile($this->getTestAssetPath('include-base_nested')); $this->assertEquals($arrayJson['bar']['foo'], 'foo'); } - + public function testFromString() { $json = '{ "test" : "foo", "bar" : [ "baz", "foo" ] }'; - + $arrayJson = $this->reader->fromString($json); - + $this->assertEquals($arrayJson['test'], 'foo'); $this->assertEquals($arrayJson['bar'][0], 'baz'); $this->assertEquals($arrayJson['bar'][1], 'foo'); } - + public function testInvalidString() { $json = '{"foo":"bar"'; - + $this->setExpectedException('Zend\Config\Exception\RuntimeException'); $arrayIni = $this->reader->fromString($json); } - + } diff --git a/test/Reader/TestAssets/DummyReader.php b/test/Reader/TestAssets/DummyReader.php new file mode 100644 index 0000000..95d24d5 --- /dev/null +++ b/test/Reader/TestAssets/DummyReader.php @@ -0,0 +1,35 @@ +reader = new Xml(); } - + /** * getTestAssetPath(): defined by AbstractReaderTestCase. - * + * * @see AbstractReaderTestCase::getTestAssetPath() * @return string */ @@ -48,14 +35,14 @@ protected function getTestAssetPath($name) { return __DIR__ . '/TestAssets/Xml/' . $name . '.xml'; } - + public function testInvalidXmlFile() { $this->reader = new Xml(); $this->setExpectedException('Zend\Config\Exception\RuntimeException'); $arrayXml = $this->reader->fromFile($this->getTestAssetPath('invalid')); } - + public function testFromString() { $xml = << ECS; - + $arrayXml= $this->reader->fromString($xml); $this->assertEquals($arrayXml['test'], 'foo'); $this->assertEquals($arrayXml['bar'][0], 'baz'); $this->assertEquals($arrayXml['bar'][1], 'foo'); } - + public function testInvalidString() { $xml = <<markTestSkipped('Yaml test for Zend\Config skipped'); } - + if (constant('TESTS_ZEND_CONFIG_YAML_LIB_INCLUDE')) { require_once constant('TESTS_ZEND_CONFIG_YAML_LIB_INCLUDE'); } - + $yamlReader = explode('::', constant('TESTS_ZEND_CONFIG_READER_YAML_CALLBACK')); if (isset($yamlReader[1])) { $this->reader = new YamlReader(array($yamlReader[0], $yamlReader[1])); @@ -51,10 +38,10 @@ public function setUp() $this->reader = new YamlReader(array($yamlReader[0])); } } - + /** * getTestAssetPath(): defined by AbstractReaderTestCase. - * + * * @see AbstractReaderTestCase::getTestAssetPath() * @return string */ @@ -62,13 +49,13 @@ protected function getTestAssetPath($name) { return __DIR__ . '/TestAssets/Yaml/' . $name . '.yaml'; } - + public function testInvalidIniFile() { $this->setExpectedException('Zend\Config\Exception\RuntimeException'); $arrayIni = $this->reader->fromFile($this->getTestAssetPath('invalid')); } - + public function testFromString() { $yaml = <<reader->fromString($yaml); $this->assertEquals($arrayYaml['test'], 'foo'); $this->assertEquals($arrayYaml['bar'][0], 'baz'); $this->assertEquals($arrayYaml['bar'][1], 'foo'); } - + public function testFromStringWithSection() { $yaml = <<tmpfile; } - + public function tearDown() { - @unlink($this->getTestAssetFileName()); + if (file_exists($this->getTestAssetFileName())) { + if (!is_writable($this->getTestAssetFileName())) { + chmod($this->getTestAssetFileName(), 0777); + } + @unlink($this->getTestAssetFileName()); + } } - + public function testNoFilenameSet() { $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'No file name specified'); @@ -80,7 +72,7 @@ public function testFileNotValid() $this->setExpectedException('Zend\Config\Exception\RuntimeException'); $this->writer->toFile('.', new Config(array())); } - + public function testFileNotWritable() { $this->setExpectedException('Zend\Config\Exception\RuntimeException'); diff --git a/test/Writer/IniTest.php b/test/Writer/IniTest.php index aa35b5a..287ad4d 100644 --- a/test/Writer/IniTest.php +++ b/test/Writer/IniTest.php @@ -1,49 +1,33 @@ reader = new IniReader(); $this->writer = new IniWriter(); } - - public function testNoSection() { $config = new Config(array('test' => 'foo', 'test2' => array('test3' => 'bar'))); @@ -58,13 +42,12 @@ public function testNoSection() public function testWriteAndReadOriginalFile() { - $config = $this->reader->fromFile(__DIR__ . '/files/allsections.ini'); + $config = $this->reader->fromFile(__DIR__ . '/_files/allsections.ini'); $this->writer->toFile($this->getTestAssetFileName(), $config); $config = $this->reader->fromFile($this->getTestAssetFileName()); $this->assertEquals('multi', $config['all']['one']['two']['three']); - } } diff --git a/test/Writer/JsonTest.php b/test/Writer/JsonTest.php index ed89f00..a37ba6a 100644 --- a/test/Writer/JsonTest.php +++ b/test/Writer/JsonTest.php @@ -1,49 +1,33 @@ reader = new JsonReader(); $this->writer = new JsonWriter(); } - - public function testNoSection() { $config = new Config(array('test' => 'foo', 'test2' => array('test3' => 'bar'))); @@ -58,7 +42,7 @@ public function testNoSection() public function testWriteAndReadOriginalFile() { - $config = $this->reader->fromFile(__DIR__ . '/files/allsections.json'); + $config = $this->reader->fromFile(__DIR__ . '/_files/allsections.json'); $this->writer->toFile($this->getTestAssetFileName(), $config); diff --git a/test/Writer/PhpArrayTest.php b/test/Writer/PhpArrayTest.php index 5c9646b..2dae349 100644 --- a/test/Writer/PhpArrayTest.php +++ b/test/Writer/PhpArrayTest.php @@ -1,36 +1,23 @@ 'foo', 'bar' => array(0 => 'baz', 1 => 'foo'))); - + $configString = $this->writer->toString($config); // build string line by line as we are trailing-whitespace sensitive. @@ -62,7 +49,7 @@ public function testRender() $expected .= " 1 => 'foo',\n"; $expected .= " ),\n"; $expected .= ");\n"; - + $this->assertEquals($expected, $configString); } } diff --git a/test/Writer/TestAssets/PhpReader.php b/test/Writer/TestAssets/PhpReader.php new file mode 100644 index 0000000..909ff1e --- /dev/null +++ b/test/Writer/TestAssets/PhpReader.php @@ -0,0 +1,19 @@ +assertEquals($expected, $configString); } - + public function testSectionsToString() { $config = new Config(array(), true); @@ -74,9 +61,9 @@ public function testSectionsToString() $config->production->database->params->username = 'production'; $config->production->database->params->password = 'secret'; $config->production->database->params->dbname = 'dbproduction'; - + $configString = $this->writer->toString($config); - + $expected = << @@ -94,7 +81,7 @@ public function testSectionsToString() ECS; - + $this->assertEquals($expected, $configString); } } diff --git a/test/Writer/YamlTest.php b/test/Writer/YamlTest.php index 73e9a40..d0d9db1 100644 --- a/test/Writer/YamlTest.php +++ b/test/Writer/YamlTest.php @@ -1,58 +1,44 @@ markTestSkipped('Yaml test for Zend\Config skipped'); } - + if (constant('TESTS_ZEND_CONFIG_YAML_LIB_INCLUDE')) { require_once constant('TESTS_ZEND_CONFIG_YAML_LIB_INCLUDE'); } - + $yamlReader = explode('::', constant('TESTS_ZEND_CONFIG_READER_YAML_CALLBACK')); if (isset($yamlReader[1])) { $this->reader = new YamlReader(array($yamlReader[0], $yamlReader[1])); } else { $this->reader = new YamlReader(array($yamlReader[0])); } - + $yamlWriter = explode('::', constant('TESTS_ZEND_CONFIG_WRITER_YAML_CALLBACK')); if (isset($yamlWriter[1])) { $this->writer = new YamlWriter(array($yamlWriter[0], $yamlWriter[1])); @@ -75,7 +61,7 @@ public function testNoSection() public function testWriteAndReadOriginalFile() { - $config = $this->reader->fromFile(__DIR__ . '/files/allsections.yaml'); + $config = $this->reader->fromFile(__DIR__ . '/_files/allsections.yaml'); $this->writer->toFile($this->getTestAssetFileName(), $config); diff --git a/test/Writer/files/allsections.ini b/test/Writer/_files/allsections.ini similarity index 93% rename from test/Writer/files/allsections.ini rename to test/Writer/_files/allsections.ini index d4eef2d..4eaa75b 100644 --- a/test/Writer/files/allsections.ini +++ b/test/Writer/_files/allsections.ini @@ -1,26 +1,26 @@ -[all] -hostname = all -name = thisname -db.host = 127.0.0.1 -db.user = username -db.pass = password -db.name = live -one.two.three = multi - -[staging] -hostname = staging -db.name = dbstaging -debug = false - -[debug] -hostname = debug -debug = true -values.changed = yes -db.name = dbdebug -special.no = no -special.null = null -special.false = false - -[other_staging] -only_in = otherStaging -db.pass = anotherpwd +[all] +hostname = all +name = thisname +db.host = 127.0.0.1 +db.user = username +db.pass = password +db.name = live +one.two.three = multi + +[staging] +hostname = staging +db.name = dbstaging +debug = false + +[debug] +hostname = debug +debug = true +values.changed = yes +db.name = dbdebug +special.no = no +special.null = null +special.false = false + +[other_staging] +only_in = otherStaging +db.pass = anotherpwd diff --git a/test/Writer/files/allsections.json b/test/Writer/_files/allsections.json similarity index 100% rename from test/Writer/files/allsections.json rename to test/Writer/_files/allsections.json diff --git a/test/Writer/files/allsections.xml b/test/Writer/_files/allsections.xml similarity index 100% rename from test/Writer/files/allsections.xml rename to test/Writer/_files/allsections.xml diff --git a/test/Writer/files/allsections.yaml b/test/Writer/_files/allsections.yaml similarity index 100% rename from test/Writer/files/allsections.yaml rename to test/Writer/_files/allsections.yaml diff --git a/test/Writer/files/PhpReader.php b/test/Writer/files/PhpReader.php deleted file mode 100644 index d7e91fe..0000000 --- a/test/Writer/files/PhpReader.php +++ /dev/null @@ -1,9 +0,0 @@ - 'ein Hund', + 'two dogs' => 'zwei Hunde' +);