private $admin;
private $editor;
+ /**
+ * The base URL to use while testing the application.
+ * @var string
+ */
+ protected $baseUrl = 'http://localhost';
+
public function tearDown()
{
\DB::disconnect();
class ImageTest extends TestCase
{
-
/**
* Get the path to our basic test image.
* @return string
*/
protected function deleteImage($relPath)
{
- unlink(public_path($relPath));
+ $path = public_path($relPath);
+ if (file_exists($path)) {
+ unlink($path);
+ }
}
public function test_image_upload()
{
$page = Page::first();
- $this->asAdmin();
$admin = $this->getAdmin();
+ $this->actingAs($admin);
+
$imageName = 'first-image.png';
+ $relPath = $this->getTestImagePath('gallery', $imageName);
+ $this->deleteImage($relPath);
$upload = $this->uploadImage($imageName, $page->id);
$upload->assertStatus(200);
- $relPath = $this->getTestImagePath('gallery', $imageName);
$this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image not found at path: '. public_path($relPath));