/** * @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')); }
/** * @param string $verb * @param mixed $xml - XML encoded array or XML string * @return array - request response */ protected function invokeXml($verb, $xml) { if (is_array($xml)) { $XArray = new XArray($xml); $xml = $XArray->toXml(); } // @note (guerrics): adding empty check since dream dies on empty xml bodies $contentType = !empty($xml) && empty($this->headers[self::HEADER_CONTENT_TYPE]) ? 'application/xml' : null; return $this->invoke($verb, $xml, $contentType); }
/** * @param string $key * @return string */ public function getXml($key = '') { if ($key == '') { return $this->toXml(); } $val = $this->getVal($key, null); $XArray = new XArray($val); return $XArray->toXml(); }