-<?php
+<?php namespace Tests;
-class ImageTest extends TestCase
+class ImageTest extends BrowserKitTest
{
/**
*/
protected function getTestImage($fileName)
{
- return new \Illuminate\Http\UploadedFile(base_path('tests/test-image.jpg'), $fileName, 'image/jpeg', 5238);
+ return new \Illuminate\Http\UploadedFile(base_path('tests/test-data/test-image.jpg'), $fileName, 'image/jpeg', 5238);
}
/**
$relPath = $this->uploadImage($imageName, $page->id);
$this->assertResponseOk();
- $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image exists');
+ $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image not found at path: '. public_path($relPath));
+
+ $this->deleteImage($relPath);
$this->seeInDatabase('images', [
- 'url' => $relPath,
+ 'url' => $this->baseUrl . $relPath,
'type' => 'gallery',
'uploaded_to' => $page->id,
'path' => $relPath,
'updated_by' => $admin->id,
'name' => $imageName
]);
-
- $this->deleteImage($relPath);
+
}
public function test_image_delete()
$this->assertResponseOk();
$this->dontSeeInDatabase('images', [
- 'url' => $relPath,
+ 'url' => $this->baseUrl . $relPath,
'type' => 'gallery'
]);
- $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has been deleted');
+ $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has not been deleted as expected');
}
}
\ No newline at end of file