From 82a88b6cb111d8288f5d0cda74058a90534a068e Mon Sep 17 00:00:00 2001 From: uckelman Date: Sun, 9 May 2010 16:34:04 +0000 Subject: Added buildPost test. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6824 67b53d14-2c14-4ace-a08f-0dab2b34000c --- test/HTTP_POST_multipartTest.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/HTTP_POST_multipartTest.php b/test/HTTP_POST_multipartTest.php index af974ce..d4db17b 100644 --- a/test/HTTP_POST_multipartTest.php +++ b/test/HTTP_POST_multipartTest.php @@ -88,6 +88,42 @@ class HTTP_POST_multipartTest extends PHPUnit_Framework_TestCase { ) ); } + + /** + * @dataProvider providerBuildPost + */ + public function testBuildPost($parts, $expected, $ex) { + if ($ex) $this->setExpectedException($ex); + + list($boundary, $content) = + self::getMethod('buildPost')->invokeArgs(null, array($parts)); + + $actual = str_replace('boundary', $boundary, $content); + $this->assertEquals($expected, $actual); + } + + public function providerBuildPost() { + return array( + array(null, null, 'Exception'), + array( + array( + array( + 'name' => 'foo', + 'data' => 1 + ), + array( + 'name' => 'foo', + 'filename' => 'somename.txt', + 'mimetype' => 'text/plain', + 'charset' => 'utf-8', + 'encoding' => null, + 'data' => "blah blah blah\nblah blah blah" + ) + ), + "--boundary\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\n1\r\n--boundary\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"somename.txt\"\r\nContent-Type: text/plain; charset=\"utf-8\"\r\n\r\nblah blah blah\nblah blah blah\r\n--boundary--\r\n" + ) + ); + } } ?> -- cgit v1.2.3