Phue\Test\Command\GetNewLightsTest::setUp PHP Метод

setUp() публичный Метод

Set up
public setUp ( )
    public function setUp()
    {
        $this->getNewLights = new GetNewLights();
        // Mock client
        $this->mockClient = $this->getMock('\\Phue\\Client', array('getUsername', 'getTransport'), array('127.0.0.1'));
        // Mock transport
        $this->mockTransport = $this->getMock('\\Phue\\Transport\\TransportInterface', array('sendRequest'));
        // Stub client's getUsername method
        $this->mockClient->expects($this->any())->method('getUsername')->will($this->returnValue('abcdefabcdef01234567890123456789'));
        // Stub client's getTransport method
        $this->mockClient->expects($this->any())->method('getTransport')->will($this->returnValue($this->mockTransport));
        // Mock transport results
        $mockTransportResults = (object) array('1' => (object) array('name' => 'Sensor 1'), '2' => (object) array('name' => 'Sensor 2'), 'lastscan' => 'active');
        // Stub transport's sendRequest usage
        $this->mockTransport->expects($this->once())->method('sendRequest')->with($this->equalTo("/api/{$this->mockClient->getUsername()}/lights/new"))->will($this->returnValue($mockTransportResults));
    }