ImboUnitTest\Http\Response\Formatter\JSONTest::testCanFormatAUserModel PHP Method

testCanFormatAUserModel() public method

    public function testCanFormatAUserModel()
    {
        $formattedDate = 'Wed, 30 Jan 2013 10:53:11 GMT';
        $date = new DateTime($formattedDate);
        $model = $this->getMock('Imbo\\Model\\User');
        $model->expects($this->once())->method('getLastModified')->will($this->returnValue($date));
        $model->expects($this->once())->method('getNumImages')->will($this->returnValue(123));
        $model->expects($this->once())->method('getUserId')->will($this->returnValue('christer'));
        $this->dateFormatter->expects($this->once())->method('formatDate')->with($date)->will($this->returnValue($formattedDate));
        $json = $this->formatter->format($model);
        $data = json_decode($json, true);
        $this->assertSame($formattedDate, $data['lastModified']);
        $this->assertSame('christer', $data['user']);
        $this->assertSame(123, $data['numImages']);
    }