Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
raptor-mvk committed Jul 8, 2019
2 parents 5be15be + e7eebec commit 2b184e4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Raptor Test Utils v1.2.1
# Raptor Test Utils v1.2.2

(c) Mikhail Kamorin aka raptor_MVK

Expand Down
2 changes: 1 addition & 1 deletion src/TestUtils/DataProcessor/WrapperDataProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))]);
}
}
22 changes: 14 additions & 8 deletions tests/TestUtils/DataProcessor/WrapperDataProcessorTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/TestUtils/WithDataLoaderTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 2b184e4

Please sign in to comment.