diff options
Diffstat (limited to 'test/HTTP_POST_multipartTest.php')
-rw-r--r-- | test/HTTP_POST_multipartTest.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/HTTP_POST_multipartTest.php b/test/HTTP_POST_multipartTest.php new file mode 100644 index 0000000..373848c --- /dev/null +++ b/test/HTTP_POST_multipartTest.php @@ -0,0 +1,34 @@ +<?php + +require_once('PHPUnit/Framework.php'); +require_once('src/HTTP_POST_multipart.php'); + +class HTTP_POST_multipartTest extends PHPUnit_Framework_TestCase { + + public static function setUpBeforeClass() { + # Set all methods to be public so we can test them + $class = new ReflectionClass('HTTP_POST_multipart'); + foreach ($class->getMethods() as $method) { + $method->setAccessible(true); + } + } + + /** + * @dataProvider providerBuildDataPart + */ + public function testBuildDataPart($name, $data, $expected, $ex) { + if ($ex) $this->setExpectedException($ex); + $poster = new HTTP_POST_multipart(); + $this->assertEquals($expected, $poster->buildDataPart($name, $data)); + } + + public function providerBuildDataPart() { + return array( + array(null, null, 'Exception'), + array('foo', 1, "Content-Disposition: form-data; name=\"foo\"\r\n\r\n1\r\n") + ); + } + +} + +?> |