/** * @test */ public function canPostCommand() { $responsetMock = $this->getMock('\\Guzzle\\Http\\Message\\Response', array(), array(), '', false); $resquestMock = $this->getMock('\\Guzzle\\Http\\Message\\Request', array('setAuth', 'send'), array(), '', false); $resquestMock->expects($this->once())->method('setAuth')->will($this->returnCallback(function () use($resquestMock) { return $resquestMock; })); $resquestMock->expects($this->once())->method('send')->will($this->returnCallback(function () use($responsetMock) { return $responsetMock; })); $expectedArguments = array('name' => 'AddToCrawlerQueue', 'arguments' => array('documentIds' => array(100, 101))); $restClient = $this->getMock('\\Guzzle\\Http\\Client', array('post', 'setAuth', 'send'), array('http://api.searcperience.com/')); $restClient->expects($this->once())->method('post')->with('/{customerKey}/commands', null, $expectedArguments)->will($this->returnCallback(function ($url, $foo, $arguments) use($resquestMock) { return $resquestMock; })); $command = new AddToUrlQueueCommand(); $command->addDocumentId(100); $command->addDocumentId(101); $this->commandBackend->injectRestClient($restClient); $this->commandBackend->post($command); }
/** * @test */ public function canGetArguments() { $this->addToUrlQueueCommand->addDocumentId(100); $this->addToUrlQueueCommand->addDocumentId(101); $this->assertEquals(array('documentIds' => array(100, 101)), $this->addToUrlQueueCommand->getArguments()); }