1 <?php namespace Tests\Uploads;
4 use Illuminate\Http\UploadedFile;
9 * Get the path to our basic test image.
12 protected function getTestImageFilePath()
14 return base_path('tests/test-data/test-image.png');
18 * Get a test image that can be uploaded
20 * @return UploadedFile
22 protected function getTestImage($fileName)
24 return new UploadedFile($this->getTestImageFilePath(), $fileName, 'image/png', 5238, null, true);
28 * Get the raw file data for the test image.
29 * @return false|string
31 protected function getTestImageContent()
33 return file_get_contents($this->getTestImageFilePath());
37 * Get the path for a test image.
42 protected function getTestImagePath($type, $fileName)
44 return '/uploads/images/' . $type . '/' . Date('Y-m-M') . '/' . $fileName;
48 * Uploads an image with the given name.
50 * @param int $uploadedTo
51 * @param string $contentType
52 * @return \Illuminate\Foundation\Testing\TestResponse
54 protected function uploadImage($name, $uploadedTo = 0, $contentType = 'image/png')
56 $file = $this->getTestImage($name);
57 return $this->withHeader('Content-Type', $contentType)
58 ->call('POST', '/images/gallery/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
62 * Delete an uploaded image.
65 protected function deleteImage($relPath)
67 $path = public_path($relPath);
68 if (file_exists($path)) {