/** * Tests get_icons_from_path() function. */ public function test_get_icons_from_path() { // Get icons from the fixtures folder. $icons = utils::get_icons_from_path(__DIR__ . '/fixtures'); // The icons are returned alphabetically and with keys === values. // For the icon with numbers after the name, only the base name is // returned and only one of it. $this->assertEquals(array('frog' => 'frog', 'zombie' => 'zombie'), $icons); }
public function validation($data, $files) { $errors = parent::validation($data, $files); // Check the extension isn't already in use. $oldextension = $data['oldextension']; $extension = trim($data['extension']); if (\tool_filetypes\utils::is_extension_invalid($extension, $oldextension)) { $errors['extension'] = get_string('error_extension', 'tool_filetypes', $extension); } // Check the 'default icon' setting doesn't conflict with an existing one. if (!empty($data['defaulticon']) && !\tool_filetypes\utils::is_defaulticon_allowed($data['mimetype'], $oldextension)) { $errors['defaulticon'] = get_string('error_defaulticon', 'tool_filetypes', $extension); } // If you choose 'lang' or 'custom' descriptiontype, you must fill something in the field. switch ($data['descriptiontype']) { case 'lang': if (!trim($data['corestring'])) { $errors['corestring'] = get_string('required'); } break; case 'custom': if (!trim($data['description'])) { $errors['description'] = get_string('required'); } break; } return $errors; }
public function validation($data, $files) { $errors = parent::validation($data, $files); // Check the extension isn't already in use. $oldextension = $data['oldextension']; $extension = trim($data['extension']); if (\tool_filetypes\utils::is_extension_invalid($extension, $oldextension)) { $errors['extension'] = get_string('error_extension', 'tool_filetypes', $extension); } // Check the 'default icon' setting doesn't conflict with an existing one. if (!empty($data['defaulticon']) && !\tool_filetypes\utils::is_defaulticon_allowed($data['mimetype'], $oldextension)) { $errors['defaulticon'] = get_string('error_defaulticon', 'tool_filetypes', $extension); } return $errors; }