Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support objects with integer keys. Fixes #1
- Loading branch information
Marius Balčytis
committed
Oct 7, 2019
1 parent
ae6ad50
commit 7edfce7
Showing
4 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
checks: | ||
php: | ||
code_rating: true | ||
|
||
filter: | ||
excluded_paths: | ||
- tests/* | ||
- vendor/* | ||
|
||
build: | ||
environment: | ||
php: '7.3' | ||
|
||
dependencies: | ||
before: | ||
- composer install | ||
- mkdir -p build/logs | ||
|
||
tests: | ||
override: | ||
- | ||
command: 'bin/phpunit --coverage-clover build/logs/clover.xml' | ||
coverage: | ||
file: 'build/logs/clover.xml' | ||
format: 'clover' |
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
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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Paysera\Component\Normalization\Tests; | ||
|
||
use Mockery; | ||
use Mockery\Adapter\Phpunit\MockeryTestCase; | ||
use Paysera\Component\Normalization\CoreNormalizer; | ||
use Paysera\Component\Normalization\DataFilter; | ||
use Paysera\Component\Normalization\NormalizationContext; | ||
use stdClass; | ||
|
||
class DataFilterTest extends MockeryTestCase | ||
{ | ||
|
||
/** | ||
* @dataProvider providerForFilterDataWithoutFiltering | ||
* @param string $expected | ||
* @param mixed $input | ||
*/ | ||
public function testFilterDataWithoutFiltering(string $expected, $input) | ||
{ | ||
$normalizer = Mockery::mock(CoreNormalizer::class); | ||
$context = new NormalizationContext($normalizer); | ||
|
||
$dataFilter = new DataFilter(); | ||
|
||
$output = $dataFilter->filterData($input, $context); | ||
$this->assertEquals($expected, json_encode($output)); | ||
} | ||
|
||
public function providerForFilterDataWithoutFiltering() | ||
{ | ||
return [ | ||
['{}', new stdClass()], | ||
['[]', []], | ||
['{"a":"b"}', ['a' => 'b']], | ||
['{"a":"b","1":2}', ['a' => 'b', 1 => 2]], | ||
['[1,2]', [0 => 1, 1 => 2]], | ||
['{"0":1,"2":2}', [0 => 1, 2 => 2]], | ||
]; | ||
} | ||
} |