Phue\Command\CreateSensor::send PHP Method

send() public method

Send command
public send ( Client $client ) : integer
$client Phue\Client Phue Client
return integer Sensor Id
    public function send(Client $client)
    {
        $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors", TransportInterface::METHOD_POST, (object) array_merge($this->attributes, array('state' => $this->state, 'config' => $this->config)));
        return $response->id;
    }

Usage Example

Example #1
0
 /**
  * Test: Send
  *
  * @covers \Phue\Command\CreateSensor::send
  */
 public function testSend()
 {
     // Mock client
     $mockClient = Mockery::mock('\\Phue\\Client', array('getUsername' => 'abcdefabcdef01234567890123456789'))->makePartial();
     // Mock client commands
     $mockClient->shouldReceive('getTransport->sendRequest')->andReturn((object) array('id' => '5'));
     $command = new CreateSensor('test');
     $this->assertEquals('5', $command->send($mockClient));
 }