Phue\Test\ClientTest::testGetSensors PHP Method

testGetSensors() public method

Test: Get sensors
public testGetSensors ( )
    public function testGetSensors()
    {
        // Mock transport
        $mockTransport = $this->getMock('\\Phue\\Transport\\TransportInterface', array('sendRequest'));
        // Mock results for sendRequest
        $mockResults = (object) array('1' => new \stdClass(), '2' => new \stdClass());
        // Stub transports sendRequest method
        $mockTransport->expects($this->once())->method('sendRequest')->will($this->returnValue($mockResults));
        // Set transport
        $this->client->setTransport($mockTransport);
        // Get sensors
        $sensors = $this->client->getSensors();
        // Ensure two sensors
        $this->assertEquals(2, count($sensors));
        // Ensure return type is an array of sensors
        $this->assertContainsOnlyInstancesOf('\\Phue\\Sensor', $sensors);
    }