Skip to content

Commit

Permalink
issue #855: fix namespace for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Dec 16, 2024
1 parent 4e94bed commit 0b87caa
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 116 deletions.
6 changes: 4 additions & 2 deletions tests/autoloader_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace auth_saml2;

defined('MOODLE_INTERNAL') || die();

require_once(__DIR__ . '/../_autoload.php');
Expand All @@ -26,14 +28,14 @@
* @copyright 2018 Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class autoloader_test extends advanced_testcase {
final class autoloader_test extends \advanced_testcase {
public function test_it_loads_classes(): void {
$classes = [
\Psr\Log\LoggerInterface::class,
\SAML2\Utils::class,
\SimpleSAML\Configuration::class,
\RobRichards\XMLSecLibs\XMLSecEnc::class,
Twig\Loader\FilesystemLoader::class,
\Twig\Loader\FilesystemLoader::class,
];
foreach ($classes as $class) {
$found = class_exists($class) || interface_exists($class);
Expand Down
12 changes: 3 additions & 9 deletions tests/form_regenerate_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* auth_saml2 create/edit page unit tests
*
* @package auth_saml2
* @copyright Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_saml2;

use auth_saml2\form\regenerate;

/**
* auth_saml2 form submission unit tests
*
* @package auth_saml2
* @copyright Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class form_regenerate_test extends advanced_testcase {
final class form_regenerate_test extends \advanced_testcase {
public function test_regenerate_certificate_form(): void {
global $CFG, $DB, $USER;
$this->resetAfterTest();
Expand Down
12 changes: 3 additions & 9 deletions tests/group_rule_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Testcase class for group_rule class.
*
* @package auth_saml2
* @author Dmitrii Metelkin <[email protected]>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_saml2;

/**
* Testcase class for group_rule class.
*
* @package auth_saml2
* @author Dmitrii Metelkin <[email protected]>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class group_rule_test extends advanced_testcase {
final class group_rule_test extends \advanced_testcase {

/**
* Test we can get list of rules from config string.
Expand Down
14 changes: 4 additions & 10 deletions tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* SAML2 SP metadata tests.
*
* @package auth_saml2
* @copyright Brendan Heywood <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_saml2;

use auth_saml2\admin\saml2_settings;
use auth_saml2\admin\setting_idpmetadata;
use SimpleXMLElement;

defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../locallib.php');

/**
* Tests for SAML
*
* @package auth_saml2
* @copyright Brendan Heywood <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class locallib_test extends advanced_testcase {
final class locallib_test extends \advanced_testcase {
/**
* Regression test for Issue 132.
*/
Expand Down
13 changes: 3 additions & 10 deletions tests/metadata_fetcher_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Testcase class for metadata_fetcher class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use auth_saml2\metadata_fetcher;
namespace auth_saml2;

/**
* Testcase class for metadata_fetcher class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class metadata_fetcher_test extends advanced_testcase {
final class metadata_fetcher_test extends \advanced_testcase {

/** @var \Prophecy\Prophet */
protected $prophet;
Expand Down
13 changes: 3 additions & 10 deletions tests/metadata_parser_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Testcase class for metadata_parser class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use auth_saml2\metadata_parser;
namespace auth_saml2;

/**
* Testcase class for metadata_parser class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class metadata_parser_test extends basic_testcase {
final class metadata_parser_test extends \basic_testcase {

public function test_parse_metadata(): void {
$xml = file_get_contents(__DIR__ . '/fixtures/metadata.xml');
Expand Down
12 changes: 3 additions & 9 deletions tests/metadata_refresh_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Testcase class for metadata_refresh task class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_saml2;

use auth_saml2\task\metadata_refresh;

/**
* Testcase class for metadata_refresh task class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class metadata_refresh_test extends advanced_testcase {
final class metadata_refresh_test extends \advanced_testcase {

/** @var \Prophecy\Prophet */
protected $prophet;
Expand Down
13 changes: 3 additions & 10 deletions tests/metadata_writer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Testcase class for metadata_writer class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use auth_saml2\metadata_writer;
namespace auth_saml2;

/**
* Testcase class for metadata_writer class.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class metadata_writer_test extends basic_testcase {
final class metadata_writer_test extends \basic_testcase {

public function test_write_default_path(): void {
global $CFG;
Expand Down
13 changes: 3 additions & 10 deletions tests/redis_store_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Testcase class for auth/saml2 Redis store.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use auth_saml2\redis_store;
namespace auth_saml2;

/**
* Testcase class for auth/saml2 Redis store.
*
* @package auth_saml2
* @author Sam Chaffee
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class redis_store_test extends advanced_testcase {
final class redis_store_test extends \advanced_testcase {

/**
* @var null|\Redis
Expand Down
4 changes: 3 additions & 1 deletion tests/saml2_sitedata_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace auth_saml2;

defined('MOODLE_INTERNAL') || die();

require_once(__DIR__ . '/../_autoload.php');
Expand All @@ -26,7 +28,7 @@
* @copyright 2018 Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class saml2_sitedata_test extends advanced_testcase {
final class saml2_sitedata_test extends \advanced_testcase {
public function test_it_creates_the_directory_if_it_does_not_exist(): void {
global $CFG;

Expand Down
5 changes: 3 additions & 2 deletions tests/setting_idpmetadata_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace auth_saml2;

use auth_saml2\admin\setting_idpmetadata;
use auth_saml2\idp_data;

defined('MOODLE_INTERNAL') || die();

Expand All @@ -29,7 +30,7 @@
* @copyright 2018 Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class setting_idpmetadata_test extends advanced_testcase {
final class setting_idpmetadata_test extends \advanced_testcase {
/** @var setting_idpmetadata */
private static $config;

Expand Down
11 changes: 3 additions & 8 deletions tests/simplesamlphp_upgrade_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* auth_saml2 SimpleSAMLphp upgrade unit tests
*
* @package auth_saml2
* @copyright Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_saml2;

/**
* auth_saml2 SimpleSAMLphp upgrade unit tests
*
* @package auth_saml2
* @copyright Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class simplesamlphp_upgrade_test extends advanced_testcase {
final class simplesamlphp_upgrade_test extends \advanced_testcase {

/**
* Test to ensure that composer files are removed from compiled extlib/simplesamlphp.
Expand Down
4 changes: 2 additions & 2 deletions tests/ssl_algorithm_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

use auth_saml2\ssl_algorithms;
namespace auth_saml2;

/**
* Test Saml2 SSL Algorithms.
Expand All @@ -24,7 +24,7 @@
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class ssl_algorithm_test extends basic_testcase {
final class ssl_algorithm_test extends \basic_testcase {
public function test_default_saml_signature_algorithm_is_valid_saml_signature_algorithm(): void {
$this->assertTrue(array_key_exists(ssl_algorithms::get_default_saml_signature_algorithm(),
ssl_algorithms::get_valid_saml_signature_algorithms()));
Expand Down
15 changes: 3 additions & 12 deletions tests/user_extractor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Test for user extractor class.
*
* @package auth_saml2
* @author Dmitrii Metelkin <[email protected]>
* @copyright 2021 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use auth_saml2\user_extractor;
namespace auth_saml2;

/**
* Test for user extractor class.
Expand All @@ -33,7 +24,7 @@
* @copyright 2021 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class user_extractor_test extends advanced_testcase {
final class user_extractor_test extends \advanced_testcase {

/**
* A helper function to create a custom profile field.
Expand All @@ -44,7 +35,7 @@ final class user_extractor_test extends advanced_testcase {
*
* @return \stdClass
*/
protected function add_user_profile_field(string $shortname, string $datatype, bool $unique = false): stdClass {
protected function add_user_profile_field(string $shortname, string $datatype, bool $unique = false): \stdClass {
global $DB;

// Create a new profile field.
Expand Down
Loading

0 comments on commit 0b87caa

Please sign in to comment.