mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-07-17 00:32:36 +00:00
Fixed test failing from missing baseURL
Also updated image upload test to delete before upload to prevent failed tests breaking subsequent tests.
This commit is contained in:
parent
88d09a2a3b
commit
ba6eb6727a
|
@ -17,6 +17,12 @@ abstract class BrowserKitTest extends TestCase
|
||||||
private $admin;
|
private $admin;
|
||||||
private $editor;
|
private $editor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base URL to use while testing the application.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $baseUrl = 'http://localhost';
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
\DB::disconnect();
|
\DB::disconnect();
|
||||||
|
|
|
@ -5,7 +5,6 @@ use BookStack\Page;
|
||||||
|
|
||||||
class ImageTest extends TestCase
|
class ImageTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path to our basic test image.
|
* Get the path to our basic test image.
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -54,20 +53,25 @@ class ImageTest extends TestCase
|
||||||
*/
|
*/
|
||||||
protected function deleteImage($relPath)
|
protected function deleteImage($relPath)
|
||||||
{
|
{
|
||||||
unlink(public_path($relPath));
|
$path = public_path($relPath);
|
||||||
|
if (file_exists($path)) {
|
||||||
|
unlink($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function test_image_upload()
|
public function test_image_upload()
|
||||||
{
|
{
|
||||||
$page = Page::first();
|
$page = Page::first();
|
||||||
$this->asAdmin();
|
|
||||||
$admin = $this->getAdmin();
|
$admin = $this->getAdmin();
|
||||||
|
$this->actingAs($admin);
|
||||||
|
|
||||||
$imageName = 'first-image.png';
|
$imageName = 'first-image.png';
|
||||||
|
$relPath = $this->getTestImagePath('gallery', $imageName);
|
||||||
|
$this->deleteImage($relPath);
|
||||||
|
|
||||||
$upload = $this->uploadImage($imageName, $page->id);
|
$upload = $this->uploadImage($imageName, $page->id);
|
||||||
$upload->assertStatus(200);
|
$upload->assertStatus(200);
|
||||||
$relPath = $this->getTestImagePath('gallery', $imageName);
|
|
||||||
|
|
||||||
$this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image not found at path: '. public_path($relPath));
|
$this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image not found at path: '. public_path($relPath));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user