1 <?php namespace Tests\Uploads;
7 * Get the path to our basic test image.
10 protected function getTestImageFilePath()
12 return base_path('tests/test-data/test-image.png');
16 * Get a test image that can be uploaded
18 * @return \Illuminate\Http\UploadedFile
20 protected function getTestImage($fileName)
22 return new \Illuminate\Http\UploadedFile($this->getTestImageFilePath(), $fileName, 'image/png', 5238);
26 * Get the raw file data for the test image.
27 * @return false|string
29 protected function getTestImageContent()
31 return file_get_contents($this->getTestImageFilePath());
35 * Get the path for a test image.
40 protected function getTestImagePath($type, $fileName)
42 return '/uploads/images/' . $type . '/' . Date('Y-m-M') . '/' . $fileName;
46 * Uploads an image with the given name.
48 * @param int $uploadedTo
49 * @return \Illuminate\Foundation\Testing\TestResponse
51 protected function uploadImage($name, $uploadedTo = 0)
53 $file = $this->getTestImage($name);
54 return $this->call('POST', '/images/gallery/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
58 * Delete an uploaded image.
61 protected function deleteImage($relPath)
63 $path = public_path($relPath);
64 if (file_exists($path)) {