diff --git a/changelog.md b/changelog.md index a8d5bf7..8cc2646 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [1.2.2] - 2019-07-08 +### Changed +- fix error in `WrapperDataProcessor` + ## [1.2.1] - 2019-07-08 ### Changed - fix errors in `generate-ide-test-containers` @@ -40,6 +44,7 @@ All notable changes to this project will be documented in this file. - command `generate-ide-test-containers` that generate service file for IDE used to autocomplete +[1.2.2]: https://github.com/raptor-mvk/test-utils/compare/v1.2.1...v1.2.2 [1.2.1]: https://github.com/raptor-mvk/test-utils/compare/v1.2.0...v1.2.1 [1.2.0]: https://github.com/raptor-mvk/test-utils/compare/v1.1.0...v1.2.0 [1.1.0]: https://github.com/raptor-mvk/test-utils/compare/v1.0.0...v1.1.0 diff --git a/readme.md b/readme.md index 3077867..981d079 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# Raptor Test Utils v1.2.1 +# Raptor Test Utils v1.2.2 (c) Mikhail Kamorin aka raptor_MVK diff --git a/src/TestUtils/DataProcessor/WrapperDataProcessor.php b/src/TestUtils/DataProcessor/WrapperDataProcessor.php index 0518e57..c559560 100644 --- a/src/TestUtils/DataProcessor/WrapperDataProcessor.php +++ b/src/TestUtils/DataProcessor/WrapperDataProcessor.php @@ -27,6 +27,6 @@ protected function processTestCase(array $element, string $name, ?array $default if ($this->hasProcessed($name)) { throw new DataParseException("Non-unique test name $name was found."); } - $this->addProcessed($name, new TestDataContainer(array_merge($default ?? [], $element))); + $this->addProcessed($name, [new TestDataContainer(array_merge($default ?? [], $element))]); } } diff --git a/tests/TestUtils/DataProcessor/WrapperDataProcessorTests.php b/tests/TestUtils/DataProcessor/WrapperDataProcessorTests.php index b4fd290..f9d574b 100644 --- a/tests/TestUtils/DataProcessor/WrapperDataProcessorTests.php +++ b/tests/TestUtils/DataProcessor/WrapperDataProcessorTests.php @@ -8,6 +8,7 @@ use Raptor\TestUtils\Exceptions\DataParseException; use Raptor\TestUtils\ExtraAssertions; use Raptor\TestUtils\TestDataContainer\TestDataContainer; +use function is_array; /** * @author Mikhail Kamorin aka raptor_MVK @@ -69,19 +70,24 @@ private function prepareNonUniqueNameTestData(): array } /** - * Checks that method _process_ returns array consists of instances of _TestContainer_. + * Checks that method _process_ returns array of arrays, each of which contains single TestDataContainer instance. + * + * @param string $json * * @dataProvider correctDataProvider */ - public function testProcessReturnsResultWithTestContainersAsElements(): void + public function testProcessReturnsArrayOfArraysContainingSingleTestDataContainerInstance(string $json): void { - $testData = $this->prepareMultiResultTestJson(); $dataProcessor = new WrapperDataProcessor(); - $actual = $dataProcessor->process($testData); + $processed = $dataProcessor->process($json); - $message = 'All elements of resulting array should be instances of TestContainer'; - static::assertContainsOnly(TestDataContainer::class, $actual, false, $message); + $result = true; + foreach ($processed as $value) { + $result = $result && is_array($value) && (count($value) === 1) && + ($value[0] instanceof TestDataContainer); + } + static::assertTrue($result, 'Process should return array of arrays with single element'); } /** @@ -177,8 +183,8 @@ public function testProcessReturnsCorrectResult(string $json, array $expected): $actual = []; foreach ($processed as $key => $value) { - /** @var TestDataContainer $value */ - $actual[$key] = $value->allData(); + /** @var array $value */ + $actual[$key] = $value[0]->allData(); } static::assertArraysAreSame($expected, $actual); } diff --git a/tests/TestUtils/WithDataLoaderTests.php b/tests/TestUtils/WithDataLoaderTests.php index cad92dd..b7c4ed9 100644 --- a/tests/TestUtils/WithDataLoaderTests.php +++ b/tests/TestUtils/WithDataLoaderTests.php @@ -33,8 +33,9 @@ public function testLoadReturnsCorrectData(): void $content = $this->prepareFileContent(); $this->addFileToVFS($filename, null, $content); $fullFilename = $this->getFullPath($filename); - $extractData = static function (TestDataContainer $container) { - return $container->allData(); + $extractData = static function (array $container) { + /** @var TestDataContainer[] $container */ + return $container[0]->allData(); }; $expectedData = $this->prepareExpectedResult();