diff options
author | Olivier Paroz <github@oparoz.com> | 2015-09-08 01:02:59 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-09-08 01:02:59 +0300 |
commit | 8b148c535a96083eb753fc1956bc72044c1bfc59 (patch) | |
tree | 81cf2ea38a59ebcb0dd07b4b9672809a5bb80916 /tests/unit | |
parent | 54f66b3b3fc9771c0af578de6b2765e07af6edf0 (diff) |
Add BOM test for ConfigParser
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/config/ConfigParserTest.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/unit/config/ConfigParserTest.php b/tests/unit/config/ConfigParserTest.php index 4362efba..db3a5619 100644 --- a/tests/unit/config/ConfigParserTest.php +++ b/tests/unit/config/ConfigParserTest.php @@ -56,21 +56,24 @@ class ConfigParserTest extends \Test\GalleryUnitTest { ]; return [ - [$emptyConfig, []], - [$noFeatures, []], - [$emptyFeatures, []], - [$features, $featureList], + [$emptyConfig, false, []], + [$noFeatures, false, []], + [$emptyFeatures, false, []], + [$emptyFeatures, true, []], + [$features, false, $featureList], + [$features, true, $featureList], ]; } /** * @dataProvider providesGetFeaturesListData * - * @param $config - * @param $expectedResult + * @param array $config + * @param bool $bom BOM in utf-8 files + * @param array $expectedResult */ - public function testGetFeaturesList($config, $expectedResult) { - $folder = $this->mockFolderWithConfig($config); + public function testGetFeaturesList($config, $bom, $expectedResult) { + $folder = $this->mockFolderWithConfig($config, $bom); $response = $this->configParser->getFeaturesList($folder, $this->configName); @@ -195,11 +198,13 @@ class ConfigParserTest extends \Test\GalleryUnitTest { $this->assertEquals($expectedResult, $response); } - private function mockFolderWithConfig($config) { + private function mockFolderWithConfig($config, $bom = false) { $file = $this->mockFile(212121); $yaml = new Dumper(); + $content = $yaml->dump($config); + $content = $bom ? chr(239) . chr(187) . chr(191) . $content : $content; $file->method('getContent') - ->willReturn($yaml->dump($config)); + ->willReturn($content); $folder = $this->mockFolder('home::user', 121212, [$file]); $folder->method('get') ->with($this->configName) |