From 43447ac47b2f73b2604a04d3155a8bac0f5f3cba Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 26 Oct 2024 12:52:43 +0100 Subject: [PATCH] Fix tests after we corrected the media URLs The media URLs have a path that starts `/storage/`. --- tests/Feature/MicropubMediaTest.php | 31 +++++++++++++++-------------- tests/Unit/NotesTest.php | 6 +++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/tests/Feature/MicropubMediaTest.php b/tests/Feature/MicropubMediaTest.php index 7abafd9b..abdb2619 100644 --- a/tests/Feature/MicropubMediaTest.php +++ b/tests/Feature/MicropubMediaTest.php @@ -93,7 +93,7 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + $filename = Str::chopStart($path, '/storage/media/'); $lastUploadResponse = $this->get( '/api/media?q=last', @@ -122,7 +122,7 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + $filename = Str::chopStart($path, '/storage/media/'); $sourceUploadResponse = $this->get( '/api/media?q=source', @@ -154,7 +154,7 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + $filename = Str::chopStart($path, '/storage/media/'); $sourceUploadResponse = $this->get( '/api/media?q=source&limit=1', @@ -261,11 +261,12 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + dump($path); + $filename = Str::chopStart($path, '/storage/'); Queue::assertPushed(ProcessMedia::class); - Storage::disk('local')->assertExists($path); + Storage::disk('local')->assertExists($filename); // now remove file - unlink(storage_path('app/media/') . $filename); + unlink(storage_path('app/') . $filename); $this->removeDirIfEmpty(storage_path('app/media')); } @@ -284,11 +285,11 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + $filename = Str::chopStart($path, '/storage/'); Queue::assertPushed(ProcessMedia::class); - Storage::disk('local')->assertExists($path); + Storage::disk('local')->assertExists($filename); // now remove file - unlink(storage_path('app/media/') . $filename); + unlink(storage_path('app/') . $filename); $this->removeDirIfEmpty(storage_path('app/media')); } @@ -307,11 +308,11 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + $filename = Str::chopStart($path, '/storage/'); Queue::assertPushed(ProcessMedia::class); - Storage::disk('local')->assertExists($path); + Storage::disk('local')->assertExists($filename); // now remove file - unlink(storage_path('app/media/') . $filename); + unlink(storage_path('app/') . $filename); $this->removeDirIfEmpty(storage_path('app/media')); } @@ -329,11 +330,11 @@ class MicropubMediaTest extends TestCase ); $path = parse_url($response->headers->get('Location'), PHP_URL_PATH); - $filename = Str::chopStart($path, '/media/'); + $filename = Str::chopStart($path, '/storage/'); Queue::assertPushed(ProcessMedia::class); - Storage::disk('local')->assertExists($path); + Storage::disk('local')->assertExists($filename); // now remove file - unlink(storage_path('app/media/') . $filename); + unlink(storage_path('app/') . $filename); $this->removeDirIfEmpty(storage_path('app/media')); } diff --git a/tests/Unit/NotesTest.php b/tests/Unit/NotesTest.php index 3679349d..dfd532e6 100644 --- a/tests/Unit/NotesTest.php +++ b/tests/Unit/NotesTest.php @@ -323,7 +323,7 @@ class NotesTest extends TestCase $note->media()->save($media); $expected = 'A nice image -'; +'; $this->assertEquals($expected, $note->content); } @@ -340,7 +340,7 @@ class NotesTest extends TestCase $note->media()->save($media); $expected = 'A nice video -