From 8cd51d02a7ed49533478d38cf9264c462d912101 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Sun, 18 Feb 2024 14:44:03 +0000 Subject: [PATCH] Validation of dataformat - custom plugin name lang string --- .../Requirements/DataformatRequirements.php | 26 ++++++++++ .../Requirements/RequirementsResolver.php | 1 + .../DataformatRequirementsTest.php | 52 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/PluginValidate/Requirements/DataformatRequirements.php create mode 100644 tests/PluginValidate/Requirements/DataformatRequirementsTest.php diff --git a/src/PluginValidate/Requirements/DataformatRequirements.php b/src/PluginValidate/Requirements/DataformatRequirements.php new file mode 100644 index 00000000..491c02ef --- /dev/null +++ b/src/PluginValidate/Requirements/DataformatRequirements.php @@ -0,0 +1,26 @@ +getLangFile())->mustHave('dataformat'); + } +} diff --git a/src/PluginValidate/Requirements/RequirementsResolver.php b/src/PluginValidate/Requirements/RequirementsResolver.php index f3d72eb5..a57a383b 100644 --- a/src/PluginValidate/Requirements/RequirementsResolver.php +++ b/src/PluginValidate/Requirements/RequirementsResolver.php @@ -32,6 +32,7 @@ public function resolveRequirements(Plugin $plugin, $moodleVersion) $map = [ 'auth' => new AuthRequirements($plugin, $moodleVersion), 'block' => new BlockRequirements($plugin, $moodleVersion), + 'dataformat' => new DataformatRequirements($plugin, $moodleVersion), 'filter' => new FilterRequirements($plugin, $moodleVersion), 'format' => new FormatRequirements($plugin, $moodleVersion), 'mod' => new ModuleRequirements($plugin, $moodleVersion), diff --git a/tests/PluginValidate/Requirements/DataformatRequirementsTest.php b/tests/PluginValidate/Requirements/DataformatRequirementsTest.php new file mode 100644 index 00000000..aeadbdc2 --- /dev/null +++ b/tests/PluginValidate/Requirements/DataformatRequirementsTest.php @@ -0,0 +1,52 @@ +requirements = new DataformatRequirements(new Plugin('dataformat_csv', 'dataformat', 'csv', ''), 29); + } + + protected function tearDown(): void + { + $this->requirements = null; + } + + public function testResolveRequirements() + { + $resolver = new RequirementsResolver(); + + $this->assertInstanceOf( + 'MoodlePluginCI\PluginValidate\Requirements\DataformatRequirements', + $resolver->resolveRequirements(new Plugin('', 'dataformat', '', ''), 29) + ); + } + + public function testGetRequiredStrings() + { + $fileToken = $this->requirements->getRequiredStrings(); + $this->assertInstanceOf('MoodlePluginCI\PluginValidate\Finder\FileTokens', $fileToken); + $this->assertSame('lang/en/dataformat_csv.php', $fileToken->file); + } +}