Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic refactoring to make code simpler. #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Added some more coverage.
  • Loading branch information
evangelion1204 committed Jun 14, 2015
commit 522b88ea72b40bd69612a8d3771cae77a6c84b70
34 changes: 32 additions & 2 deletions tests/evangelion1204/Normalizer/ArrayNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@


use evangelion1204\Normalizer\ArrayNormalizer;
use Prophecy\Argument;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

class ArrayNormalizerTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -21,7 +23,11 @@ class ArrayNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testNormalize($src, $expected)
{
$normalizer = new ArrayNormalizer();
$mock = $this->prophesize('Symfony\Component\Serializer\NameConverter\NameConverterInterface');
$mock->normalize(Argument::any())->will(function ($args) {
return $args[0];
});
$normalizer = new ArrayNormalizer(null, null);

$this->assertEquals($expected, $normalizer->normalize($src));
}
Expand All @@ -31,7 +37,12 @@ public function testNormalize($src, $expected)
*/
public function testDenormalize($expected, $src)
{
$normalizer = new ArrayNormalizer();
$mock = $this->prophesize('Symfony\Component\Serializer\NameConverter\NameConverterInterface');
$mock->denormalize(Argument::any())->will(function ($args) {
return $args[0];
});

$normalizer = new ArrayNormalizer(null, $mock->reveal());

$this->assertEquals($expected, $normalizer->denormalize($src));
}
Expand All @@ -46,4 +57,23 @@ public function defaultDataProvider()
);
}

/**
* @dataProvider scalarDataProvider
*/
public function testDenormalizeScalar($value)
{
$normalizer = new ArrayNormalizer();

$this->assertEquals($value, $normalizer->denormalize($value));
}

public function scalarDataProvider()
{
return array(
array(1),
array(true),
array('string'),
);
}

}