Browse Source

Write testContentType() method for test contentType() method of Http/Client/FormData.php

sohelrana820 8 years ago
parent
commit
dac4bb31c1
1 changed files with 22 additions and 0 deletions
  1. 22 0
      tests/TestCase/Http/Client/FormDataTest.php

+ 22 - 0
tests/TestCase/Http/Client/FormDataTest.php

@@ -237,4 +237,26 @@ class FormDataTest extends TestCase
         ];
         $this->assertEquals(implode("\r\n", $expected), $result);
     }
+
+    /**
+     * Test contentType method.
+     *
+     * @return void
+     */
+    public function testContentType()
+    {
+        $data = new FormData();
+        $data->add('key', 'value');
+        $result = $data->contentType();
+        $expected = 'application/x-www-form-urlencoded';
+        $this->assertEquals($expected, $result);
+
+        $file = CORE_PATH . 'VERSION.txt';
+        $data = new FormData();
+        $data->addFile('upload', fopen($file, 'r'));
+        $boundary = $data->boundary();
+        $result = $data->contentType();
+        $expected = 'multipart/form-data; boundary="' . $boundary . '"';
+        $this->assertEquals($expected, $result);
+    }
 }