浏览代码

Rename and add test cases

Kieu Anh Tuan 12 年之前
父节点
当前提交
136793fe63

+ 2 - 2
src/JMS/Serializer/Naming/PropertyNamingStrategy.php

@@ -1,10 +1,10 @@
 <?php
-namespace JMS\Serializer\Serializer\Naming;
+namespace JMS\Serializer\Naming;
 
 use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
 use JMS\Serializer\Metadata\PropertyMetadata;
 
-class PropertyNamingStrategy implements PropertyNamingStrategyInterface
+class IdenticalPropertyNamingStrategy implements PropertyNamingStrategyInterface
 {
     public function translateName(PropertyMetadata $property)
     {

+ 28 - 0
tests/JMS/Serializer/Tests/Serializer/Naming/IdenticalPropertyNamingStrategyTest.php

@@ -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));
+    }
+}