From 7b47bd13b73ae9c3bc8f10b627c70b911d1dfbad Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Mon, 22 Jan 2024 16:14:18 +0100 Subject: [PATCH] Unit test for file action --- tests/Cms/Files/FileActionsTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/Cms/Files/FileActionsTest.php b/tests/Cms/Files/FileActionsTest.php index 83220c2b72..ae189fc8e5 100644 --- a/tests/Cms/Files/FileActionsTest.php +++ b/tests/Cms/Files/FileActionsTest.php @@ -542,6 +542,33 @@ public function testCreate($parent) $this->assertIsString($result->content()->get('uuid')->value()); } + /** + * @dataProvider parentProvider + */ + public function testCreateDuplicate($parent) + { + $source = static::TMP . '/source.md'; + + // create the dummy source + F::write($source, '# Test'); + + $result = File::create([ + 'filename' => 'test.md', + 'source' => $source, + 'parent' => $parent + ]); + + $uuid = $result->content()->get('uuid')->value(); + + $duplicate = File::create([ + 'filename' => 'test.md', + 'source' => $source, + 'parent' => $parent + ]); + + $this->assertSame($uuid, $duplicate->content()->get('uuid')->value()); + } + /** * @dataProvider parentProvider */