/** * @covers Imbo\Http\Response\Formatter\Formatter::format * @covers Imbo\Http\Response\Formatter\JSON::formatListModel */ public function testCanFormatAnEmptyListModel() { $list = array(); $container = 'foo'; $model = $this->getMock('Imbo\\Model\\ListModel'); $model->expects($this->once())->method('getList')->will($this->returnValue($list)); $model->expects($this->once())->method('getContainer')->will($this->returnValue($container)); $this->assertSame('{"foo":[]}', $this->formatter->format($model)); }
/** * @dataProvider getStats * @covers Imbo\Http\Response\Formatter\Formatter::format * @covers Imbo\Http\Response\Formatter\JSON::formatStats */ public function testCanFormatAStatsModel($images, $users, $bytes, $customStats, $expectedJson) { $model = $this->getMock('Imbo\\Model\\Stats'); $model->expects($this->once())->method('getNumImages')->will($this->returnValue($images)); $model->expects($this->once())->method('getNumUsers')->will($this->returnValue($users)); $model->expects($this->once())->method('getNumBytes')->will($this->returnValue($bytes)); $model->expects($this->once())->method('getCustomStats')->will($this->returnValue($customStats)); $this->assertSame($this->formatter->format($model), $expectedJson); }
/** * @covers Imbo\Http\Response\Formatter\Formatter::format * @expectedException Imbo\Exception\InvalidArgumentException * @expectedExceptionMessage Unsupported model type * @expectedExceptionCode 500 */ public function testThrowsExceptionWhenModelIsNotSupported() { $formatter = new JSON($this->getMock('Imbo\\Helpers\\DateFormatter')); $formatter->format($this->getMock('Imbo\\Model\\ModelInterface')); }