public function testPass() { $listener = new MockSimpleSocket(); $fullpath = realpath(dirname(__FILE__) . '/support/test1.php'); $testpath = EclipseReporter::escapeVal($fullpath); $expected = "{status:\"pass\",message:\"pass1 at [{$testpath} line 4]\",group:\"{$testpath}\",case:\"test1\",method:\"test_pass\"}"; //this should work...but it doesn't so the next line and the last line are the hacks //$listener->expectOnce('write',array($expected)); $listener->returnsByValue('write', -1); $pathparts = pathinfo($fullpath); $filename = $pathparts['basename']; $test = new TestSuite($filename); $test->addFile($fullpath); $test->run(new EclipseReporter($listener)); $this->assertEqual($expected, $listener->output); }
public function testRedirectWithPort() { $socket = new MockSimpleSocket(); $socket->returnsByValueAt(0, 'read', "HTTP/1.1 301 OK\r\n"); $socket->returnsByValueAt(1, 'read', "Content-Type: text/plain\r\n"); $socket->returnsByValueAt(2, 'read', "Location: http://www.somewhere-else.com:80/\r\n"); $socket->returnsByValueAt(3, 'read', "Connection: close\r\n"); $socket->returnsByValueAt(4, 'read', "\r\n"); $socket->returnsByValue('read', ''); $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding()); $headers = $response->getHeaders(); $this->assertTrue($headers->isRedirect()); $this->assertEqual($headers->getLocation(), 'http://www.somewhere-else.com:80/'); }