/** * @test */ public function Can_invoke_get() { // arrange $uri = 'http://example.com/foo/bar?baz=qux'; MockPlug::register(MockRequest::newMockRequest(HttpPlug::VERB_GET, $uri, []), MockResponse::newMockResponse(HttpPlug::HTTPSUCCESS, [], ['page'])); $Plug = HttpPlug::newPlug($uri); // act $Result = new XArray($Plug->get()); // assert $this->assertEquals(200, $Result->getVal('status')); $this->assertEquals('page', $Result->getVal('body')); }
/** * @test */ public function Add_multiple_path_segments_to_existing_query_2() { // arrange $Plug = HttpPlug::newPlug('http://foo.com?a=b&c=d'); // act $Plug = $Plug->at('bar', 'qux')->at('foo', 'fred'); // assert /** @var HttpPlug $Plug */ $this->assertEquals('http://foo.com/bar/qux/foo/fred?a=b&c=d', $Plug->getUri()); }
/** * @test */ public function Add_multiple_params_to_existing_query() { // arrange $Plug = HttpPlug::newPlug('http://foo.com?a=b&c=d'); // act $Plug = $Plug->with('bar', 'qux')->with('fred', 'foo'); // assert /** @var HttpPlug $Plug */ $this->assertEquals('http://foo.com/?a=b&c=d&bar=qux&fred=foo', $Plug->getUri()); }