/** * @covers Imbo\Database\MongoDB::insertImage * @expectedException Imbo\Exception\DatabaseException * @expectedExceptionMessage Unable to save image data * @expectedExceptionCode 500 */ public function testThrowsExceptionWhenMongoFailsDuringInsertImageAndImageAlreadyExists() { $this->imageCollection->expects($this->once())->method('findOne')->will($this->returnValue(['some' => 'data'])); $this->imageCollection->expects($this->once())->method('update')->will($this->throwException(new MongoException())); $this->driver->insertImage('key', 'identifier', $this->getMock('Imbo\\Model\\Image')); }