function testEmptyMultipartEncodingWritesEndBoundaryContentLength() { $socket = new MockSimpleSocket(); $socket->expectArgumentsAt(0, 'write', array("Content-Length: 14\r\n")); $socket->expectArgumentsAt(1, 'write', array("Content-Type: multipart/form-data, boundary=boundary\r\n")); $encoding = new SimpleMultipartEncoding(array(), 'boundary'); $encoding->writeHeadersTo($socket); }
function testContentHeadersCalculated() { $socket = new MockSimpleSocket(); $socket->expectArgumentsAt(0, 'write', array("Content-Length: 3\r\n")); $socket->expectArgumentsAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n")); $socket->expectArgumentsAt(2, 'write', array("\r\n")); $socket->expectArgumentsAt(3, 'write', array("a=A")); $route = new MockSimpleRoute(); $route->setReturnReference('createConnection', $socket); $route->expectArguments('createConnection', array('POST', 15)); $request = new SimpleHttpRequest($route, new SimplePostEncoding(array('a' => 'A'))); $this->assertIsA($request->fetch(15), 'SimpleHttpResponse'); }