X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=phpunit%2FMessageBodyTest.php;h=1764ef6027b89128915420ce2667676fbb27ab3c;hb=87702149e0c422104aec0ddb7391f91392be0376;hp=0218af1bc3550908f333bca3d461f9b8d06bce72;hpb=61067d19cf03ad876954c2644ff9e37942b2ad67;p=m6w6%2Fext-http diff --git a/phpunit/MessageBodyTest.php b/phpunit/MessageBodyTest.php index 0218af1..1764ef6 100644 --- a/phpunit/MessageBodyTest.php +++ b/phpunit/MessageBodyTest.php @@ -29,9 +29,9 @@ class MessageBodyTest extends PHPUnit_Framework_TestCase { $this->assertEquals(3, $this->temp->append("yes")); } - function testAdd() { + function testAddForm() { $this->assertTrue( - $this->temp->add( + $this->temp->addForm( array( "foo" => "bar", "more" => array( @@ -78,6 +78,20 @@ class MessageBodyTest extends PHPUnit_Framework_TestCase { ); } + function testAddPart() { + $this->temp->addPart(new http\Message("This: is a header\n\nand this is the data\n")); + $this->assertStringMatchesFormat( + "--%x.%x\r\n". + "This: is a header\r\n". + "Content-Length: 21\r\n". + "\r\n". + "and this is the data\n\r\n". + "--%x.%x--\r\n". + "", + str_replace("\r", "", $this->temp) + ); + } + function testEtag() { $s = stat(__FILE__); $this->assertEquals( @@ -110,4 +124,11 @@ class MessageBodyTest extends PHPUnit_Framework_TestCase { function testClone() { $this->assertEquals((string) $this->file, (string) clone $this->file); } + + function testGetResource() { + $stream = $this->file->getResource(); + $this->assertTrue(is_resource($stream)); + $stat = fstat($stream); + $this->assertEquals(filesize(__FILE__), $stat["size"]); + } }