From 020451cc4e4ff73e66d8db3a7ce4c71ebcc4611a Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Tue, 21 May 2024 16:53:56 +0200 Subject: [PATCH] Refactor unit tests to use the new version method --- tests/Cms/Files/FileActionsTest.php | 36 ++++++++++++++--------------- tests/Cms/Pages/PageActionsTest.php | 20 ++++++++-------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/Cms/Files/FileActionsTest.php b/tests/Cms/Files/FileActionsTest.php index 322b60fb1d..143183d48b 100644 --- a/tests/Cms/Files/FileActionsTest.php +++ b/tests/Cms/Files/FileActionsTest.php @@ -106,19 +106,19 @@ public function testChangeName(File $file) // create an empty dummy file F::write($file->root(), ''); // ...and an empty content file for it - F::write($file->storage()->contentFile(VersionId::published(), 'default'), ''); + F::write($file->version(VersionId::published())->contentFile('default'), ''); $this->assertFileExists($file->root()); - $this->assertFileExists($file->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileExists($file->version(VersionId::published())->contentFile('default')); $result = $file->changeName('test'); $this->assertNotSame($file->root(), $result->root()); $this->assertSame('test.csv', $result->filename()); $this->assertFileExists($result->root()); - $this->assertFileExists($result->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileExists($result->version(VersionId::published())->contentFile('default')); $this->assertFileDoesNotExist($file->root()); - $this->assertFileDoesNotExist($file->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileDoesNotExist($file->version(VersionId::published())->contentFile('default')); } public static function fileProviderMultiLang(): array @@ -142,20 +142,20 @@ public function testChangeNameMultiLang(File $file) // create an empty dummy file F::write($file->root(), ''); // ...and empty content files for it - F::write($file->storage()->contentFile(VersionId::published(), 'en'), ''); - F::write($file->storage()->contentFile(VersionId::published(), 'de'), ''); + F::write($file->version(VersionId::published())->contentFile('en'), ''); + F::write($file->version(VersionId::published())->contentFile('de'), ''); $this->assertFileExists($file->root()); - $this->assertFileExists($file->storage()->contentFile(VersionId::published(), 'en')); - $this->assertFileExists($file->storage()->contentFile(VersionId::published(), 'de')); + $this->assertFileExists($file->version(VersionId::published())->contentFile('en')); + $this->assertFileExists($file->version(VersionId::published())->contentFile('de')); $result = $file->changeName('test'); $this->assertNotEquals($file->root(), $result->root()); $this->assertSame('test.csv', $result->filename()); $this->assertFileExists($result->root()); - $this->assertFileExists($result->storage()->contentFile(VersionId::published(), 'en')); - $this->assertFileExists($result->storage()->contentFile(VersionId::published(), 'de')); + $this->assertFileExists($result->version(VersionId::published())->contentFile('en')); + $this->assertFileExists($result->version(VersionId::published())->contentFile('de')); } public function testChangeTemplate() @@ -377,9 +377,9 @@ public function testChangeTemplateMultilang() $this->assertNull($modified->caption()->value()); $this->assertSame('Das ist der Text', $modified->text()->value()); - $this->assertFileExists($modified->storage()->contentFile(VersionId::published(), 'en')); - $this->assertFileExists($modified->storage()->contentFile(VersionId::published(), 'de')); - $this->assertFileDoesNotExist($modified->storage()->contentFile(VersionId::published(), 'fr')); + $this->assertFileExists($modified->version(VersionId::published())->contentFile('en')); + $this->assertFileExists($modified->version(VersionId::published())->contentFile('de')); + $this->assertFileDoesNotExist($modified->version(VersionId::published())->contentFile('fr')); } public function testChangeTemplateDefault() @@ -755,17 +755,17 @@ public function testDelete(File $file) // create an empty dummy file F::write($file->root(), ''); // ...and an empty content file for it - F::write($file->storage()->contentFile(VersionId::published(), 'default'), ''); + F::write($file->version(VersionId::published())->contentFile('default'), ''); $this->assertFileExists($file->root()); - $this->assertFileExists($file->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileExists($file->version(VersionId::published())->contentFile('default')); $result = $file->delete(); $this->assertTrue($result); $this->assertFileDoesNotExist($file->root()); - $this->assertFileDoesNotExist($file->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileDoesNotExist($file->version(VersionId::published())->contentFile('default')); } /** @@ -875,11 +875,11 @@ public function testSave($file) F::write($file->root(), ''); $this->assertFileExists($file->root()); - $this->assertFileDoesNotExist($file->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileDoesNotExist($file->version(VersionId::published())->contentFile('default')); $file = $file->clone(['content' => ['caption' => 'save']])->save(); - $this->assertFileExists($file->storage()->contentFile(VersionId::published(), 'default')); + $this->assertFileExists($file->version(VersionId::published())->contentFile('default')); } /** diff --git a/tests/Cms/Pages/PageActionsTest.php b/tests/Cms/Pages/PageActionsTest.php index 15d7f2d93a..bb083ccbb2 100644 --- a/tests/Cms/Pages/PageActionsTest.php +++ b/tests/Cms/Pages/PageActionsTest.php @@ -424,9 +424,9 @@ public function testChangeTemplateMultilang() $this->assertSame('article', $modified->intendedTemplate()->name()); $this->assertSame(2, $calls); - $this->assertFileExists($modified->storage()->contentFile(VersionId::published(), 'en')); - $this->assertFileExists($modified->storage()->contentFile(VersionId::published(), 'de')); - $this->assertFileDoesNotExist($modified->storage()->contentFile(VersionId::published(), 'fr')); + $this->assertFileExists($modified->version(VersionId::published())->contentFile('en')); + $this->assertFileExists($modified->version(VersionId::published())->contentFile('de')); + $this->assertFileDoesNotExist($modified->version(VersionId::published())->contentFile('fr')); $this->assertNull($modified->caption()->value()); $this->assertSame('Text', $modified->text()->value()); $this->assertNull($modified->content('de')->get('caption')->value()); @@ -891,15 +891,15 @@ public function testDuplicateMultiLang() 'parent' => $page, 'code' => 'en', ]); - $this->assertFileExists($page->storage()->contentFile(VersionId::changes(), 'en')); + $this->assertFileExists($page->version(VersionId::changes())->contentFile('en')); $drafts = $app->site()->drafts(); $childrenAndDrafts = $app->site()->childrenAndDrafts(); $copy = $page->duplicate('test-copy'); - $this->assertFileExists($copy->storage()->contentFile(VersionId::changes(), 'en')); - $this->assertFileDoesNotExist($copy->storage()->contentFile(VersionId::changes(), 'de')); + $this->assertFileExists($copy->version(VersionId::changes())->contentFile('en')); + $this->assertFileDoesNotExist($copy->version(VersionId::changes())->contentFile('de')); $this->assertIsPage($page, $drafts->find('test')); $this->assertIsPage($page, $childrenAndDrafts->find('test')); @@ -931,8 +931,8 @@ public function testDuplicateMultiLangSlug() 'slug' => 'test-de' ], 'de'); - $this->assertFileExists($page->storage()->contentFile(VersionId::changes(), 'en')); - $this->assertFileExists($page->storage()->contentFile(VersionId::changes(), 'de')); + $this->assertFileExists($page->version(VersionId::changes())->contentFile('en')); + $this->assertFileExists($page->version(VersionId::changes())->contentFile('de')); $this->assertSame('test', $page->slug()); $this->assertSame('test-de', $page->slug('de')); @@ -1046,8 +1046,8 @@ public function testDuplicateChildrenMultiLang() $copy = $page->duplicate('test-copy', ['children' => true]); - $this->assertFileExists($copy->storage()->contentFile(VersionId::changes(), 'en')); - $this->assertFileDoesNotExist($copy->storage()->contentFile(VersionId::changes(), 'de')); + $this->assertFileExists($copy->version(VersionId::changes())->contentFile('en')); + $this->assertFileDoesNotExist($copy->version(VersionId::changes())->contentFile('de')); $this->assertNotSame($page->uuid()->id(), $copy->uuid()->id());