/** * @test */ public function itShouldReturnGivenAuth() { $auth = array('username' => 'customer', 'password' => 'password', 'context' => 4); $request = new Request(); $request->setAuth($auth); $this->assertEquals($auth, $request->getAuth()); }
/** * @param Task $task * @return Response */ public function call(Task $task) { $request = new Request($task); $request->setAuth($this->accountInfo->getAuthInfo()); $url = $this->accountInfo->getUrl(); $response = $this->delivery->send($url, $request); return new Response($response); }
/** * @test */ public function itShouldSendARequestWithTheGivenTaskAndTheAuthInformation() { $task = new Request\Task\DomainInquireList(); $authInfo = array('user', 'password', 2); $this->accountInfo->with('getAuthInfo', $authInfo); $request = new Request($task); $request->setAuth($authInfo); $this->delivery = $this->delivery->build(); $this->delivery->expects($this->once())->method('send')->with($this->anything(), $request); $this->buildClient()->call($task); }
/** * @test */ public function itShouldWork() { $query = new Query(); $task = new Request\Task\DomainInquireList(); $task->withView(array('offset' => 0, 'limit' => 20, 'children' => 0))->withKeys(array('created', 'updated'))->withQuery($query->addOr($query->addAnd(array('name', 'like', '*.at'), array('created', 'lt', '2012-12-*')), array('name', 'like', '*.de'))); $request = new Request($task); $request->setAuth(array('user' => 'username', 'password' => 'password', 'context' => 'context')); $expectedXml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <request> <auth> <user>username</user> <password>password</password> <context>context</context> </auth> <task> <code>0105</code> <view> <offset>0</offset> <limit>20</limit> <children>0</children> </view> <key>created</key> <key>updated</key> <where> <or> <and> <key>name</key> <operator>like</operator> <value>*.at</value> </and> <and> <key>created</key> <operator>lt</operator> <value>2012-12-*</value> </and> </or> <or> <key>name</key> <operator>like</operator> <value>*.de</value> </or> </where> </task> </request> XML; $array2Xml = new Array2Xml(); $generatedXml = $array2Xml->buildXml('request', $request->asArray())->saveXML(); $this->assertXmlStringEqualsXmlString($expectedXml, $generatedXml); }
/** * @param string $url * @param Client\Request $request * @return string */ public function send($url, Request $request) { $xml = $this->arrayXmlConverter->convert($request->asArray()); $response = $this->sender->post($url, array(), $xml); return $this->xmlToArrayConverter->convert($response->getContent()); }