Author: Christer Edvartsen (cogo@starzinger.net)
Inheritance: extends Formatter, implements Imbo\Http\Response\Formatter\FormatterInterface
Example #1
0
 /**
  * @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));
 }
Example #2
0
 /**
  * @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);
 }
Example #3
0
 /**
  * @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'));
 }