Файловый менеджер - Редактировать - /home/harasnat/www/mf/tests.zip
Назад
PK ( 0[\��� � processor_test.phpnu &1i� <?php // This file is part of Moodle - https://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. namespace mlbackend_python; /** * Unit tests for the {@link \mlbackend_python\processor} class. * * @package mlbackend_python * @category test * @copyright 2019 David Mudrák <david@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class processor_test extends \advanced_testcase { /** * Test implementation of the {@link \mlbackend_python\processor::check_pip_package_version()} method. * * @dataProvider check_pip_package_versions * @param string $actual A sample of the actual package version * @param string $required A sample of the required package version * @param int $result Expected value returned by the tested method */ public function test_check_pip_package_version($actual, $required, $result) { $this->assertSame($result, \mlbackend_python\processor::check_pip_package_version($actual, $required)); } /** * Check that the {@link \mlbackend_python\processor::check_pip_package_version()} can be called with single argument. */ public function test_check_pip_package_version_default() { $this->assertSame(-1, \mlbackend_python\processor::check_pip_package_version('0.0.1')); $this->assertSame(0, \mlbackend_python\processor::check_pip_package_version( \mlbackend_python\processor::REQUIRED_PIP_PACKAGE_VERSION)); } /** * Provides data samples for the {@link self::test_check_pip_package_version()}. * * @return array */ public function check_pip_package_versions() { return [ // Exact match. [ '0.0.5', '0.0.5', 0, ], [ '1.0.0', '1.0.0', 0, ], // Actual version higher than required, yet still API compatible. [ '1.0.3', '1.0.1', 0, ], [ '2.1.3', '2.0.0', 0, ], [ '1.1.5', '1.1', 0, ], [ '2.0.3', '2', 0, ], // Actual version not high enough to meet the requirements. [ '0.0.5', '1.0.0', -1, ], [ '0.37.0', '1.0.0', -1, ], [ '0.0.5', '0.37.0', -1, ], [ '2.0.0', '2.0.2', -1, ], [ '2.7.0', '3.0', -1, ], [ '2.8.9-beta1', '3.0', -1, ], [ '1.1.0-rc1', '1.1.0', -1, ], // Actual version too high and no longer API compatible. [ '2.0.0', '1.0.0', 1, ], [ '3.1.5', '2.0', 1, ], [ '3.0.0', '1.0', 1, ], [ '2.0.0', '0.0.5', 1, ], [ '3.0.2', '0.37.0', 1, ], // Zero major version requirement is fulfilled with 1.x API (0.x are not considered stable APIs). [ '1.0.0', '0.0.5', 0, ], [ '1.8.6', '0.37.0', 0, ], // Empty version is never good enough. [ '', '1.0.0', -1, ], [ '0.0.0', '0.37.0', -1, ], ]; } } PK �0[ߗ�w? ? behat/rememberusername.featurenu &1i� @core @core_auth Feature: Test the 'remember username' feature works. In order for users to easily log in to the site As a user I need the site to remember my username when the feature is enabled Background: Given the following "users" exist: | username | | teacher1 | # Given the user has logged in and selected 'Remember username', when they log in again, then their username should be remembered. Scenario: Check that 'remember username' works without javascript for teachers. # Log in the first time with $CFG->rememberusername set to Yes. Given the following config values are set as admin: | rememberusername | 1 | And I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" And I set the field "Username" to "teacher1" And I set the field "Password" to "teacher1" And I press "Log in" And I log out # Log out and check that the username was remembered. When I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" Then the field "username" matches value "teacher1" # Given the user has logged in before and selected 'Remember username', when they log in again and unset 'Remember username', then # their username should be forgotten for future log in attempts. Scenario: Check that 'remember username' unsetting works without javascript for teachers. # Log in the first time with $CFG->rememberusername set to Optional. Given the following config values are set as admin: | rememberusername | 2 | And I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" And I set the field "Username" to "teacher1" And I set the field "Password" to "teacher1" And I press "Log in" And I log out # Log in again, the username should have been remembered. When I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" Then the field "username" matches value "teacher1" And I set the field "Password" to "teacher1" And I press "Log in" And I log out And the following config values are set as admin: | rememberusername | 0 | # Check username has been forgotten. And I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" Then the field "username" matches value "" PK �0[MN�yS S behat/logout.phpnu &1i� <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. // phpcs:disable moodle.Files.RequireLogin.Missing // phpcs:disable moodle.PHP.ForbiddenFunctions.Found /** * Login end point for Behat tests only. * * @package core_auth * @category test * @copyright Andrew Lyons <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__.'/../../../config.php'); $behatrunning = defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING; if (!$behatrunning) { redirect(new moodle_url('/login/logout.php')); } require_logout(); $login = optional_param('loginpage', 0, PARAM_BOOL); if ($login) { redirect(get_login_url()); } else { redirect(new moodle_url('/')); } PK �0[/a�� * behat/validateagedigitalconsentmap.featurenu &1i� @core @verify_age_location Feature: Test validation of 'Age of digital consent' setting. In order to set the 'Age of digital consent' setting As an admin I need to provide valid data and valid format Background: Given I log in as "admin" And I navigate to "Users > Privacy and policies > Privacy settings" in site administration Scenario: Admin provides valid value for 'Age of digital consent'. Given I set the field "s__agedigitalconsentmap" to multiline: """ *, 16 AT, 14 BE, 14 """ When I press "Save changes" Then I should see "Changes saved" And I should not see "Some settings were not changed due to an error." And I should not see "The digital age of consent is not valid:" Scenario: Admin provides invalid format for 'Age of digital consent'. # Try to set a value with missing space separator Given I set the field "s__agedigitalconsentmap" to multiline: """ *16 AT, 14 BE, 14 """ When I press "Save changes" Then I should not see "Changes saved" And I should see "Some settings were not changed due to an error." And I should see "The digital age of consent is not valid: \"*16\" has more or less than one comma separator." # Try to set a value with missing default age of consent When I set the field "s__agedigitalconsentmap" to multiline: """ AT, 14 BE, 14 """ And I press "Save changes" Then I should not see "Changes saved" And I should see "Some settings were not changed due to an error." And I should see "The digital age of consent is not valid: Default (*) value is missing." Scenario: Admin provides invalid age of consent or country for 'Age of digital consent'. # Try to set a value containing invalid age of consent Given I set the field "s__agedigitalconsentmap" to multiline: """ *, 16 AT, age BE, 14 """ When I press "Save changes" Then I should not see "Changes saved" And I should see "Some settings were not changed due to an error." And I should see "The digital age of consent is not valid: \"age\" is not a valid value for age." # Try to set a value containing invalid country When I set the field "s__agedigitalconsentmap" to multiline: """ *, 16 COUNTRY, 14 BE, 14 """ And I press "Save changes" Then I should not see "Changes saved" And I should see "Some settings were not changed due to an error." And I should see "The digital age of consent is not valid: \"COUNTRY\" is not a valid value for country." PK �0[��� � behat/behat_auth.phpnu &1i� <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Basic authentication steps definitions. * * @package core_auth * @category test * @copyright 2012 David Monllaó * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. require_once(__DIR__ . '/../../../lib/behat/behat_base.php'); /** * Log in log out steps definitions. * * @package core_auth * @category test * @copyright 2012 David Monllaó * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class behat_auth extends behat_base { /** * Logs in the user. There should exist a user with the same value as username and password. * * @Given /^I log in as "(?P<username_string>(?:[^"]|\\")*)"$/ * @Given I am logged in as :username * @param string $username the user to log in as. * @param moodle_url|null $wantsurl optional, URL to go to after logging in. */ public function i_log_in_as(string $username, moodle_url $wantsurl = null) { // In the mobile app the required tasks are different (does not support $wantsurl). if ($this->is_in_app()) { $this->execute('behat_app::login', [$username]); return; } $loginurl = new moodle_url('/auth/tests/behat/login.php', [ 'username' => $username, ]); if ($wantsurl !== null) { $loginurl->param('wantsurl', $wantsurl->out_as_local_url()); } // Visit login page. $this->execute('behat_general::i_visit', [$loginurl]); } /** * Logs out of the system. * * @Given /^I log out$/ * @Given I am not logged in */ public function i_log_out() { $this->execute('behat_general::i_visit', [new moodle_url('/auth/tests/behat/logout.php')]); } } PK �0[!�9G� � behat/login.phpnu &1i� <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. // phpcs:disable moodle.Files.RequireLogin.Missing // phpcs:disable moodle.PHP.ForbiddenFunctions.Found /** * Login end point for Behat tests only. * * @package core_auth * @category test * @author Guy Thomas * @copyright 2021 Class Technologies Inc. {@link https://www.class.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__.'/../../../config.php'); require_once("{$CFG->dirroot}/login/lib.php"); $behatrunning = defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING; if (!$behatrunning) { redirect(new moodle_url('/')); } $username = required_param('username', PARAM_ALPHANUMEXT); $wantsurl = optional_param('wantsurl', null, PARAM_URL); if (isloggedin()) { // If the user is already logged in, log them out and redirect them back to login again. require_logout(); redirect(new moodle_url('/auth/tests/behat/login.php', [ 'username' => $username, 'wantsurl' => (new moodle_url($wantsurl))->out(false), ])); } // Note - with behat, the password is always the same as the username. $password = $username; $failurereason = null; $user = authenticate_user_login($username, $password, true, $failurereason, false); if ($failurereason) { switch($failurereason) { case AUTH_LOGIN_NOUSER: $reason = get_string('invalidlogin'); break; case AUTH_LOGIN_SUSPENDED: $reason = 'User suspended'; break; case AUTH_LOGIN_FAILED: $reason = 'Login failed'; break; case AUTH_LOGIN_LOCKOUT: $reason = 'Account locked'; break; case AUTH_LOGIN_UNAUTHORISED: $reason = get_string('unauthorisedlogin', 'core', $username); break; default: $reason = "Unknown login failure: '{$failurereason}'"; break; } // Note: Do not throw an exception here as we sometimes test that login does not work. // Exceptions are automatic failures in Behat. \core\notification::add($reason, \core\notification::ERROR); redirect(new moodle_url('/')); } if (!complete_user_login($user)) { throw new Exception("Failed to login as behat step for $username"); } if (empty($wantsurl)) { $wantsurl = core_login_get_return_url(); } redirect(new moodle_url($wantsurl)); PK �0[�Z�� � "