Skip to content

Commit

Permalink
Merge pull request #37 from passkey1510/master
Browse files Browse the repository at this point in the history
Add PropertyNamingStrategy
  • Loading branch information
schmittjoh committed Feb 14, 2013
2 parents 71388cc + 136793f commit f95ba24
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/JMS/Serializer/Naming/IdenticalPropertyNamingStrategy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace JMS\Serializer\Naming;

use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use JMS\Serializer\Metadata\PropertyMetadata;

class IdenticalPropertyNamingStrategy implements PropertyNamingStrategyInterface
{
public function translateName(PropertyMetadata $property)
{
return $property->name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace JMS\Serializer\Tests\Serializer\Naming;

use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;

class IdenticalPropertyNamingStrategyTest extends \PHPUnit_Framework_TestCase
{
public function providePropertyNames()
{
return array(
array('createdAt'),
array('my_field'),
array('identical')
);
}

/**
* @dataProvider providePropertyNames
*/
public function testTranslateName($propertyName)
{
$mockProperty = $this->getMockBuilder('JMS\Serializer\Metadata\PropertyMetadata')->disableOriginalConstructor()->getMock();
$mockProperty->name = $propertyName;

$strategy = new IdenticalPropertyNamingStrategy();
$this->assertEquals($propertyName, $strategy->translateName($mockProperty));
}
}

0 comments on commit f95ba24

Please # to comment.