/** * @covers ::translate * @covers ::_translateHeaders * @covers ::_translateURI * @covers ::_translateReferer */ public function test_translate() { $Expected = array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_MAXREDIRS => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array('Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8', 'Accept-Language: en-us, en;q=0.5', 'Cache-Control: max-age=0', 'Content-Type: application/x-www-form-urlencoded'), CURLOPT_ENCODING => '', CURLOPT_AUTOREFERER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYPEER => 1, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_URL => 'http://example.com', CURLOPT_PORT => 1000, CURLOPT_USERPWD => 'user:pass', CURLOPT_REFERER => 'about:nothing', CURLOPT_USERAGENT => 'Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36', CURLOPT_POSTFIELDS => 'foo=bar', CURLOPT_COOKIEFILE => $this->Client->createCookieFile()->getPathname(), CURLOPT_COOKIEJAR => $this->Client->createCookieFile()->getPathname()); $Factory = new RequestFactory(); $Browser = new Nexus($this->Client, new Config(array('MaxHistory' => 10))); $Request = $Factory->createPOST(new GenericURI('http://*****:*****@example.com:1000'), new GenericURI('about:nothing'), array('foo' => 'bar'), $Browser->createHeaders()); $this->Client->send($Request); $this->assertEquals($Expected, $this->Client->translate($Request), 'cURL::translate() Returned an invalid value'); unset($Request->Referer); $Request->getHeader()->offsetSet('Referer', new Referer(new GenericURI('about:nothing'))); $this->assertEquals($Expected, $this->Client->translate($Request), 'cURL::translate() Returned an invalid value'); $Request->getHeader()->offsetUnset('Referer'); unset($Expected[CURLOPT_REFERER]); $this->assertEquals($Expected, $this->Client->translate($Request), 'cURL::translate() Returned an invalid value'); # Inalid request $this->assertSame(array(), $this->Client->translate($Factory->createGET(new GenericURI('about:nothing'), new GenericURI('about:nothing'))), 'cURL::translate() Returned an invalid value'); }
/** * @coversNothing */ public function test_basic() { $this->assertTrue($this->Browser->go('http://a'), 'IBrowser::go() Should return true'); $this->assertTrue($this->Browser->go('http://a/b'), 'IBrowser::go() Should return true'); $this->assertTrue($this->Browser->go('http://a/b/c'), 'IBrowser::go() Should return true'); $this->assertTrue($this->Browser->go('http://a/b/c/d?q#f'), 'IBrowser::go() Should return true'); $this->assertEquals('http://a/b/c/d?q=#f', strval($this->Browser->Base), 'IBrowser::$Base Should equal `http://a/b/c/d?q#f`'); $this->assertEquals('Heading', $this->Browser->filter('h1')->offsetGet(0)->textContent, 'IBrowser::go() Failed to set page'); $this->assertTrue($this->Browser->back(), 'IBrowser::back() Should return true'); $this->assertEquals('http://a/b/c', strval($this->Browser->Base), 'IBrowser::$Base Should equal `http://a/b/c/d?q#f`'); $this->assertEquals('Heading', $this->Browser->filter('h1')->offsetGet(0)->textContent, 'IBrowser::go() Failed to set page'); $this->assertTrue($this->Browser->back(), 'IBrowser::back() Should return true'); $this->assertEquals('http://a/b', strval($this->Browser->Base), 'IBrowser::$Base Should equal `http://a/b/c/d?q#f`'); $this->assertEquals('Heading', $this->Browser->filter('h1')->offsetGet(0)->textContent, 'IBrowser::go() Failed to set page'); $this->assertTrue($this->Browser->forward(), 'IBrowser::back() Should return true'); $this->assertEquals('http://a/b/c', strval($this->Browser->Base), 'IBrowser::$Base Should equal `http://a/b/c/d?q#f`'); $this->assertEquals('Heading', $this->Browser->filter('h1')->offsetGet(0)->textContent, 'IBrowser::go() Failed to set page'); }