/** * @test * * @expectedException Uphold\Exception\UpholdClientException * @expectedExceptionMessage foobar */ public function shouldThrownAnExceptionIfHttpCodeIsNot412Or416OnCount() { $client = $this->getMockBuilder('Uphold\\UpholdClient')->disableOriginalConstructor()->setMethods(array('get'))->getMock(); $client->expects($this->once())->method('get')->will($this->throwException(new UpholdClientException('foobar', 'qux', 500))); $pager = new Paginator($client, '/path'); $pager->count(); }
/** * @test */ public function shouldReturnCount() { $contentRange = array('count' => 200, 'end' => 19, 'start' => 0); $response = $this->getMockBuilder('Uphold\\HttpClient\\Message\\Response')->disableOriginalConstructor()->getMock(); $response->expects($this->once())->method('getContentRange')->will($this->returnValue($contentRange)); $client = $this->getMockBuilder('Uphold\\UpholdClient')->disableOriginalConstructor()->setMethods(array('get'))->getMock(); $client->expects($this->once())->method('get')->with('/path', array(), array('range' => 'items=0-1'))->will($this->returnValue($response)); $pager = new Paginator($client, '/path'); $this->assertEquals($contentRange['count'], $pager->count()); }