/** * Test: Send command * * @covers \Phue\Command\CreateSchedule::__construct * @covers \Phue\Command\CreateSchedule::send */ public function testSend() { $command = new CreateSchedule('Dummy!', '2012-12-30T10:11:12', $this->mockCommand); $command->description('Description!'); // Stub transport's sendRequest usage $this->mockTransport->expects($this->once())->method('sendRequest')->with($this->equalTo("{$this->mockClient->getUsername()}/schedules"), $this->equalTo(TransportInterface::METHOD_POST), $this->equalTo((object) ['name' => 'Dummy!', 'description' => 'Description!', 'time' => '2012-12-30T10:11:12', 'command' => ['method' => TransportInterface::METHOD_POST, 'address' => "/api/endpoint", 'body' => "Dummy"]]))->will($this->returnValue(4)); // Send command and get response $scheduleId = $command->send($this->mockClient); // Ensure we have a schedule id $this->assertEquals($scheduleId, 4); }