From e9e808175c7c53dbaa944c854aa6537390b97b01 Mon Sep 17 00:00:00 2001 From: Benedict Massolle Date: Tue, 19 Mar 2024 14:51:22 +0100 Subject: [PATCH] Add test for case when file type could not be determined --- tests/AutoFileTemplatesTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/AutoFileTemplatesTest.php b/tests/AutoFileTemplatesTest.php index c22986b..32b73a7 100644 --- a/tests/AutoFileTemplatesTest.php +++ b/tests/AutoFileTemplatesTest.php @@ -209,6 +209,27 @@ public function testOverwriteTemplateIfOptionIsSet(): void $this->assertEquals('image', $service->autoAssign($image)); } + public function testFileTypeCannotBeDetermined(): void + { + $options = [ + 'autoAssign' => true, + ]; + + $kirby = new App([ + 'roots' => [ + 'index' => self::$tmpDir, + ], + 'options' => [ + 'presprog.auto-file-templates' => $options, + ], + ]); + + $service = new AutoFileTemplates($kirby, PluginOptions::createFromOptions($kirby->options())); + $image = new File(['type' => 'sometype', 'filename' => 'file', 'parent' => self::page()]); + + $this->assertEquals(null, $service->autoAssign($image)); + } + public static function files(): \Generator { $page = self::page();