Phue\Test\ClientTest::testGetLights PHP Method

testGetLights() public method

Test: Get lights
public testGetLights ( )
    public function testGetLights()
    {
        // Mock transport
        $mockTransport = $this->getMock('\\Phue\\Transport\\TransportInterface', array('sendRequest'));
        // Mock results for sendRequest
        // $mockResults = (object) [
        // '1' => new \stdClass,
        // '2' => new \stdClass,
        // ];
        $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 lights
        $lights = $this->client->getLights();
        // Ensure two lights
        $this->assertEquals(2, count($lights));
        // Ensure return type is an array of lights
        $this->assertContainsOnlyInstancesOf('\\Phue\\Light', $lights);
    }