/** * Insert some images to test the query functionality * * All images added is owned by "user", unless $alternateUser is set to true * * @param boolean $alternateUser Whether to alternate between 'user' and 'user2' when * inserting images * @return array Returns an array with two elements where the first is the timestamp of when * the first image was added, and the second is the timestamp of when the last * image was added */ private function insertImages($alternateUser = false) { $now = time(); $start = $now; $images = []; foreach (['image.jpg', 'image.png', 'image1.png', 'image2.png', 'image3.png', 'image4.png'] as $i => $fileName) { $path = FIXTURES_DIR . '/' . $fileName; $info = getimagesize($path); $user = '******'; if ($alternateUser && $i % 2 === 0) { $user = '******'; } $image = new Image(); $image->setMimeType($info['mime'])->setExtension(substr($fileName, strrpos($fileName, '.') + 1))->setWidth($info[0])->setHeight($info[1])->setBlob(file_get_contents($path))->setAddedDate(new DateTime('@' . $now, new DateTimeZone('UTC')))->setUpdatedDate(new DateTime('@' . $now, new DateTimeZone('UTC')))->setOriginalChecksum(md5_file($path)); $now++; $imageIdentifier = md5($image->getBlob()); // Add the image $this->adapter->insertImage($user, $imageIdentifier, $image); // Insert some metadata $this->adapter->updateMetadata($user, $imageIdentifier, ['key' . $i => 'value' . $i]); } // Remove the last increment to get the timestamp for when the last image was added $end = $now - 1; return [$start, $end]; }