Imbo\EventListener\ImageVariations\Database\MongoDB::storeImageVariationMetadata PHP Method

storeImageVariationMetadata() public method

public storeImageVariationMetadata ( $user, $imageIdentifier, $width, $height )
    public function storeImageVariationMetadata($user, $imageIdentifier, $width, $height)
    {
        try {
            $this->getCollection()->insert(['added' => time(), 'user' => $user, 'imageIdentifier' => $imageIdentifier, 'width' => $width, 'height' => $height]);
        } catch (MongoException $e) {
            throw new DatabaseException('Unable to save image variation data', 500, $e);
        }
        return true;
    }

Usage Example

Beispiel #1
0
 /**
  * @covers Imbo\EventListener\ImageVariations\Database\MongoDB::__construct
  * @covers Imbo\EventListener\ImageVariations\Database\MongoDB::getCollection
  * @expectedException Imbo\Exception\DatabaseException
  * @expectedExceptionMessage Could not select collection
  * @expectedExceptionCode 500
  */
 public function testThrowsExceptionWhenNotAbleToGetCollection()
 {
     $client = $this->getMockBuilder('MongoClient')->disableOriginalConstructor()->getMock();
     $client->expects($this->once())->method('selectCollection')->will($this->throwException(new MongoException()));
     $adapter = new MongoDB(['databaseName' => $this->databaseName], $client);
     $adapter->storeImageVariationMetadata('key', 'id', 700, 700);
 }