/** * @test */ public function itShouldReturnAnArrayRepresentationOfARequest() { $query = new Query(); $query = $query->addOr($query->addAnd(array('name', 'like', '*.at'), array('created', 'lt', '2012-12-*')), array('name', 'like', '*.de')); $task = new Request\Task\DomainInquireList(); $task->withView(array('offset' => 0, 'limit' => 20, 'children' => 0))->withKeys(array('created', 'payable'))->withQuery($query); $request = new Request($task, null, '0987654321'); $request->withReplyTo('*****@*****.**'); $expectedRequestArray = array('auth' => array(), 'task' => array('code' => '0105', 'view' => array('offset' => 0, 'limit' => 20, 'children' => 0), 'key' => array('created', 'payable'), 'where' => array('or' => array(array('and' => array(array('key' => 'name', 'operator' => 'like', 'value' => '*.at'), array('key' => 'created', 'operator' => 'lt', 'value' => '2012-12-*'))), array('key' => 'name', 'operator' => 'like', 'value' => '*.de')))), 'ctid' => '0987654321', 'reply_to' => '*****@*****.**'); $output = $request->asArray(); $this->assertEquals($expectedRequestArray, $output); }
/** * @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); }
/** * @test */ public function itShouldMakeADomainInquireListCall() { $taskName = 'DomainInquireList'; $responseXml = $this->getResponseXml($taskName); $expectedRequest = $this->getExpectedRequestXml($taskName); $expectedResult = new Client\Response(array('result' => array('data' => array('summary' => '2', 'domain' => array(array('owner' => array('user' => 'customer', 'context' => '4'), 'name' => 'example.com', 'created' => '2005-06-16 16:47:50'), array('owner' => array('user' => 'customer2', 'context' => '4'), 'name' => 'example.com', 'created' => '2005-06-16 16:47:50', 'domainsafe' => 'true', 'dnssec' => 'false'))), 'status' => array('text' => 'Domaindaten wurden erfolgreich ermittelt.', 'type' => 'success', 'code' => 'S0105')))); $fakeResponse = $this->aStub('Buzz\\Message\\MessageInterface')->with('getContent', $responseXml); $sender = $this->aStub('Buzz\\Browser')->with('post', $fakeResponse)->build(); $sender->expects($this->once())->method('post')->with($this->anything(), $this->anything(), $expectedRequest); $client = $this->buildClient($sender); $query = new Query(); $query = $query->addOr($query->addAnd(array('name', 'like', '*.at'), array('created', 'lt', '2012-12-*')), array('name', 'like', '*.de')); $task = new Request\Task\DomainInquireList(); $task->withView(array('offset' => 0, 'limit' => 20, 'children' => 0))->withKeys(array('created', 'payable'))->withQuery($query); $this->assertEquals($expectedResult, $client->call($task)); }