Phue\Test\ClientTest::testGetRules PHP Method

testGetRules() public method

Test: Get rules
public testGetRules ( )
    public function testGetRules()
    {
        // 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 rules
        $rules = $this->client->getRules();
        // Ensure two rules
        $this->assertEquals(2, count($rules));
        // Ensure return type is an array of rules
        $this->assertContainsOnlyInstancesOf('\\Phue\\Rule', $rules);
    }