Browse Source

Add tests for passing scalar values to toArray()

Tyler Stroud 10 years ago
parent
commit
d248808406
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/JMS/Serializer/Tests/Serializer/ArrayTest.php

+ 20 - 0
tests/JMS/Serializer/Tests/Serializer/ArrayTest.php

@@ -64,6 +64,26 @@ class ArrayTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($expected, $result);
     }
 
+    /**
+     * @dataProvider scalarValues
+     */
+    public function testToArrayWithScalar($input)
+    {
+        $result = $this->serializer->toArray($input);
+
+        $this->assertEquals(array($input), $result);
+    }
+
+    public function scalarValues()
+    {
+        return array(
+            array(42),
+            array(3.14159),
+            array('helloworld'),
+            array(true),
+        );
+    }
+
     public function testFromArray()
     {
         $data = array(