From bdc3ad00c989b93c75b99d90bb68a082bb9081e8 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sat, 1 Aug 2020 18:15:28 +0200 Subject: [PATCH 01/15] MDL-67673 phpunit: Bump to PHPUnit 8.5 and remove DBunit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes everything to break, but it's what we'll be fixing in the next commits, heh. :-) Generated with php72 (min version supported), following the instructions @ https://docs.moodle.org/dev/Composer --- composer.json | 3 +- composer.lock | 444 ++++++++++++++++++++++---------------------- lib/phpunit/lib.php | 1 - 3 files changed, 228 insertions(+), 220 deletions(-) diff --git a/composer.json b/composer.json index c267d2a426d..2f18f08a658 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,7 @@ } ], "require-dev": { - "phpunit/phpunit": "7.5.*", - "phpunit/dbunit": "4.0.*", + "phpunit/phpunit": "8.5.*", "moodlehq/behat-extension": "3.400.0", "mikey179/vfsstream": "^1.6", "instaclick/php-webdriver": "dev-local as 1.x-dev" diff --git a/composer.lock b/composer.lock index f6c97d56488..eefb88266d1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0716ef75702afddcf37c7abef09fbcd1", + "content-hash": "8fce11cc96863c2d4e5fb599b307d3fa", "packages": [], "packages-dev": [ { @@ -710,23 +710,23 @@ }, { "name": "guzzlehttp/promises", - "version": "v1.3.1", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + "reference": "60d379c243457e073cff02bc323a2a86cb355631" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631", + "reference": "60d379c243457e073cff02bc323a2a86cb355631", "shasum": "" }, "require": { - "php": ">=5.5.0" + "php": ">=5.5" }, "require-dev": { - "phpunit/phpunit": "^4.0" + "symfony/phpunit-bridge": "^4.4 || ^5.1" }, "type": "library", "extra": { @@ -757,20 +757,20 @@ "keywords": [ "promise" ], - "time": "2016-12-20T10:07:11+00:00" + "time": "2020-09-30T07:37:28+00:00" }, { "name": "guzzlehttp/psr7", - "version": "1.6.1", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3", + "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3", "shasum": "" }, "require": { @@ -783,15 +783,15 @@ }, "require-dev": { "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" }, "suggest": { - "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.7-dev" } }, "autoload": { @@ -828,7 +828,7 @@ "uri", "url" ], - "time": "2019-07-01T23:21:34+00:00" + "time": "2020-09-30T07:37:11+00:00" }, { "name": "instaclick/php-webdriver", @@ -1238,16 +1238,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.2.1", + "version": "5.2.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d870572532cd70bc3fab58f2e23ad423c8404c44" + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d870572532cd70bc3fab58f2e23ad423c8404c44", - "reference": "d870572532cd70bc3fab58f2e23ad423c8404c44", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", "shasum": "" }, "require": { @@ -1286,20 +1286,20 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-08-15T11:14:08+00:00" + "time": "2020-09-03T19:13:55+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", - "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", "shasum": "" }, "require": { @@ -1331,32 +1331,32 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-06-27T10:12:23+00:00" + "time": "2020-09-17T18:55:26+00:00" }, { "name": "phpspec/prophecy", - "version": "1.11.1", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160" + "reference": "8ce87516be71aae9b956f81906aaf0338e0d8a2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160", - "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/8ce87516be71aae9b956f81906aaf0338e0d8a2d", + "reference": "8ce87516be71aae9b956f81906aaf0338e0d8a2d", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2", - "php": "^7.2", - "phpdocumentor/reflection-docblock": "^5.0", + "php": "^7.2 || ~8.0, <8.1", + "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { "phpspec/phpspec": "^6.0", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^8.0 || ^9.0 <9.3" }, "type": "library", "extra": { @@ -1394,97 +1394,44 @@ "spy", "stub" ], - "time": "2020-07-08T12:44:21+00:00" - }, - { - "name": "phpunit/dbunit", - "version": "4.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/dbunit.git", - "reference": "e77b469c3962b5a563f09a2a989f1c9bd38b8615" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/e77b469c3962b5a563f09a2a989f1c9bd38b8615", - "reference": "e77b469c3962b5a563f09a2a989f1c9bd38b8615", - "shasum": "" - }, - "require": { - "ext-pdo": "*", - "ext-simplexml": "*", - "php": "^7.1", - "phpunit/phpunit": "^7.0", - "symfony/yaml": "^3.0 || ^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "PHPUnit extension for database interaction testing", - "homepage": "https://github.com/sebastianbergmann/dbunit/", - "keywords": [ - "database", - "testing", - "xunit" - ], - "abandoned": true, - "time": "2018-02-07T06:47:59+00:00" + "time": "2020-09-29T09:10:42+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "6.1.4", + "version": "7.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", + "phpunit/php-token-stream": "^3.1.1", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", + "sebastian/environment": "^4.2.2", "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-xdebug": "^2.6.0" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -1510,7 +1457,7 @@ "testing", "xunit" ], - "time": "2018-10-31T16:06:48+00:00" + "time": "2019-11-20T13:55:58+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1704,53 +1651,52 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.20", + "version": "8.5.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" + "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34c18baa6a44f1d1fbf0338907139e9dce95b997", + "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.1", + "doctrine/instantiator": "^1.2.0", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.2", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^7.0.7", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.2", + "sebastian/exporter": "^3.1.1", + "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", "sebastian/version": "^2.0.1" }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -1758,7 +1704,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.5-dev" + "dev-master": "8.5-dev" } }, "autoload": { @@ -1784,7 +1730,17 @@ "testing", "xunit" ], - "time": "2020-01-08T08:45:45+00:00" + "funding": [ + { + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-22T07:06:58+00:00" }, { "name": "psr/container", @@ -2258,23 +2214,26 @@ }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -2282,7 +2241,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2305,7 +2264,7 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "time": "2019-02-01T05:30:01+00:00" }, { "name": "sebastian/object-enumerator", @@ -2494,6 +2453,52 @@ "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "time": "2018-10-04T04:07:39+00:00" }, + { + "name": "sebastian/type", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2019-07-02T08:10:15+00:00" + }, { "name": "sebastian/version", "version": "2.0.1", @@ -2539,16 +2544,16 @@ }, { "name": "symfony/browser-kit", - "version": "v4.4.13", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "f53310646af9901292488b2ff36e26ea10f545f5" + "reference": "9a1786e5020783605a30cff2ceed9aca030e8d80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/f53310646af9901292488b2ff36e26ea10f545f5", - "reference": "f53310646af9901292488b2ff36e26ea10f545f5", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/9a1786e5020783605a30cff2ceed9aca030e8d80", + "reference": "9a1786e5020783605a30cff2ceed9aca030e8d80", "shasum": "" }, "require": { @@ -2608,20 +2613,20 @@ "type": "tidelift" } ], - "time": "2020-05-22T17:28:00+00:00" + "time": "2020-10-02T08:38:15+00:00" }, { "name": "symfony/config", - "version": "v4.4.13", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "043bf8652c307ebc23ce44047d215eec889d8850" + "reference": "7c5a1002178a612787c291a4f515f87b19176b61" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/043bf8652c307ebc23ce44047d215eec889d8850", - "reference": "043bf8652c307ebc23ce44047d215eec889d8850", + "url": "https://api.github.com/repos/symfony/config/zipball/7c5a1002178a612787c291a4f515f87b19176b61", + "reference": "7c5a1002178a612787c291a4f515f87b19176b61", "shasum": "" }, "require": { @@ -2686,20 +2691,20 @@ "type": "tidelift" } ], - "time": "2020-08-10T07:27:51+00:00" + "time": "2020-10-02T07:34:48+00:00" }, { "name": "symfony/console", - "version": "v5.1.5", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "186f395b256065ba9b890c0a4e48a91d598fa2cf" + "reference": "ae789a8a2ad189ce7e8216942cdb9b77319f5eb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/186f395b256065ba9b890c0a4e48a91d598fa2cf", - "reference": "186f395b256065ba9b890c0a4e48a91d598fa2cf", + "url": "https://api.github.com/repos/symfony/console/zipball/ae789a8a2ad189ce7e8216942cdb9b77319f5eb8", + "reference": "ae789a8a2ad189ce7e8216942cdb9b77319f5eb8", "shasum": "" }, "require": { @@ -2779,11 +2784,11 @@ "type": "tidelift" } ], - "time": "2020-09-02T07:07:40+00:00" + "time": "2020-10-07T15:23:00+00:00" }, { "name": "symfony/css-selector", - "version": "v5.1.5", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -2850,16 +2855,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v4.4.13", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "384c2601e5a6228d60b041911d63f010e0885ffb" + "reference": "89274c8847dff2ed703e481843eb9159ca25cc6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/384c2601e5a6228d60b041911d63f010e0885ffb", - "reference": "384c2601e5a6228d60b041911d63f010e0885ffb", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/89274c8847dff2ed703e481843eb9159ca25cc6e", + "reference": "89274c8847dff2ed703e481843eb9159ca25cc6e", "shasum": "" }, "require": { @@ -2933,20 +2938,20 @@ "type": "tidelift" } ], - "time": "2020-09-01T17:42:15+00:00" + "time": "2020-09-10T10:08:39+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.1.3", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14" + "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5e20b83385a77593259c9f8beb2c43cd03b2ac14", - "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5fa56b4074d1ae755beb55617ddafe6f5d78f665", + "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665", "shasum": "" }, "require": { @@ -2955,7 +2960,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" }, "thanks": { "name": "symfony/contracts", @@ -2997,20 +3002,20 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:49:21+00:00" + "time": "2020-09-07T11:33:47+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.4.13", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "6dd1e7adef4b7efeeb9691fd619279027d4dcf85" + "reference": "bdcb7633a501770a0daefbf81d2e6b28c3864f2b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/6dd1e7adef4b7efeeb9691fd619279027d4dcf85", - "reference": "6dd1e7adef4b7efeeb9691fd619279027d4dcf85", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/bdcb7633a501770a0daefbf81d2e6b28c3864f2b", + "reference": "bdcb7633a501770a0daefbf81d2e6b28c3864f2b", "shasum": "" }, "require": { @@ -3072,20 +3077,20 @@ "type": "tidelift" } ], - "time": "2020-08-12T06:20:35+00:00" + "time": "2020-10-02T07:34:48+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.1.5", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "94871fc0a69c3c5da57764187724cdce0755899c" + "reference": "d5de97d6af175a9e8131c546db054ca32842dd0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/94871fc0a69c3c5da57764187724cdce0755899c", - "reference": "94871fc0a69c3c5da57764187724cdce0755899c", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d5de97d6af175a9e8131c546db054ca32842dd0f", + "reference": "d5de97d6af175a9e8131c546db054ca32842dd0f", "shasum": "" }, "require": { @@ -3105,6 +3110,7 @@ "psr/log": "~1.0", "symfony/config": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", + "symfony/error-handler": "^4.4|^5.0", "symfony/expression-language": "^4.4|^5.0", "symfony/http-foundation": "^4.4|^5.0", "symfony/service-contracts": "^1.1|^2", @@ -3158,20 +3164,20 @@ "type": "tidelift" } ], - "time": "2020-08-13T14:19:42+00:00" + "time": "2020-09-18T14:27:32+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.1.3", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "f6f613d74cfc5a623fc36294d3451eb7fa5a042b" + "reference": "0ba7d54483095a198fa51781bc608d17e84dffa2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f6f613d74cfc5a623fc36294d3451eb7fa5a042b", - "reference": "f6f613d74cfc5a623fc36294d3451eb7fa5a042b", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/0ba7d54483095a198fa51781bc608d17e84dffa2", + "reference": "0ba7d54483095a198fa51781bc608d17e84dffa2", "shasum": "" }, "require": { @@ -3184,7 +3190,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" }, "thanks": { "name": "symfony/contracts", @@ -3234,20 +3240,20 @@ "type": "tidelift" } ], - "time": "2020-07-06T13:23:11+00:00" + "time": "2020-09-07T11:33:47+00:00" }, { "name": "symfony/filesystem", - "version": "v5.1.5", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "f7b9ed6142a34252d219801d9767dedbd711da1a" + "reference": "1a8697545a8d87b9f2f6b1d32414199cc5e20aae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/f7b9ed6142a34252d219801d9767dedbd711da1a", - "reference": "f7b9ed6142a34252d219801d9767dedbd711da1a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/1a8697545a8d87b9f2f6b1d32414199cc5e20aae", + "reference": "1a8697545a8d87b9f2f6b1d32414199cc5e20aae", "shasum": "" }, "require": { @@ -3298,7 +3304,7 @@ "type": "tidelift" } ], - "time": "2020-08-21T17:19:47+00:00" + "time": "2020-09-27T14:02:37+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4005,16 +4011,16 @@ }, { "name": "symfony/process", - "version": "v5.1.5", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "1864216226af21eb76d9477f691e7cbf198e0402" + "reference": "d3a2e64866169586502f0cd9cab69135ad12cee9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/1864216226af21eb76d9477f691e7cbf198e0402", - "reference": "1864216226af21eb76d9477f691e7cbf198e0402", + "url": "https://api.github.com/repos/symfony/process/zipball/d3a2e64866169586502f0cd9cab69135ad12cee9", + "reference": "d3a2e64866169586502f0cd9cab69135ad12cee9", "shasum": "" }, "require": { @@ -4065,20 +4071,20 @@ "type": "tidelift" } ], - "time": "2020-07-23T08:36:24+00:00" + "time": "2020-09-02T16:23:27+00:00" }, { "name": "symfony/service-contracts", - "version": "v2.1.3", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442" + "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/58c7475e5457c5492c26cc740cc0ad7464be9442", - "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", + "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", "shasum": "" }, "require": { @@ -4091,7 +4097,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" }, "thanks": { "name": "symfony/contracts", @@ -4141,20 +4147,20 @@ "type": "tidelift" } ], - "time": "2020-07-06T13:23:11+00:00" + "time": "2020-09-07T11:33:47+00:00" }, { "name": "symfony/string", - "version": "v5.1.5", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "0de4cc1e18bb596226c06a82e2e7e9bc6001a63a" + "reference": "4a9afe9d07bac506f75bcee8ed3ce76da5a9343e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/0de4cc1e18bb596226c06a82e2e7e9bc6001a63a", - "reference": "0de4cc1e18bb596226c06a82e2e7e9bc6001a63a", + "url": "https://api.github.com/repos/symfony/string/zipball/4a9afe9d07bac506f75bcee8ed3ce76da5a9343e", + "reference": "4a9afe9d07bac506f75bcee8ed3ce76da5a9343e", "shasum": "" }, "require": { @@ -4226,20 +4232,20 @@ "type": "tidelift" } ], - "time": "2020-08-17T07:48:54+00:00" + "time": "2020-09-15T12:23:47+00:00" }, { "name": "symfony/translation", - "version": "v4.4.13", + "version": "v4.4.15", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "700e6e50174b0cdcf0fa232773bec5c314680575" + "reference": "8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/700e6e50174b0cdcf0fa232773bec5c314680575", - "reference": "700e6e50174b0cdcf0fa232773bec5c314680575", + "url": "https://api.github.com/repos/symfony/translation/zipball/8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd", + "reference": "8494fa1bbf9d77fe1e7d50ac8ccfb80a858a98bd", "shasum": "" }, "require": { @@ -4316,20 +4322,20 @@ "type": "tidelift" } ], - "time": "2020-08-17T09:56:45+00:00" + "time": "2020-10-02T07:34:48+00:00" }, { "name": "symfony/translation-contracts", - "version": "v2.1.3", + "version": "v2.3.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "616a9773c853097607cf9dd6577d5b143ffdcd63" + "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/616a9773c853097607cf9dd6577d5b143ffdcd63", - "reference": "616a9773c853097607cf9dd6577d5b143ffdcd63", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/e2eaa60b558f26a4b0354e1bbb25636efaaad105", + "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105", "shasum": "" }, "require": { @@ -4341,7 +4347,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.3-dev" }, "thanks": { "name": "symfony/contracts", @@ -4391,39 +4397,43 @@ "type": "tidelift" } ], - "time": "2020-07-06T13:23:11+00:00" + "time": "2020-09-28T13:05:58+00:00" }, { "name": "symfony/yaml", - "version": "v4.4.13", + "version": "v5.1.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "e2a69525b11a33be51cb00b8d6d13a9258a296b1" + "reference": "e147a68cb66a8b510f4b7481fe4da5b2ab65ec6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e2a69525b11a33be51cb00b8d6d13a9258a296b1", - "reference": "e2a69525b11a33be51cb00b8d6d13a9258a296b1", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e147a68cb66a8b510f4b7481fe4da5b2ab65ec6a", + "reference": "e147a68cb66a8b510f4b7481fe4da5b2ab65ec6a", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/console": "<3.4" + "symfony/console": "<4.4" }, "require-dev": { - "symfony/console": "^3.4|^4.0|^5.0" + "symfony/console": "^4.4|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" }, + "bin": [ + "Resources/bin/yaml-lint" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -4464,7 +4474,7 @@ "type": "tidelift" } ], - "time": "2020-08-26T08:30:46+00:00" + "time": "2020-09-27T03:44:28+00:00" }, { "name": "theseer/tokenizer", diff --git a/lib/phpunit/lib.php b/lib/phpunit/lib.php index 3a70ac0ac3d..d470c34126e 100644 --- a/lib/phpunit/lib.php +++ b/lib/phpunit/lib.php @@ -33,7 +33,6 @@ require_once(__DIR__.'/classes/phpmailer_sink.php'); require_once(__DIR__.'/classes/base_testcase.php'); require_once(__DIR__.'/classes/basic_testcase.php'); require_once(__DIR__.'/classes/database_driver_testcase.php'); -require_once(__DIR__.'/classes/arraydataset.php'); require_once(__DIR__.'/classes/advanced_testcase.php'); require_once(__DIR__.'/classes/hint_resultprinter.php'); // Loaded here because phpunit.xml does not support relative links for printerFile. require_once(__DIR__.'/classes/constraint_object_is_equal_with_exceptions.php'); From f6711bb394f5b054c0ae175b82af5b9c0aca5f90 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 2 Aug 2020 10:59:12 +0200 Subject: [PATCH 02/15] MDL-67673 phpunit: Fix the return type of template methods All the setup/teardown/pre/post/conditions template methods now are required to return void. This was warned with phpunit 7 and now is enforced. At the same time, fix a few wrong function names, provider data and param types, return statements... --- admin/tool/behat/tests/manager_util_test.php | 2 +- admin/tool/capability/tests/events_test.php | 2 +- admin/tool/cohortroles/tests/api_test.php | 2 +- admin/tool/cohortroles/tests/privacy_test.php | 2 +- .../tool/dataprivacy/tests/expired_data_requests_test.php | 2 +- admin/tool/dataprivacy/tests/task_test.php | 2 +- admin/tool/langimport/tests/events_test.php | 2 +- admin/tool/log/store/database/tests/privacy_test.php | 2 +- admin/tool/log/store/legacy/tests/privacy_test.php | 2 +- admin/tool/log/store/standard/tests/privacy_test.php | 2 +- admin/tool/log/store/standard/tests/store_test.php | 2 +- admin/tool/log/tests/privacy_test.php | 2 +- admin/tool/lp/tests/externallib_test.php | 2 +- admin/tool/lpmigrate/tests/processor_test.php | 2 +- admin/tool/messageinbound/tests/manager_test.php | 2 +- admin/tool/messageinbound/tests/privacy_test.php | 2 +- admin/tool/mobile/tests/privacy_provider_test.php | 2 +- admin/tool/monitor/tests/eventobservers_test.php | 2 +- admin/tool/monitor/tests/events_test.php | 2 +- admin/tool/monitor/tests/generator_test.php | 4 ++-- admin/tool/monitor/tests/privacy_test.php | 2 +- admin/tool/monitor/tests/rule_manager_test.php | 4 ++-- admin/tool/monitor/tests/subscription_test.php | 2 +- .../tool/monitor/tests/task_check_subscriptions_test.php | 2 +- admin/tool/monitor/tests/task_clean_events_test.php | 2 +- admin/tool/policy/tests/externallib_test.php | 2 +- admin/tool/policy/tests/privacy_provider_test.php | 2 +- admin/tool/recyclebin/tests/category_bin_test.php | 2 +- admin/tool/recyclebin/tests/course_bin_test.php | 2 +- admin/tool/recyclebin/tests/events_test.php | 2 +- admin/tool/usertours/tests/accessdate_filter_test.php | 2 +- admin/tool/usertours/tests/manager_test.php | 4 ++-- admin/tool/usertours/tests/role_filter_test.php | 2 +- admin/tool/usertours/tests/step_test.php | 4 ++-- admin/tool/usertours/tests/tour_test.php | 4 ++-- analytics/tests/course_test.php | 2 +- analytics/tests/dataset_manager_test.php | 2 +- analytics/tests/model_test.php | 2 +- analytics/tests/prediction_actions_test.php | 2 +- analytics/tests/prediction_test.php | 2 +- analytics/tests/privacy_test.php | 2 +- analytics/tests/stats_test.php | 2 +- auth/email/tests/external_test.php | 2 +- auth/manual/tests/manual_test.php | 2 +- auth/manual/tests/privacy_provider_test.php | 2 +- auth/mnet/tests/privacy_provider_test.php | 2 +- auth/oauth2/tests/privacy_provider_test.php | 2 +- auth/tests/external_test.php | 4 ++-- auth/tests/privacy_test.php | 2 +- .../condition/completion/tests/condition_test.php | 2 +- availability/condition/date/tests/condition_test.php | 2 +- availability/condition/group/tests/condition_test.php | 2 +- availability/condition/grouping/tests/condition_test.php | 2 +- availability/condition/profile/tests/condition_test.php | 2 +- availability/tests/info_test.php | 2 +- availability/tests/tree_test.php | 2 +- backup/controller/tests/controller_test.php | 2 +- backup/converter/moodle1/tests/moodle1_converter_test.php | 4 ++-- backup/moodle2/tests/backup_encrypted_content_test.php | 2 +- backup/moodle2/tests/backup_xml_transformer_test.php | 2 +- backup/tests/automated_backup_test.php | 2 +- backup/tests/course_copy_test.php | 4 ++-- backup/tests/externallib_test.php | 4 ++-- backup/util/checks/tests/checks_test.php | 2 +- backup/util/dbops/tests/backup_dbops_test.php | 2 +- backup/util/factories/tests/factories_test.php | 4 ++-- .../tests/restore_structure_parser_processor_test.php | 2 +- backup/util/plan/tests/plan_test.php | 2 +- backup/util/plan/tests/step_test.php | 2 +- backup/util/plan/tests/task_test.php | 2 +- backup/util/structure/tests/structure_test.php | 2 +- badges/tests/badgeslib_test.php | 2 +- badges/tests/external_test.php | 2 +- badges/tests/privacy_test.php | 2 +- blocks/comments/tests/events_test.php | 2 +- blocks/comments/tests/privacy_provider_test.php | 2 +- blocks/online_users/tests/online_users_test.php | 2 +- blocks/recentlyaccesseditems/tests/observer_test.php | 4 ++-- blocks/rss_client/tests/privacy_test.php | 2 +- blocks/tests/privacy_test.php | 2 +- blog/tests/events_test.php | 2 +- blog/tests/external_test.php | 2 +- blog/tests/lib_test.php | 2 +- blog/tests/privacy_test.php | 2 +- cache/stores/apcu/tests/apcu_test.php | 6 +++--- cache/stores/redis/tests/compressor_test.php | 2 +- cache/stores/redis/tests/redis_test.php | 6 +++--- cache/tests/administration_helper_test.php | 4 ++-- cache/tests/cache_test.php | 4 ++-- cache/tests/config_writer_test.php | 4 ++-- cache/tests/fixtures/stores.php | 4 ++-- calendar/tests/calendartype_test.php | 2 +- calendar/tests/container_test.php | 2 +- calendar/tests/events_related_objects_cache_test.php | 2 +- calendar/tests/events_test.php | 2 +- calendar/tests/externallib_test.php | 2 +- calendar/tests/lib_test.php | 2 +- calendar/tests/local_api_test.php | 2 +- calendar/tests/privacy_test.php | 2 +- calendar/tests/rrule_manager_test.php | 2 +- calendar/tests/std_proxy_test.php | 2 +- cohort/tests/privacy_test.php | 2 +- comment/tests/externallib_test.php | 2 +- comment/tests/privacy_test.php | 2 +- competency/tests/external_test.php | 2 +- competency/tests/privacy_test.php | 2 +- completion/tests/api_test.php | 2 +- completion/tests/progress_test.php | 2 +- course/format/weeks/tests/observer_test.php | 2 +- course/tests/category_hooks_test.php | 2 +- course/tests/category_test.php | 2 +- course/tests/customfield_test.php | 2 +- course/tests/events_test.php | 2 +- course/tests/externallib_test.php | 2 +- course/tests/search_test.php | 2 +- customfield/field/checkbox/tests/plugin_test.php | 2 +- customfield/field/date/tests/plugin_test.php | 4 ++-- customfield/field/select/tests/plugin_test.php | 4 ++-- customfield/field/text/tests/plugin_test.php | 2 +- customfield/field/textarea/tests/plugin_test.php | 2 +- enrol/flatfile/tests/privacy_provider_test.php | 2 +- enrol/imsenterprise/tests/imsenterprise_test.php | 2 +- enrol/lti/tests/data_connector_test.php | 2 +- enrol/lti/tests/helper_test.php | 2 +- enrol/lti/tests/lib_test.php | 2 +- enrol/lti/tests/privacy_provider_test.php | 2 +- enrol/lti/tests/sync_members_test.php | 2 +- enrol/lti/tests/tool_provider_test.php | 2 +- enrol/paypal/tests/privacy_provider_test.php | 2 +- enrol/tests/course_enrolment_manager_test.php | 2 +- enrol/tests/role_external_test.php | 4 ++-- favourites/tests/component_favourite_service_test.php | 2 +- favourites/tests/privacy_test.php | 2 +- favourites/tests/repository_test.php | 2 +- favourites/tests/user_favourite_service_test.php | 2 +- filter/algebra/tests/filter_test.php | 2 +- filter/displayh5p/tests/filter_test.php | 4 ++-- filter/multilang/tests/filter_test.php | 2 +- filter/tex/tests/filter_test.php | 2 +- grade/export/ods/tests/logging_test.php | 4 ++-- grade/export/txt/tests/logging_test.php | 4 ++-- grade/export/xls/tests/logging_test.php | 4 ++-- grade/export/xml/tests/logging_test.php | 4 ++-- grade/import/csv/tests/load_data_test.php | 2 +- grade/report/grader/tests/privacy_test.php | 2 +- grade/report/overview/tests/externallib_test.php | 2 +- grade/report/user/tests/lib_test.php | 2 +- grade/report/user/tests/privacy_test.php | 2 +- grade/tests/events_test.php | 2 +- ...ades_grader_gradingpanel_point_external_store_test.php | 2 +- grade/tests/privacy_test.php | 2 +- h5p/tests/editor_ajax_test.php | 2 +- h5p/tests/editor_framework_test.php | 2 +- h5p/tests/event_h5p_deleted_test.php | 2 +- h5p/tests/event_h5p_viewed_test.php | 2 +- h5p/tests/external_test.php | 2 +- h5p/tests/framework_test.php | 2 +- h5p/tests/generator_test.php | 2 +- h5p/tests/h5p_core_test.php | 2 +- h5p/tests/h5p_file_storage_test.php | 2 +- iplookup/tests/geoip_test.php | 2 +- iplookup/tests/geoplugin_test.php | 2 +- lib/antivirus/clamav/tests/scanner_test.php | 4 ++-- lib/ddl/tests/ddl_test.php | 2 +- lib/dml/tests/dml_test.php | 2 +- lib/dml/tests/pgsql_native_recordset_test.php | 4 ++-- lib/dml/tests/recordset_walk_test.php | 2 +- lib/dml/tests/sqlsrv_native_moodle_database_test.php | 2 +- lib/filebrowser/tests/file_browser_test.php | 2 +- lib/filestorage/tests/file_system_filedir_test.php | 4 ++-- lib/filestorage/tests/file_system_test.php | 4 ++-- lib/filestorage/tests/zip_packer_test.php | 2 +- lib/form/tests/dateselector_test.php | 2 +- lib/form/tests/datetimeselector_test.php | 2 +- lib/grade/tests/fixtures/lib.php | 2 +- lib/phpunit/classes/database_driver_testcase.php | 8 ++++---- lib/phpunit/classes/restore_date_testcase.php | 4 ++-- lib/phpunit/tests/basic_test.php | 2 +- lib/tests/ajaxlib_test.php | 4 ++-- lib/tests/antivirus_test.php | 4 ++-- lib/tests/blocklib_test.php | 4 ++-- lib/tests/calendar_cron_task_test.php | 2 +- lib/tests/collator_test.php | 4 ++-- lib/tests/component_test.php | 4 ++-- lib/tests/core_media_player_native.php | 4 ++-- lib/tests/csvclass_test.php | 2 +- lib/tests/customcontext_test.php | 2 +- lib/tests/event/contentbank_content_created_test.php | 2 +- lib/tests/event/contentbank_content_deleted_test.php | 2 +- lib/tests/event/contentbank_content_updated_test.php | 2 +- lib/tests/event/contentbank_content_uploaded_test.php | 2 +- lib/tests/event/contentbank_content_viewed_test.php | 2 +- lib/tests/event_profile_field_test.php | 2 +- lib/tests/event_user_graded_test.php | 2 +- lib/tests/events_test.php | 2 +- lib/tests/exporter_test.php | 2 +- lib/tests/externallib_test.php | 4 ++-- lib/tests/gdlib_test.php | 2 +- lib/tests/h5p_get_content_types_task_test.php | 2 +- lib/tests/lock_test.php | 2 +- lib/tests/medialib_test.php | 4 ++-- lib/tests/moodle_page_test.php | 2 +- lib/tests/myprofilelib_test.php | 2 +- lib/tests/notification_test.php | 4 ++-- lib/tests/persistent_test.php | 2 +- lib/tests/plugin_manager_test.php | 2 +- lib/tests/plugininfo/base_test.php | 2 +- lib/tests/questionlib_test.php | 2 +- lib/tests/rsslib_test.php | 2 +- lib/tests/session_redis_test.php | 4 ++-- lib/tests/statslib_test.php | 2 +- lib/tests/task_database_logger_test.php | 4 ++-- lib/tests/task_logging_test.php | 2 +- lib/tests/time_splittings_test.php | 2 +- lib/tests/user_test.php | 2 +- lib/tests/useragent_test.php | 2 +- lib/xapi/tests/external/post_statement_test.php | 2 +- media/player/html5audio/tests/player_test.php | 2 +- media/player/html5video/tests/player_test.php | 2 +- media/player/swf/tests/player_test.php | 2 +- media/player/videojs/tests/player_test.php | 2 +- media/player/vimeo/tests/player_test.php | 2 +- media/player/youtube/tests/player_test.php | 2 +- message/output/airnotifier/tests/externallib_test.php | 2 +- message/output/airnotifier/tests/privacy_test.php | 2 +- message/output/email/tests/privacy_test.php | 2 +- message/output/jabber/tests/privacy_test.php | 2 +- message/output/popup/tests/api_test.php | 2 +- message/output/popup/tests/externallib_test.php | 2 +- message/tests/events_test.php | 2 +- message/tests/externallib_test.php | 2 +- message/tests/helper_test.php | 2 +- message/tests/inbound_test.php | 2 +- message/tests/messagelib_test.php | 2 +- message/tests/migrate_message_data_task_test.php | 2 +- message/tests/search_received_test.php | 2 +- message/tests/search_sent_test.php | 2 +- mnet/service/enrol/tests/privacy_test.php | 4 ++-- mnet/tests/events_test.php | 2 +- mod/assign/feedback/editpdf/tests/privacy_test.php | 2 +- mod/assign/tests/base_test.php | 2 +- mod/book/tests/events_test.php | 2 +- mod/book/tests/lib_test.php | 2 +- mod/book/tests/search_test.php | 2 +- mod/book/tool/exportimscp/tests/events_test.php | 2 +- mod/book/tool/importhtml/tests/locallib_test.php | 2 +- mod/book/tool/print/tests/events_test.php | 2 +- mod/chat/tests/lib_test.php | 2 +- mod/chat/tests/privacy_test.php | 2 +- mod/choice/tests/events_test.php | 2 +- mod/choice/tests/privacy_provider_test.php | 2 +- mod/data/tests/events_test.php | 2 +- mod/data/tests/externallib_test.php | 2 +- mod/data/tests/import_test.php | 2 +- mod/data/tests/lib_test.php | 2 +- mod/data/tests/privacy_provider_test.php | 2 +- mod/data/tests/search_test.php | 2 +- mod/feedback/tests/events_test.php | 2 +- mod/feedback/tests/external_test.php | 2 +- mod/feedback/tests/privacy_test.php | 2 +- mod/folder/tests/events_test.php | 2 +- mod/folder/tests/lib_test.php | 4 ++-- mod/folder/tests/search_test.php | 2 +- mod/forum/tests/builders_exported_posts_test.php | 4 ++-- mod/forum/tests/events_test.php | 4 ++-- mod/forum/tests/exporters_discussion_test.php | 4 ++-- mod/forum/tests/externallib_test.php | 4 ++-- mod/forum/tests/generator_test.php | 4 ++-- mod/forum/tests/lib_test.php | 4 ++-- mod/forum/tests/mail_group_test.php | 4 ++-- mod/forum/tests/mail_test.php | 4 ++-- mod/forum/tests/maildigest_test.php | 4 ++-- mod/forum/tests/managers_capability_test.php | 4 ++-- mod/forum/tests/privacy_provider_test.php | 2 +- mod/forum/tests/private_replies_test.php | 4 ++-- mod/forum/tests/qanda_test.php | 4 ++-- mod/forum/tests/search_test.php | 2 +- mod/forum/tests/subscriptions_test.php | 4 ++-- mod/forum/tests/vaults_discussion_list_test.php | 2 +- mod/forum/tests/vaults_discussion_test.php | 2 +- mod/forum/tests/vaults_post_test.php | 4 ++-- mod/glossary/tests/events_test.php | 2 +- mod/glossary/tests/privacy_provider_test.php | 2 +- mod/glossary/tests/search_test.php | 2 +- mod/label/tests/lib_test.php | 4 ++-- mod/lesson/tests/events_test.php | 2 +- mod/lesson/tests/external_test.php | 2 +- mod/lesson/tests/privacy_test.php | 2 +- .../gradebookservices/tests/privacy_provider_test.php | 2 +- .../service/gradebookservices/tests/task_cleanup_test.php | 2 +- .../service/memberships/tests/privacy_provider_test.php | 2 +- mod/lti/tests/externallib_test.php | 2 +- mod/lti/tests/lib_test.php | 2 +- mod/lti/tests/task_clean_access_tokens_test.php | 2 +- mod/page/tests/lib_test.php | 2 +- mod/quiz/accessrule/seb/tests/access_manager_test.php | 2 +- mod/quiz/accessrule/seb/tests/backup_restore_test.php | 2 +- mod/quiz/accessrule/seb/tests/event_test.php | 4 ++-- mod/quiz/accessrule/seb/tests/link_generator_test.php | 2 +- mod/quiz/accessrule/seb/tests/quiz_settings_test.php | 2 +- mod/quiz/accessrule/seb/tests/rule_test.php | 4 ++-- mod/quiz/accessrule/seb/tests/template_test.php | 2 +- mod/quiz/tests/external_test.php | 2 +- mod/quiz/tests/repaginate_test.php | 4 ++-- mod/resource/tests/events_test.php | 2 +- mod/resource/tests/lib_test.php | 2 +- mod/resource/tests/search_test.php | 2 +- mod/scorm/report/basic/tests/privacy_test.php | 2 +- mod/scorm/report/interactions/tests/privacy_test.php | 2 +- mod/scorm/report/objectives/tests/privacy_test.php | 2 +- mod/scorm/tests/events_test.php | 2 +- mod/scorm/tests/externallib_test.php | 2 +- mod/scorm/tests/lib_test.php | 2 +- mod/scorm/tests/locallib_test.php | 2 +- mod/survey/tests/events_test.php | 2 +- mod/survey/tests/externallib_test.php | 2 +- mod/survey/tests/lib_test.php | 2 +- mod/survey/tests/privacy_test.php | 2 +- mod/url/tests/lib_test.php | 4 ++-- mod/wiki/tests/events_test.php | 2 +- mod/wiki/tests/externallib_test.php | 2 +- mod/wiki/tests/privacy_test.php | 2 +- mod/wiki/tests/search_test.php | 2 +- mod/workshop/allocation/random/tests/allocator_test.php | 4 ++-- mod/workshop/eval/best/tests/lib_test.php | 4 ++-- mod/workshop/form/accumulative/tests/lib_test.php | 4 ++-- mod/workshop/form/numerrors/tests/lib_test.php | 4 ++-- mod/workshop/form/rubric/tests/lib_test.php | 4 ++-- mod/workshop/tests/events_test.php | 4 ++-- mod/workshop/tests/external_test.php | 2 +- mod/workshop/tests/locallib_test.php | 4 ++-- mod/workshop/tests/portfolio_caller_test.php | 4 ++-- mod/workshop/tests/privacy_provider_test.php | 2 +- my/tests/events_test.php | 2 +- notes/tests/events_test.php | 2 +- notes/tests/lib_test.php | 4 ++-- privacy/classes/tests/provider_testcase.php | 2 +- privacy/tests/manager_test.php | 2 +- privacy/tests/writer_test.php | 2 +- question/behaviour/adaptive/tests/behaviourtype_test.php | 2 +- question/behaviour/adaptive/tests/mark_display_test.php | 2 +- .../behaviour/deferredcbm/tests/behaviourtype_test.php | 2 +- .../deferredfeedback/tests/behaviourtype_test.php | 2 +- .../behaviour/immediatecbm/tests/behaviourtype_test.php | 2 +- .../immediatefeedback/tests/behaviourtype_test.php | 2 +- .../informationitem/tests/behaviourtype_test.php | 2 +- .../behaviour/interactive/tests/behaviourtype_test.php | 2 +- .../interactivecountback/tests/behaviourtype_test.php | 2 +- .../behaviour/manualgraded/tests/behaviourtype_test.php | 2 +- question/behaviour/missing/tests/behaviourtype_test.php | 2 +- question/engine/tests/helpers.php | 4 ++-- question/engine/tests/questionattempt_test.php | 4 ++-- question/engine/tests/questionattempt_with_steps_test.php | 4 ++-- question/engine/tests/questionattemptiterator_test.php | 6 +++--- .../engine/tests/questionattemptstepiterator_test.php | 6 +++--- question/engine/tests/questionusage_autosave_test.php | 2 +- question/engine/tests/unitofwork_test.php | 4 ++-- question/engine/upgrade/tests/helper.php | 4 ++-- question/tests/category_class_test.php | 2 +- question/tests/events_test.php | 2 +- question/tests/externallib_test.php | 2 +- question/type/calculated/tests/questiontype_test.php | 4 ++-- .../type/calculatedsimple/tests/questiontype_test.php | 4 ++-- question/type/ddimageortext/tests/questiontype_test.php | 4 ++-- question/type/ddmarker/tests/questiontype_test.php | 4 ++-- question/type/ddwtos/tests/questiontype_test.php | 4 ++-- question/type/description/tests/questiontype_test.php | 4 ++-- question/type/essay/tests/questiontype_test.php | 4 ++-- question/type/gapselect/tests/questiontype_test.php | 4 ++-- question/type/match/tests/questiontype_test.php | 4 ++-- question/type/multianswer/tests/questiontype_test.php | 4 ++-- question/type/multichoice/tests/questiontype_test.php | 4 ++-- question/type/numerical/tests/questiontype_test.php | 4 ++-- question/type/random/tests/questiontype_test.php | 4 ++-- question/type/shortanswer/tests/questiontype_test.php | 4 ++-- ...estion_first_matching_answer_grading_strategy_test.php | 4 ++-- question/type/truefalse/tests/questiontype_test.php | 4 ++-- rating/tests/externallib_test.php | 2 +- rating/tests/rating_test.php | 2 +- report/completion/tests/events_test.php | 2 +- report/log/tests/events_test.php | 2 +- report/log/tests/lib_test.php | 2 +- report/loglive/tests/events_test.php | 2 +- report/outline/tests/lib_test.php | 2 +- report/questioninstances/tests/events_test.php | 2 +- report/stats/tests/events_test.php | 2 +- report/stats/tests/lib_test.php | 2 +- report/usersessions/tests/lib_test.php | 2 +- repository/flickr/tests/privacy_test.php | 2 +- .../tests/access_controlled_link_manager_test.php | 4 ++-- repository/nextcloud/tests/lib_test.php | 2 +- repository/nextcloud/tests/ocs_test.php | 2 +- repository/onedrive/tests/privacy_test.php | 2 +- repository/recent/tests/lib_test.php | 2 +- repository/tests/privacy_test.php | 2 +- rss/tests/privacy_test.php | 2 +- search/engine/simpledb/tests/engine_test.php | 4 ++-- search/engine/simpledb/tests/privacy_test.php | 4 ++-- search/engine/solr/tests/engine_test.php | 4 ++-- search/tests/base_activity_test.php | 4 ++-- search/tests/base_test.php | 4 ++-- search/tests/document_test.php | 4 ++-- search/tests/engine_test.php | 2 +- search/tests/external_test.php | 2 +- search/tests/generator/lib.php | 4 ++-- search/tests/manager_test.php | 4 ++-- tag/tests/events_test.php | 2 +- tag/tests/taglib_test.php | 2 +- user/profile/field/checkbox/tests/privacy_test.php | 2 +- user/profile/field/datetime/tests/privacy_test.php | 2 +- user/profile/field/menu/tests/privacy_test.php | 2 +- user/profile/field/text/tests/privacy_test.php | 2 +- user/profile/field/textarea/tests/privacy_test.php | 2 +- user/tests/search_test.php | 2 +- webservice/tests/events_test.php | 2 +- webservice/tests/externallib_test.php | 2 +- webservice/tests/lib_test.php | 2 +- webservice/tests/privacy_test.php | 2 +- webservice/xmlrpc/tests/lib_test.php | 2 +- webservice/xmlrpc/tests/locallib_test.php | 2 +- webservice/xmlrpc/tests/xmlrpc_server_test.php | 2 +- 421 files changed, 531 insertions(+), 531 deletions(-) diff --git a/admin/tool/behat/tests/manager_util_test.php b/admin/tool/behat/tests/manager_util_test.php index 98ccd03a85a..71629550155 100644 --- a/admin/tool/behat/tests/manager_util_test.php +++ b/admin/tool/behat/tests/manager_util_test.php @@ -87,7 +87,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { /** * Setup test. */ - public function setup() { + public function setUp(): void { global $CFG; $this->resetAfterTest(); diff --git a/admin/tool/capability/tests/events_test.php b/admin/tool/capability/tests/events_test.php index 30942ca4b3d..1e3e8d5bc26 100644 --- a/admin/tool/capability/tests/events_test.php +++ b/admin/tool/capability/tests/events_test.php @@ -36,7 +36,7 @@ class tool_capability_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/admin/tool/cohortroles/tests/api_test.php b/admin/tool/cohortroles/tests/api_test.php index 2d99e5c37ac..f023b71840b 100644 --- a/admin/tool/cohortroles/tests/api_test.php +++ b/admin/tool/cohortroles/tests/api_test.php @@ -49,7 +49,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase { /** * Setup function- we will create a course and add an assign instance to it. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); // Create some users. diff --git a/admin/tool/cohortroles/tests/privacy_test.php b/admin/tool/cohortroles/tests/privacy_test.php index 6399314cf77..72446a2e834 100644 --- a/admin/tool/cohortroles/tests/privacy_test.php +++ b/admin/tool/cohortroles/tests/privacy_test.php @@ -43,7 +43,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes /** * Overriding setUp() function to always reset after tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/admin/tool/dataprivacy/tests/expired_data_requests_test.php b/admin/tool/dataprivacy/tests/expired_data_requests_test.php index eec0bd5397c..32c4f56afa5 100644 --- a/admin/tool/dataprivacy/tests/expired_data_requests_test.php +++ b/admin/tool/dataprivacy/tests/expired_data_requests_test.php @@ -44,7 +44,7 @@ class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testc /** * Test tearDown. */ - public function tearDown() { + public function tearDown(): void { \core_privacy\local\request\writer::reset(); } diff --git a/admin/tool/dataprivacy/tests/task_test.php b/admin/tool/dataprivacy/tests/task_test.php index 0dc614a43a0..8ab89199632 100644 --- a/admin/tool/dataprivacy/tests/task_test.php +++ b/admin/tool/dataprivacy/tests/task_test.php @@ -39,7 +39,7 @@ class tool_dataprivacy_task_testcase extends data_privacy_testcase { /** * Test tearDown. */ - public function tearDown() { + public function tearDown(): void { \core_privacy\local\request\writer::reset(); } diff --git a/admin/tool/langimport/tests/events_test.php b/admin/tool/langimport/tests/events_test.php index d2164cf443c..0633984a8fb 100644 --- a/admin/tool/langimport/tests/events_test.php +++ b/admin/tool/langimport/tests/events_test.php @@ -36,7 +36,7 @@ class tool_langimport_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/admin/tool/log/store/database/tests/privacy_test.php b/admin/tool/log/store/database/tests/privacy_test.php index 085ce1b27f1..86b8b37790d 100644 --- a/admin/tool/log/store/database/tests/privacy_test.php +++ b/admin/tool/log/store/database/tests/privacy_test.php @@ -50,7 +50,7 @@ require_once(__DIR__ . '/fixtures/event.php'); */ class logstore_database_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $CFG; $this->resetAfterTest(); $this->preventResetByRollback(); // Logging waits till the transaction gets committed. diff --git a/admin/tool/log/store/legacy/tests/privacy_test.php b/admin/tool/log/store/legacy/tests/privacy_test.php index d6d2a6c63d9..ad0e9920eab 100644 --- a/admin/tool/log/store/legacy/tests/privacy_test.php +++ b/admin/tool/log/store/legacy/tests/privacy_test.php @@ -48,7 +48,7 @@ require_once(__DIR__ . '/fixtures/event.php'); */ class logstore_legacy_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/admin/tool/log/store/standard/tests/privacy_test.php b/admin/tool/log/store/standard/tests/privacy_test.php index 1e23599a30c..d324d79b139 100644 --- a/admin/tool/log/store/standard/tests/privacy_test.php +++ b/admin/tool/log/store/standard/tests/privacy_test.php @@ -47,7 +47,7 @@ require_once(__DIR__ . '/fixtures/event.php'); */ class logstore_standard_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->preventResetByRollback(); // Logging waits till the transaction gets committed. } diff --git a/admin/tool/log/store/standard/tests/store_test.php b/admin/tool/log/store/standard/tests/store_test.php index 1492718b0fb..aeb15c6b61e 100644 --- a/admin/tool/log/store/standard/tests/store_test.php +++ b/admin/tool/log/store/standard/tests/store_test.php @@ -540,7 +540,7 @@ class logstore_standard_store_testcase extends advanced_testcase { /** * Reset any garbage collector changes to the previous state at the end of the test. */ - public function tearDown() { + public function tearDown(): void { if ($this->wedisabledgc) { gc_enable(); } diff --git a/admin/tool/log/tests/privacy_test.php b/admin/tool/log/tests/privacy_test.php index ae85b869a65..f69738759b6 100644 --- a/admin/tool/log/tests/privacy_test.php +++ b/admin/tool/log/tests/privacy_test.php @@ -51,7 +51,7 @@ require_once($CFG->dirroot . '/admin/tool/log/store/standard/tests/fixtures/even */ class tool_log_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->preventResetByRollback(); // Logging waits till the transaction gets committed. } diff --git a/admin/tool/lp/tests/externallib_test.php b/admin/tool/lp/tests/externallib_test.php index 8511c842f2b..338bdebdcb6 100644 --- a/admin/tool/lp/tests/externallib_test.php +++ b/admin/tool/lp/tests/externallib_test.php @@ -75,7 +75,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase { /** * Setup function- we will create a course and add an assign instance to it. */ - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/admin/tool/lpmigrate/tests/processor_test.php b/admin/tool/lpmigrate/tests/processor_test.php index c8db5c18ac7..b1336725623 100644 --- a/admin/tool/lpmigrate/tests/processor_test.php +++ b/admin/tool/lpmigrate/tests/processor_test.php @@ -46,7 +46,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase { * Then we create 2 courses, and in each 1 CM. * Then we attach some competencies from the first framework to courses and CM. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); diff --git a/admin/tool/messageinbound/tests/manager_test.php b/admin/tool/messageinbound/tests/manager_test.php index b88a74261bf..0ba834c70dd 100644 --- a/admin/tool/messageinbound/tests/manager_test.php +++ b/admin/tool/messageinbound/tests/manager_test.php @@ -44,7 +44,7 @@ use tool_messageinbound\privacy\provider; */ class tool_messageinbound_manager_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $CFG; $this->resetAfterTest(); diff --git a/admin/tool/messageinbound/tests/privacy_test.php b/admin/tool/messageinbound/tests/privacy_test.php index e98c027a5b9..65d6869af7e 100644 --- a/admin/tool/messageinbound/tests/privacy_test.php +++ b/admin/tool/messageinbound/tests/privacy_test.php @@ -46,7 +46,7 @@ use tool_messageinbound\privacy\provider; */ class tool_messageinbound_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $CFG; $this->resetAfterTest(); diff --git a/admin/tool/mobile/tests/privacy_provider_test.php b/admin/tool/mobile/tests/privacy_provider_test.php index 6e1da9c8e07..c1469f457e3 100644 --- a/admin/tool/mobile/tests/privacy_provider_test.php +++ b/admin/tool/mobile/tests/privacy_provider_test.php @@ -40,7 +40,7 @@ class tool_mobile_privacy_testcase extends \core_privacy\tests\provider_testcase /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/admin/tool/monitor/tests/eventobservers_test.php b/admin/tool/monitor/tests/eventobservers_test.php index f74c10b309c..35a90b44941 100644 --- a/admin/tool/monitor/tests/eventobservers_test.php +++ b/admin/tool/monitor/tests/eventobservers_test.php @@ -38,7 +38,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase { /** * Set up method. */ - public function setUp() { + public function setUp(): void { // Enable monitor. set_config('enablemonitor', 1, 'tool_monitor'); } diff --git a/admin/tool/monitor/tests/events_test.php b/admin/tool/monitor/tests/events_test.php index 4ed829d3f40..109bc7ff92b 100644 --- a/admin/tool/monitor/tests/events_test.php +++ b/admin/tool/monitor/tests/events_test.php @@ -33,7 +33,7 @@ class tool_monitor_events_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { set_config('enablemonitor', 1, 'tool_monitor'); $this->resetAfterTest(); } diff --git a/admin/tool/monitor/tests/generator_test.php b/admin/tool/monitor/tests/generator_test.php index 7c4ae86587d..c2672a8c67f 100644 --- a/admin/tool/monitor/tests/generator_test.php +++ b/admin/tool/monitor/tests/generator_test.php @@ -39,7 +39,7 @@ class tool_monitor_generator_testcase extends advanced_testcase { /** * Set up method. */ - public function setUp() { + public function setUp(): void { // Enable monitor. set_config('enablemonitor', 1, 'tool_monitor'); } @@ -138,4 +138,4 @@ class tool_monitor_generator_testcase extends advanced_testcase { $this->assertEquals(1, $historydata->userid); $this->assertEquals(1, $historydata->sid); } -} \ No newline at end of file +} diff --git a/admin/tool/monitor/tests/privacy_test.php b/admin/tool/monitor/tests/privacy_test.php index 3d419c7e4d5..871b11d5130 100644 --- a/admin/tool/monitor/tests/privacy_test.php +++ b/admin/tool/monitor/tests/privacy_test.php @@ -43,7 +43,7 @@ class tool_monitor_privacy_testcase extends provider_testcase { /** * Set up method. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // Enable monitor. set_config('enablemonitor', 1, 'tool_monitor'); diff --git a/admin/tool/monitor/tests/rule_manager_test.php b/admin/tool/monitor/tests/rule_manager_test.php index a5173faad34..fd334e61e50 100644 --- a/admin/tool/monitor/tests/rule_manager_test.php +++ b/admin/tool/monitor/tests/rule_manager_test.php @@ -37,7 +37,7 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase { /** * Set up method. */ - public function setUp() { + public function setUp(): void { // Enable monitor. set_config('enablemonitor', 1, 'tool_monitor'); } @@ -192,4 +192,4 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase { $this->assertEmpty(array_diff(array_keys($ruledata), $ruleids)); $this->assertCount(10, $ruledata); } -} \ No newline at end of file +} diff --git a/admin/tool/monitor/tests/subscription_test.php b/admin/tool/monitor/tests/subscription_test.php index b3511b5e846..cb18815ad12 100644 --- a/admin/tool/monitor/tests/subscription_test.php +++ b/admin/tool/monitor/tests/subscription_test.php @@ -34,7 +34,7 @@ class tool_monitor_subscription_testcase extends advanced_testcase { /** * Test set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); // Create the mock subscription. diff --git a/admin/tool/monitor/tests/task_check_subscriptions_test.php b/admin/tool/monitor/tests/task_check_subscriptions_test.php index b52678436e6..10a5e98efa9 100644 --- a/admin/tool/monitor/tests/task_check_subscriptions_test.php +++ b/admin/tool/monitor/tests/task_check_subscriptions_test.php @@ -36,7 +36,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase { /** * Test set up. */ - public function setUp() { + public function setUp(): void { global $DB; set_config('enablemonitor', 1, 'tool_monitor'); $this->resetAfterTest(true); diff --git a/admin/tool/monitor/tests/task_clean_events_test.php b/admin/tool/monitor/tests/task_clean_events_test.php index 9de32269c36..5f0a13ca58f 100644 --- a/admin/tool/monitor/tests/task_clean_events_test.php +++ b/admin/tool/monitor/tests/task_clean_events_test.php @@ -35,7 +35,7 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase { /** * Test set up. */ - public function setUp() { + public function setUp(): void { set_config('enablemonitor', 1, 'tool_monitor'); $this->resetAfterTest(true); } diff --git a/admin/tool/policy/tests/externallib_test.php b/admin/tool/policy/tests/externallib_test.php index 8abff00e520..bec7faab688 100644 --- a/admin/tool/policy/tests/externallib_test.php +++ b/admin/tool/policy/tests/externallib_test.php @@ -46,7 +46,7 @@ class tool_policy_external_testcase extends externallib_advanced_testcase { /** * Setup function- we will create some policy docs. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/admin/tool/policy/tests/privacy_provider_test.php b/admin/tool/policy/tests/privacy_provider_test.php index c771cde1bdd..6fa4a0d6c11 100644 --- a/admin/tool/policy/tests/privacy_provider_test.php +++ b/admin/tool/policy/tests/privacy_provider_test.php @@ -51,7 +51,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider /** * Setup function. Will create a user. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); diff --git a/admin/tool/recyclebin/tests/category_bin_test.php b/admin/tool/recyclebin/tests/category_bin_test.php index 0e24c311ca1..199fca063c2 100644 --- a/admin/tool/recyclebin/tests/category_bin_test.php +++ b/admin/tool/recyclebin/tests/category_bin_test.php @@ -46,7 +46,7 @@ class tool_recyclebin_category_bin_tests extends advanced_testcase { /** * Setup for each test. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/recyclebin/tests/course_bin_test.php b/admin/tool/recyclebin/tests/course_bin_test.php index 44f9db6cc06..87c4e86db76 100644 --- a/admin/tool/recyclebin/tests/course_bin_test.php +++ b/admin/tool/recyclebin/tests/course_bin_test.php @@ -46,7 +46,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase { /** * Setup for each test. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/admin/tool/recyclebin/tests/events_test.php b/admin/tool/recyclebin/tests/events_test.php index c3ea0e68477..c7be87b264f 100644 --- a/admin/tool/recyclebin/tests/events_test.php +++ b/admin/tool/recyclebin/tests/events_test.php @@ -40,7 +40,7 @@ class tool_recyclebin_events_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // We want the category and course bin to be enabled. diff --git a/admin/tool/usertours/tests/accessdate_filter_test.php b/admin/tool/usertours/tests/accessdate_filter_test.php index 642ee0c775a..b60247feacf 100644 --- a/admin/tool/usertours/tests/accessdate_filter_test.php +++ b/admin/tool/usertours/tests/accessdate_filter_test.php @@ -36,7 +36,7 @@ use tool_usertours\local\filter\accessdate; */ class tool_usertours_accessdate_filter_test extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/admin/tool/usertours/tests/manager_test.php b/admin/tool/usertours/tests/manager_test.php index d5e4893ccf5..0deff0da644 100644 --- a/admin/tool/usertours/tests/manager_test.php +++ b/admin/tool/usertours/tests/manager_test.php @@ -47,7 +47,7 @@ class tool_usertours_manager_testcase extends advanced_testcase { /** * Setup to store the DB reference. */ - public function setUp() { + public function setUp(): void { global $DB; $this->db = $DB; @@ -56,7 +56,7 @@ class tool_usertours_manager_testcase extends advanced_testcase { /** * Tear down to restore the original DB reference. */ - public function tearDown() { + public function tearDown(): void { global $DB; $DB = $this->db; diff --git a/admin/tool/usertours/tests/role_filter_test.php b/admin/tool/usertours/tests/role_filter_test.php index 940e517fc3e..8fe97394343 100644 --- a/admin/tool/usertours/tests/role_filter_test.php +++ b/admin/tool/usertours/tests/role_filter_test.php @@ -58,7 +58,7 @@ class tool_usertours_role_filter_testcase extends advanced_testcase { */ protected $roles; - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(true); diff --git a/admin/tool/usertours/tests/step_test.php b/admin/tool/usertours/tests/step_test.php index 005272ee081..fb6a3c1d85f 100644 --- a/admin/tool/usertours/tests/step_test.php +++ b/admin/tool/usertours/tests/step_test.php @@ -44,7 +44,7 @@ class step_testcase extends advanced_testcase { /** * Setup to store the DB reference. */ - public function setUp() { + public function setUp(): void { global $DB; $this->db = $DB; @@ -53,7 +53,7 @@ class step_testcase extends advanced_testcase { /** * Tear down to restore the original DB reference. */ - public function tearDown() { + public function tearDown(): void { global $DB; $DB = $this->db; diff --git a/admin/tool/usertours/tests/tour_test.php b/admin/tool/usertours/tests/tour_test.php index c5bf23f012a..d1014f7d847 100644 --- a/admin/tool/usertours/tests/tour_test.php +++ b/admin/tool/usertours/tests/tour_test.php @@ -46,7 +46,7 @@ class tour_testcase extends advanced_testcase { /** * Setup to store the DB reference. */ - public function setUp() { + public function setUp(): void { global $DB; $this->db = $DB; @@ -55,7 +55,7 @@ class tour_testcase extends advanced_testcase { /** * Tear down to restore the original DB reference. */ - public function tearDown() { + public function tearDown(): void { global $DB; $DB = $this->db; diff --git a/analytics/tests/course_test.php b/analytics/tests/course_test.php index 00cfea33691..13010f96645 100644 --- a/analytics/tests/course_test.php +++ b/analytics/tests/course_test.php @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); */ class core_analytics_course_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { global $DB; $this->course = $this->getDataGenerator()->create_course(['startdate' => 0]); diff --git a/analytics/tests/dataset_manager_test.php b/analytics/tests/dataset_manager_test.php index f5c916c9ea3..fb600c8fb9a 100644 --- a/analytics/tests/dataset_manager_test.php +++ b/analytics/tests/dataset_manager_test.php @@ -38,7 +38,7 @@ class dataset_manager_testcase extends advanced_testcase { * * @return null */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); $this->sharedtoprows = array( diff --git a/analytics/tests/model_test.php b/analytics/tests/model_test.php index 9d5bdd2b1e9..a1004fb563f 100644 --- a/analytics/tests/model_test.php +++ b/analytics/tests/model_test.php @@ -41,7 +41,7 @@ require_once(__DIR__ . '/fixtures/test_analysis.php'); */ class analytics_model_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->setAdminUser(); diff --git a/analytics/tests/prediction_actions_test.php b/analytics/tests/prediction_actions_test.php index f3768788e0f..f8f2866dcb8 100644 --- a/analytics/tests/prediction_actions_test.php +++ b/analytics/tests/prediction_actions_test.php @@ -39,7 +39,7 @@ class analytics_prediction_actions_testcase extends advanced_testcase { /** * Common startup tasks */ - public function setUp() { + public function setUp(): void { global $DB; $this->setAdminUser(); diff --git a/analytics/tests/prediction_test.php b/analytics/tests/prediction_test.php index 1fd9ac2a724..159bfd83466 100644 --- a/analytics/tests/prediction_test.php +++ b/analytics/tests/prediction_test.php @@ -62,7 +62,7 @@ class core_analytics_prediction_testcase extends advanced_testcase { * * @return null */ - public function tearDown() { + public function tearDown(): void { $this->setAdminUser(); $models = \core_analytics\manager::get_all_models(); diff --git a/analytics/tests/privacy_test.php b/analytics/tests/privacy_test.php index 21fdd289757..d0fa280cda1 100644 --- a/analytics/tests/privacy_test.php +++ b/analytics/tests/privacy_test.php @@ -44,7 +44,7 @@ require_once(__DIR__ . '/fixtures/test_target_course_users.php'); */ class core_analytics_privacy_model_testcase extends \core_privacy\tests\provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/analytics/tests/stats_test.php b/analytics/tests/stats_test.php index 5054a3fb040..5d3cb030251 100644 --- a/analytics/tests/stats_test.php +++ b/analytics/tests/stats_test.php @@ -39,7 +39,7 @@ class analytics_stats_testcase extends advanced_testcase { /** * Set up the test environment. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); } diff --git a/auth/email/tests/external_test.php b/auth/email/tests/external_test.php index f62f95c1102..ed1900a6dfd 100644 --- a/auth/email/tests/external_test.php +++ b/auth/email/tests/external_test.php @@ -43,7 +43,7 @@ class auth_email_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $CFG, $DB; $this->resetAfterTest(true); diff --git a/auth/manual/tests/manual_test.php b/auth/manual/tests/manual_test.php index 156a997fe94..7857e34b17b 100644 --- a/auth/manual/tests/manual_test.php +++ b/auth/manual/tests/manual_test.php @@ -44,7 +44,7 @@ class auth_manual_testcase extends advanced_testcase { /** * Setup test data. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); $this->authplugin = new auth_plugin_manual(); set_config('expiration', '1', 'auth_manual'); diff --git a/auth/manual/tests/privacy_provider_test.php b/auth/manual/tests/privacy_provider_test.php index 55722915e47..af741c3ee65 100644 --- a/auth/manual/tests/privacy_provider_test.php +++ b/auth/manual/tests/privacy_provider_test.php @@ -45,7 +45,7 @@ class auth_manual_privacy_testcase extends \core_privacy\tests\provider_testcase /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); $this->authplugin = new auth_plugin_manual(); } diff --git a/auth/mnet/tests/privacy_provider_test.php b/auth/mnet/tests/privacy_provider_test.php index 7ecf9e6d8ad..b41db22fff8 100644 --- a/auth/mnet/tests/privacy_provider_test.php +++ b/auth/mnet/tests/privacy_provider_test.php @@ -43,7 +43,7 @@ class auth_mnet_privacy_testcase extends provider_testcase { /** * Set up method. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } diff --git a/auth/oauth2/tests/privacy_provider_test.php b/auth/oauth2/tests/privacy_provider_test.php index d582d0a4dce..1e190cf3e0f 100644 --- a/auth/oauth2/tests/privacy_provider_test.php +++ b/auth/oauth2/tests/privacy_provider_test.php @@ -42,7 +42,7 @@ class auth_oauth2_privacy_testcase extends provider_testcase { /** * Set up method. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } diff --git a/auth/tests/external_test.php b/auth/tests/external_test.php index 237852ce6e5..f3f53d5feb6 100644 --- a/auth/tests/external_test.php +++ b/auth/tests/external_test.php @@ -46,7 +46,7 @@ class core_auth_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $CFG; $this->resetAfterTest(true); @@ -60,7 +60,7 @@ class core_auth_external_testcase extends externallib_advanced_testcase { /** * Tear down to restore old logging.. */ - protected function tearDown() { + protected function tearDown(): void { ini_set('error_log', $this->oldlog); parent::tearDown(); } diff --git a/auth/tests/privacy_test.php b/auth/tests/privacy_test.php index 16701f26f80..d3586d3f1bc 100644 --- a/auth/tests/privacy_test.php +++ b/auth/tests/privacy_test.php @@ -43,7 +43,7 @@ use core_auth\privacy\provider; */ class core_auth_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/availability/condition/completion/tests/condition_test.php b/availability/condition/completion/tests/condition_test.php index b1a004093c6..02d8476b775 100644 --- a/availability/condition/completion/tests/condition_test.php +++ b/availability/condition/completion/tests/condition_test.php @@ -52,7 +52,7 @@ class availability_completion_condition_testcase extends advanced_testcase { /** * Load required classes. */ - public function setUp() { + public function setUp(): void { availability_completion\condition::wipe_static_cache(); } diff --git a/availability/condition/date/tests/condition_test.php b/availability/condition/date/tests/condition_test.php index 7b62904e210..ae2b2a7c244 100644 --- a/availability/condition/date/tests/condition_test.php +++ b/availability/condition/date/tests/condition_test.php @@ -38,7 +38,7 @@ class availability_date_condition_testcase extends advanced_testcase { /** * Load required classes. */ - public function setUp() { + public function setUp(): void { // Load the mock info class so that it can be used. global $CFG; require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php'); diff --git a/availability/condition/group/tests/condition_test.php b/availability/condition/group/tests/condition_test.php index 1c94323a7c3..2f7d6184749 100644 --- a/availability/condition/group/tests/condition_test.php +++ b/availability/condition/group/tests/condition_test.php @@ -37,7 +37,7 @@ class availability_group_condition_testcase extends advanced_testcase { /** * Load required classes. */ - public function setUp() { + public function setUp(): void { // Load the mock info class so that it can be used. global $CFG; require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php'); diff --git a/availability/condition/grouping/tests/condition_test.php b/availability/condition/grouping/tests/condition_test.php index 94cd4ec3301..5f5f7769dce 100644 --- a/availability/condition/grouping/tests/condition_test.php +++ b/availability/condition/grouping/tests/condition_test.php @@ -37,7 +37,7 @@ class availability_grouping_condition_testcase extends advanced_testcase { /** * Load required classes. */ - public function setUp() { + public function setUp(): void { // Load the mock info class so that it can be used. global $CFG; require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php'); diff --git a/availability/condition/profile/tests/condition_test.php b/availability/condition/profile/tests/condition_test.php index e2250e22d06..c6dc98dda3a 100644 --- a/availability/condition/profile/tests/condition_test.php +++ b/availability/condition/profile/tests/condition_test.php @@ -45,7 +45,7 @@ class availability_profile_condition_testcase extends advanced_testcase { /** @var \core_availability\info Current info */ private $info; - public function setUp() { + public function setUp(): void { global $DB, $CFG; $this->resetAfterTest(); diff --git a/availability/tests/info_test.php b/availability/tests/info_test.php index e8044df1380..befd3fff4c0 100644 --- a/availability/tests/info_test.php +++ b/availability/tests/info_test.php @@ -36,7 +36,7 @@ use core_availability\info_section; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class info_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { // Load the mock condition so that it can be used. require_once(__DIR__ . '/fixtures/mock_condition.php'); } diff --git a/availability/tests/tree_test.php b/availability/tests/tree_test.php index 1b131a9a96e..2760c5896d6 100644 --- a/availability/tests/tree_test.php +++ b/availability/tests/tree_test.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tree_testcase extends \advanced_testcase { - public function setUp() { + public function setUp(): void { // Load the mock classes so they can be used. require_once(__DIR__ . '/fixtures/mock_condition.php'); require_once(__DIR__ . '/fixtures/mock_info.php'); diff --git a/backup/controller/tests/controller_test.php b/backup/controller/tests/controller_test.php index f638be031aa..5c93fb60e21 100644 --- a/backup/controller/tests/controller_test.php +++ b/backup/controller/tests/controller_test.php @@ -38,7 +38,7 @@ class core_backup_controller_testcase extends advanced_testcase { protected $courseid; // course id used for testing protected $userid; // user used if for testing - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/backup/converter/moodle1/tests/moodle1_converter_test.php b/backup/converter/moodle1/tests/moodle1_converter_test.php index 68589da2692..7065286efdb 100644 --- a/backup/converter/moodle1/tests/moodle1_converter_test.php +++ b/backup/converter/moodle1/tests/moodle1_converter_test.php @@ -41,7 +41,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { /** @var string saved hash of an icon file used during testing */ protected $iconhash; - protected function setUp() { + protected function setUp(): void { global $CFG; $this->tempdir = convert_helper::generate_id('unittest'); @@ -75,7 +75,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { ); } - protected function tearDown() { + protected function tearDown(): void { global $CFG; if (empty($CFG->keeptempdirectoriesonbackup)) { fulldelete($this->tempdirpath); diff --git a/backup/moodle2/tests/backup_encrypted_content_test.php b/backup/moodle2/tests/backup_encrypted_content_test.php index 5a609c85d03..d8397e06a35 100644 --- a/backup/moodle2/tests/backup_encrypted_content_test.php +++ b/backup/moodle2/tests/backup_encrypted_content_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_custom_fields.php'); class core_backup_encrypted_content_testscase extends advanced_testcase { - public function setUp() { + public function setUp(): void { if (!function_exists('openssl_encrypt')) { $this->markTestSkipped('OpenSSL extension is not loaded.'); diff --git a/backup/moodle2/tests/backup_xml_transformer_test.php b/backup/moodle2/tests/backup_xml_transformer_test.php index 554aa0be8fb..658f6c1bd4d 100644 --- a/backup/moodle2/tests/backup_xml_transformer_test.php +++ b/backup/moodle2/tests/backup_xml_transformer_test.php @@ -42,7 +42,7 @@ class backup_xml_transformer_testcase extends advanced_testcase { /** * Initial set up. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(true); diff --git a/backup/tests/automated_backup_test.php b/backup/tests/automated_backup_test.php index 9ac514f97dc..c76d9529f3d 100644 --- a/backup/tests/automated_backup_test.php +++ b/backup/tests/automated_backup_test.php @@ -46,7 +46,7 @@ class core_backup_automated_backup_testcase extends advanced_testcase { */ protected $course; - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/backup/tests/course_copy_test.php b/backup/tests/course_copy_test.php index 906dbfe51c4..40f216853e9 100644 --- a/backup/tests/course_copy_test.php +++ b/backup/tests/course_copy_test.php @@ -66,7 +66,7 @@ class core_backup_course_copy_testcase extends advanced_testcase { /** * Set up tasks for all tests. */ - protected function setUp() { + protected function setUp(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -633,4 +633,4 @@ class core_backup_course_copy_testcase extends advanced_testcase { $this->expectException(\moodle_exception::class); new \core_backup\copy\copy($formdata); } -} \ No newline at end of file +} diff --git a/backup/tests/externallib_test.php b/backup/tests/externallib_test.php index 8cb6e4d3a6a..df2b1539c4e 100644 --- a/backup/tests/externallib_test.php +++ b/backup/tests/externallib_test.php @@ -44,7 +44,7 @@ class backup_external_testcase extends externallib_advanced_testcase { /** * Set up tasks for all tests. */ - protected function setUp() { + protected function setUp(): void { global $CFG; $this->resetAfterTest(true); @@ -179,4 +179,4 @@ class backup_external_testcase extends externallib_advanced_testcase { $this->assertEquals(0, $restorerec->progress); $this->assertEquals('restore', $restorerec->operation); } -} \ No newline at end of file +} diff --git a/backup/util/checks/tests/checks_test.php b/backup/util/checks/tests/checks_test.php index 8e4ced3e7e3..3b8904358a1 100644 --- a/backup/util/checks/tests/checks_test.php +++ b/backup/util/checks/tests/checks_test.php @@ -39,7 +39,7 @@ class backup_check_testcase extends advanced_testcase { protected $courseid; // course id used for testing protected $userid; // user record id - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/backup/util/dbops/tests/backup_dbops_test.php b/backup/util/dbops/tests/backup_dbops_test.php index 219b5304653..7a18eb0fae4 100644 --- a/backup/util/dbops/tests/backup_dbops_test.php +++ b/backup/util/dbops/tests/backup_dbops_test.php @@ -37,7 +37,7 @@ class backup_dbops_testcase extends advanced_testcase { protected $courseid; // course id used for testing protected $userid; // user record used for testing - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/backup/util/factories/tests/factories_test.php b/backup/util/factories/tests/factories_test.php index 2a3fa1a55eb..7cebfc56c56 100644 --- a/backup/util/factories/tests/factories_test.php +++ b/backup/util/factories/tests/factories_test.php @@ -40,7 +40,7 @@ require_once($CFG->dirroot . '/backup/util/factories/backup_factory.class.php'); */ class backup_factories_testcase extends advanced_testcase { - function setUp() { + public function setUp(): void { global $CFG; parent::setUp(); @@ -57,7 +57,7 @@ class backup_factories_testcase extends advanced_testcase { /** * test get_logger_chain() method */ - function test_backup_factory() { + public function test_backup_factory() { global $CFG; // Default instantiate, all levels = backup::LOG_NONE diff --git a/backup/util/helper/tests/restore_structure_parser_processor_test.php b/backup/util/helper/tests/restore_structure_parser_processor_test.php index ea5ab2cc0e2..a5239a10c3e 100644 --- a/backup/util/helper/tests/restore_structure_parser_processor_test.php +++ b/backup/util/helper/tests/restore_structure_parser_processor_test.php @@ -42,7 +42,7 @@ class restore_structure_parser_processor_test extends advanced_testcase { /** * Initial set up. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(true); diff --git a/backup/util/plan/tests/plan_test.php b/backup/util/plan/tests/plan_test.php index 3e9b2feb1f7..a02573689b7 100644 --- a/backup/util/plan/tests/plan_test.php +++ b/backup/util/plan/tests/plan_test.php @@ -36,7 +36,7 @@ class backup_plan_testcase extends advanced_testcase { protected $courseid; // course id used for testing protected $userid; // user record used for testing - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/backup/util/plan/tests/step_test.php b/backup/util/plan/tests/step_test.php index 8b9f6e17997..78d1a0c1804 100644 --- a/backup/util/plan/tests/step_test.php +++ b/backup/util/plan/tests/step_test.php @@ -36,7 +36,7 @@ class backup_step_testcase extends advanced_testcase { protected $courseid; // course id used for testing protected $userid; // user record used for testing - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/backup/util/plan/tests/task_test.php b/backup/util/plan/tests/task_test.php index 40ee6ead97c..3cb0bef732f 100644 --- a/backup/util/plan/tests/task_test.php +++ b/backup/util/plan/tests/task_test.php @@ -36,7 +36,7 @@ class backup_task_testcase extends advanced_testcase { protected $courseid; // course id used for testing protected $userid; // user record used for testing - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/backup/util/structure/tests/structure_test.php b/backup/util/structure/tests/structure_test.php index 93a51a7c627..3b9b807bcea 100644 --- a/backup/util/structure/tests/structure_test.php +++ b/backup/util/structure/tests/structure_test.php @@ -53,7 +53,7 @@ class backup_structure_testcase extends advanced_testcase { protected $contextid; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); diff --git a/badges/tests/badgeslib_test.php b/badges/tests/badgeslib_test.php index c4ec0e1acf6..0dac8de0348 100644 --- a/badges/tests/badgeslib_test.php +++ b/badges/tests/badgeslib_test.php @@ -43,7 +43,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase { /** @var $assertion2 to define json format for Open badge version 2 */ protected $assertion2; - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; $this->resetAfterTest(true); $CFG->enablecompletion = true; diff --git a/badges/tests/external_test.php b/badges/tests/external_test.php index 0be15261f09..7b36cae7a57 100644 --- a/badges/tests/external_test.php +++ b/badges/tests/external_test.php @@ -45,7 +45,7 @@ class core_badges_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/badges/tests/privacy_test.php b/badges/tests/privacy_test.php index 8067b4ef1a5..12b8638c5ee 100644 --- a/badges/tests/privacy_test.php +++ b/badges/tests/privacy_test.php @@ -48,7 +48,7 @@ require_once($CFG->libdir . '/badgeslib.php'); */ class core_badges_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/blocks/comments/tests/events_test.php b/blocks/comments/tests/events_test.php index 1e7aae4b731..55db08c694f 100644 --- a/blocks/comments/tests/events_test.php +++ b/blocks/comments/tests/events_test.php @@ -43,7 +43,7 @@ class block_comments_events_testcase extends advanced_testcase { /** * Setup test data. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/blocks/comments/tests/privacy_provider_test.php b/blocks/comments/tests/privacy_provider_test.php index 363245d999b..1962cc13d6d 100644 --- a/blocks/comments/tests/privacy_provider_test.php +++ b/blocks/comments/tests/privacy_provider_test.php @@ -51,7 +51,7 @@ class block_comments_privacy_provider_testcase extends \core_privacy\tests\provi /** @var stdClass A test course. */ protected $course2; - protected function setUp() { + protected function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/blocks/online_users/tests/online_users_test.php b/blocks/online_users/tests/online_users_test.php index da436ac5a4a..9f56f5fc81d 100644 --- a/blocks/online_users/tests/online_users_test.php +++ b/blocks/online_users/tests/online_users_test.php @@ -47,7 +47,7 @@ class block_online_users_testcase extends advanced_testcase { * Prepare the site with some courses, groups, users and * simulate various recent accesses. */ - protected function setUp() { + protected function setUp(): void { // Generate (simulated) recently logged-in users. $generator = $this->getDataGenerator()->get_plugin_generator('block_online_users'); diff --git a/blocks/recentlyaccesseditems/tests/observer_test.php b/blocks/recentlyaccesseditems/tests/observer_test.php index fcc0eb25c56..6600709b20c 100644 --- a/blocks/recentlyaccesseditems/tests/observer_test.php +++ b/blocks/recentlyaccesseditems/tests/observer_test.php @@ -42,7 +42,7 @@ class block_recentlyaccesseditems_observer_testcase extends advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); @@ -157,4 +157,4 @@ class block_recentlyaccesseditems_observer_testcase extends advanced_testcase { $records = $DB->count_records($this->table, array('cmid' => $this->chat->cmid)); $this->assertEquals(2, $records); } -} \ No newline at end of file +} diff --git a/blocks/rss_client/tests/privacy_test.php b/blocks/rss_client/tests/privacy_test.php index 68035eface7..b3e9c1b739f 100644 --- a/blocks/rss_client/tests/privacy_test.php +++ b/blocks/rss_client/tests/privacy_test.php @@ -38,7 +38,7 @@ class block_rss_client_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/blocks/tests/privacy_test.php b/blocks/tests/privacy_test.php index 20df9d9fecb..4695a70d17c 100644 --- a/blocks/tests/privacy_test.php +++ b/blocks/tests/privacy_test.php @@ -44,7 +44,7 @@ use core_block\privacy\provider; */ class core_block_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/blog/tests/events_test.php b/blog/tests/events_test.php index 87f265dfeb3..e6105c8e3eb 100644 --- a/blog/tests/events_test.php +++ b/blog/tests/events_test.php @@ -58,7 +58,7 @@ class core_blog_events_testcase extends advanced_testcase { /** * Setup the tests. */ - protected function setUp() { + protected function setUp(): void { global $DB; parent::setUp(); diff --git a/blog/tests/external_test.php b/blog/tests/external_test.php index 5e23d5f827c..7887a693954 100644 --- a/blog/tests/external_test.php +++ b/blog/tests/external_test.php @@ -44,7 +44,7 @@ class core_blog_external_testcase extends advanced_testcase { private $tagid; private $postid; - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/blog/tests/lib_test.php b/blog/tests/lib_test.php index a690e6346a3..f1ad9219186 100644 --- a/blog/tests/lib_test.php +++ b/blog/tests/lib_test.php @@ -41,7 +41,7 @@ class core_blog_lib_testcase extends advanced_testcase { private $tagid; private $postid; - protected function setUp() { + protected function setUp(): void { global $DB; parent::setUp(); diff --git a/blog/tests/privacy_test.php b/blog/tests/privacy_test.php index 700255291da..67de624c045 100644 --- a/blog/tests/privacy_test.php +++ b/blog/tests/privacy_test.php @@ -47,7 +47,7 @@ require_once($CFG->dirroot . '/comment/lib.php'); */ class core_blog_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/cache/stores/apcu/tests/apcu_test.php b/cache/stores/apcu/tests/apcu_test.php index 4903d3bbb3d..108015b68e9 100644 --- a/cache/stores/apcu/tests/apcu_test.php +++ b/cache/stores/apcu/tests/apcu_test.php @@ -45,11 +45,11 @@ class cachestore_apcu_test extends cachestore_tests { return 'cachestore_apcu'; } - public function setUp() { + public function setUp(): void { if (!cachestore_apcu::are_requirements_met()) { $this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.'); } - return parent::setUp(); + parent::setUp(); } /** @@ -88,4 +88,4 @@ class cachestore_apcu_test extends cachestore_tests { $instance2->purge(); $this->assertSame(1, $instance->get('test1')); } -} \ No newline at end of file +} diff --git a/cache/stores/redis/tests/compressor_test.php b/cache/stores/redis/tests/compressor_test.php index 7f8876e301e..b7178b3c336 100644 --- a/cache/stores/redis/tests/compressor_test.php +++ b/cache/stores/redis/tests/compressor_test.php @@ -45,7 +45,7 @@ class cachestore_redis_compressor_test extends advanced_testcase { /** * Test set up */ - public function setUp() { + public function setUp(): void { if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) { $this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.'); } diff --git a/cache/stores/redis/tests/redis_test.php b/cache/stores/redis/tests/redis_test.php index 1fa3861b5c7..a4bd9f79425 100644 --- a/cache/stores/redis/tests/redis_test.php +++ b/cache/stores/redis/tests/redis_test.php @@ -54,13 +54,13 @@ class cachestore_redis_test extends cachestore_tests { return 'cachestore_redis'; } - public function setUp() { + public function setUp(): void { if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) { $this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.'); } parent::setUp(); } - protected function tearDown() { + protected function tearDown(): void { parent::tearDown(); if ($this->store instanceof cachestore_redis) { @@ -123,4 +123,4 @@ class cachestore_redis_test extends cachestore_tests { $this->assertFalse($store->release_lock('lock', '321')); $this->assertTrue($store->release_lock('lock', '123')); } -} \ No newline at end of file +} diff --git a/cache/tests/administration_helper_test.php b/cache/tests/administration_helper_test.php index 146efe34abc..b392114fb51 100644 --- a/cache/tests/administration_helper_test.php +++ b/cache/tests/administration_helper_test.php @@ -45,7 +45,7 @@ class core_cache_administration_helper_testcase extends advanced_testcase { /** * Set things back to the default before each test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); cache_factory::reset(); cache_config_testing::create_default_configuration(); @@ -54,7 +54,7 @@ class core_cache_administration_helper_testcase extends advanced_testcase { /** * Final task is to reset the cache system */ - public static function tearDownAfterClass() { + public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); cache_factory::reset(); } diff --git a/cache/tests/cache_test.php b/cache/tests/cache_test.php index faafe51449d..ffbb1dfd53e 100644 --- a/cache/tests/cache_test.php +++ b/cache/tests/cache_test.php @@ -44,7 +44,7 @@ class core_cache_testcase extends advanced_testcase { /** * Set things back to the default before each test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); cache_factory::reset(); cache_config_testing::create_default_configuration(); @@ -53,7 +53,7 @@ class core_cache_testcase extends advanced_testcase { /** * Final task is to reset the cache system */ - public static function tearDownAfterClass() { + public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); cache_factory::reset(); } diff --git a/cache/tests/config_writer_test.php b/cache/tests/config_writer_test.php index 12b6291ed75..8fa28d737c7 100644 --- a/cache/tests/config_writer_test.php +++ b/cache/tests/config_writer_test.php @@ -44,7 +44,7 @@ class core_cache_config_writer_testcase extends advanced_testcase { /** * Set things back to the default before each test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); cache_factory::reset(); cache_config_testing::create_default_configuration(); @@ -53,7 +53,7 @@ class core_cache_config_writer_testcase extends advanced_testcase { /** * Final task is to reset the cache system */ - public static function tearDownAfterClass() { + public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); cache_factory::reset(); } diff --git a/cache/tests/fixtures/stores.php b/cache/tests/fixtures/stores.php index 0eee86e377f..b266f4e1d69 100644 --- a/cache/tests/fixtures/stores.php +++ b/cache/tests/fixtures/stores.php @@ -46,7 +46,7 @@ abstract class cachestore_tests extends advanced_testcase { * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ - public function setUp() { + public function setUp(): void { $class = $this->get_class_name(); if (!class_exists($class) || !$class::are_requirements_met()) { $this->markTestSkipped('Could not test '.$class.'. Requirements are not met.'); @@ -190,4 +190,4 @@ abstract class cachestore_tests extends advanced_testcase { $this->assertSame(3, $instance->delete_many(array('many2', 'many3', 'many4'))); $this->assertSame(2, $instance->delete_many(array('many1', 'many5', 'many6'))); } -} \ No newline at end of file +} diff --git a/calendar/tests/calendartype_test.php b/calendar/tests/calendartype_test.php index 859acc6f197..487010b2869 100644 --- a/calendar/tests/calendartype_test.php +++ b/calendar/tests/calendartype_test.php @@ -58,7 +58,7 @@ class core_calendar_type_testcase extends advanced_testcase { /** * Test set up. */ - protected function setUp() { + protected function setUp(): void { // The user we are going to test this on. $this->user = self::getDataGenerator()->create_user(); self::setUser($this->user); diff --git a/calendar/tests/container_test.php b/calendar/tests/container_test.php index bc72391ce38..7e00429f270 100644 --- a/calendar/tests/container_test.php +++ b/calendar/tests/container_test.php @@ -47,7 +47,7 @@ class core_calendar_container_testcase extends advanced_testcase { /** * Test setup. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } diff --git a/calendar/tests/events_related_objects_cache_test.php b/calendar/tests/events_related_objects_cache_test.php index f0799db5347..0238db8047e 100644 --- a/calendar/tests/events_related_objects_cache_test.php +++ b/calendar/tests/events_related_objects_cache_test.php @@ -41,7 +41,7 @@ class core_calendar_events_related_objects_cache_testcase extends advanced_testc /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); } diff --git a/calendar/tests/events_test.php b/calendar/tests/events_test.php index 76f8374effc..fdb852ce80a 100644 --- a/calendar/tests/events_test.php +++ b/calendar/tests/events_test.php @@ -48,7 +48,7 @@ class core_calendar_events_testcase extends advanced_testcase { /** * Test set up. */ - protected function setUp() { + protected function setUp(): void { global $USER; // The user we are going to test this on. $this->setAdminUser(); diff --git a/calendar/tests/externallib_test.php b/calendar/tests/externallib_test.php index 1d41b310bcb..d39596d9e83 100644 --- a/calendar/tests/externallib_test.php +++ b/calendar/tests/externallib_test.php @@ -43,7 +43,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/calendar/externallib.php'); } diff --git a/calendar/tests/lib_test.php b/calendar/tests/lib_test.php index 4467337ce95..d39012581cf 100644 --- a/calendar/tests/lib_test.php +++ b/calendar/tests/lib_test.php @@ -38,7 +38,7 @@ class core_calendar_lib_testcase extends advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); } diff --git a/calendar/tests/local_api_test.php b/calendar/tests/local_api_test.php index 70f56d97666..987de7b3915 100644 --- a/calendar/tests/local_api_test.php +++ b/calendar/tests/local_api_test.php @@ -40,7 +40,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); } diff --git a/calendar/tests/privacy_test.php b/calendar/tests/privacy_test.php index 2b7157d5dc2..d2173b79a80 100644 --- a/calendar/tests/privacy_test.php +++ b/calendar/tests/privacy_test.php @@ -47,7 +47,7 @@ class core_calendar_privacy_testcase extends provider_testcase { /** * Overriding setUp() function to always reset after tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/calendar/tests/rrule_manager_test.php b/calendar/tests/rrule_manager_test.php index a6e2531e658..3af4655cb8c 100644 --- a/calendar/tests/rrule_manager_test.php +++ b/calendar/tests/rrule_manager_test.php @@ -46,7 +46,7 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase { /** * Set up method. */ - protected function setUp() { + protected function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/calendar/tests/std_proxy_test.php b/calendar/tests/std_proxy_test.php index dc9f25e3efb..5d175ac5e95 100644 --- a/calendar/tests/std_proxy_test.php +++ b/calendar/tests/std_proxy_test.php @@ -38,7 +38,7 @@ class core_calendar_std_proxy_testcase extends advanced_testcase { */ public $objects; - public function setUp() { + public function setUp(): void { $this->objects = [ 1 => (object) [ 'member1' => 'Hello', diff --git a/cohort/tests/privacy_test.php b/cohort/tests/privacy_test.php index 71a70804eab..c6c04bc9a72 100644 --- a/cohort/tests/privacy_test.php +++ b/cohort/tests/privacy_test.php @@ -42,7 +42,7 @@ class core_cohort_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/comment/tests/externallib_test.php b/comment/tests/externallib_test.php index b9473923d54..ea79b8bdded 100644 --- a/comment/tests/externallib_test.php +++ b/comment/tests/externallib_test.php @@ -44,7 +44,7 @@ class core_comment_externallib_testcase extends externallib_advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); } diff --git a/comment/tests/privacy_test.php b/comment/tests/privacy_test.php index b2f7ba2d7eb..45e2093258c 100644 --- a/comment/tests/privacy_test.php +++ b/comment/tests/privacy_test.php @@ -38,7 +38,7 @@ use \core_privacy\tests\provider_testcase; */ class core_comment_privacy_testcase extends provider_testcase { - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); } diff --git a/competency/tests/external_test.php b/competency/tests/external_test.php index 83247d136a5..c2ddd7af698 100644 --- a/competency/tests/external_test.php +++ b/competency/tests/external_test.php @@ -96,7 +96,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Setup function- we will create a course and add an assign instance to it. */ - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/competency/tests/privacy_test.php b/competency/tests/privacy_test.php index 7105753f50d..4ba3a69b155 100644 --- a/competency/tests/privacy_test.php +++ b/competency/tests/privacy_test.php @@ -48,7 +48,7 @@ use core_competency\privacy\provider; */ class core_competency_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $PAGE; $this->resetAfterTest(); diff --git a/completion/tests/api_test.php b/completion/tests/api_test.php index af24c079a84..984393e70b0 100644 --- a/completion/tests/api_test.php +++ b/completion/tests/api_test.php @@ -38,7 +38,7 @@ class core_completion_api_testcase extends advanced_testcase { /** * Test setup. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/completion/tests/progress_test.php b/completion/tests/progress_test.php index fded21991e3..2ea3061a0f8 100644 --- a/completion/tests/progress_test.php +++ b/completion/tests/progress_test.php @@ -38,7 +38,7 @@ class core_completion_progress_testcase extends advanced_testcase { /** * Test setup. */ - public function setUp() { + public function setUp(): void { global $CFG; $CFG->enablecompletion = true; diff --git a/course/format/weeks/tests/observer_test.php b/course/format/weeks/tests/observer_test.php index 6e737d6ba15..5d833b12664 100644 --- a/course/format/weeks/tests/observer_test.php +++ b/course/format/weeks/tests/observer_test.php @@ -36,7 +36,7 @@ class format_weeks_observer_testcase extends advanced_testcase { /** * Test setup. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/course/tests/category_hooks_test.php b/course/tests/category_hooks_test.php index 52af5f710d7..4a5cb9a6f97 100644 --- a/course/tests/category_hooks_test.php +++ b/course/tests/category_hooks_test.php @@ -37,7 +37,7 @@ use PHPUnit\Framework\MockObject\MockObject; */ class core_course_category_hooks_testcase extends \advanced_testcase { - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } diff --git a/course/tests/category_test.php b/course/tests/category_test.php index 8d8b26be765..5d463dec0d1 100644 --- a/course/tests/category_test.php +++ b/course/tests/category_test.php @@ -32,7 +32,7 @@ class core_course_category_testcase extends advanced_testcase { protected $roles; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); diff --git a/course/tests/customfield_test.php b/course/tests/customfield_test.php index 2673208d4e2..64d5ba00460 100644 --- a/course/tests/customfield_test.php +++ b/course/tests/customfield_test.php @@ -40,7 +40,7 @@ class core_course_customfield_testcase extends advanced_testcase { /** * Set up */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); diff --git a/course/tests/events_test.php b/course/tests/events_test.php index 0a30f7e55ef..c3a96186fb9 100644 --- a/course/tests/events_test.php +++ b/course/tests/events_test.php @@ -36,7 +36,7 @@ class core_course_events_testcase extends advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/course/lib.php'); $this->resetAfterTest(); diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index 015632f7d08..648463db376 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -42,7 +42,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/course/externallib.php'); } diff --git a/course/tests/search_test.php b/course/tests/search_test.php index 6d03d4852d4..f438ee1dac6 100644 --- a/course/tests/search_test.php +++ b/course/tests/search_test.php @@ -53,7 +53,7 @@ class course_search_testcase extends advanced_testcase { */ protected $customfieldareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/customfield/field/checkbox/tests/plugin_test.php b/customfield/field/checkbox/tests/plugin_test.php index 4d945332990..9a64267af10 100644 --- a/customfield/field/checkbox/tests/plugin_test.php +++ b/customfield/field/checkbox/tests/plugin_test.php @@ -48,7 +48,7 @@ class customfield_checkbox_plugin_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->cfcat = $this->get_generator()->create_category(); diff --git a/customfield/field/date/tests/plugin_test.php b/customfield/field/date/tests/plugin_test.php index 749872287e0..4d52f3bafaf 100644 --- a/customfield/field/date/tests/plugin_test.php +++ b/customfield/field/date/tests/plugin_test.php @@ -48,7 +48,7 @@ class customfield_date_plugin_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->cfcat = $this->get_generator()->create_category(); @@ -206,4 +206,4 @@ class customfield_date_plugin_testcase extends advanced_testcase { public function test_delete() { $this->cfcat->get_handler()->delete_all(); } -} \ No newline at end of file +} diff --git a/customfield/field/select/tests/plugin_test.php b/customfield/field/select/tests/plugin_test.php index 6def88cfa66..937c2b86d15 100644 --- a/customfield/field/select/tests/plugin_test.php +++ b/customfield/field/select/tests/plugin_test.php @@ -48,7 +48,7 @@ class customfield_select_plugin_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->cfcat = $this->get_generator()->create_category(); @@ -199,4 +199,4 @@ class customfield_select_plugin_testcase extends advanced_testcase { public function test_delete() { $this->cfcat->get_handler()->delete_all(); } -} \ No newline at end of file +} diff --git a/customfield/field/text/tests/plugin_test.php b/customfield/field/text/tests/plugin_test.php index 8f625641ef2..b52d5a0685a 100644 --- a/customfield/field/text/tests/plugin_test.php +++ b/customfield/field/text/tests/plugin_test.php @@ -48,7 +48,7 @@ class customfield_text_plugin_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->cfcat = $this->get_generator()->create_category(); diff --git a/customfield/field/textarea/tests/plugin_test.php b/customfield/field/textarea/tests/plugin_test.php index a5cc62d3ccb..9c48ad6e24e 100644 --- a/customfield/field/textarea/tests/plugin_test.php +++ b/customfield/field/textarea/tests/plugin_test.php @@ -48,7 +48,7 @@ class customfield_textarea_plugin_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->cfcat = $this->get_generator()->create_category(); diff --git a/enrol/flatfile/tests/privacy_provider_test.php b/enrol/flatfile/tests/privacy_provider_test.php index 2619389177c..0b99cfc0906 100644 --- a/enrol/flatfile/tests/privacy_provider_test.php +++ b/enrol/flatfile/tests/privacy_provider_test.php @@ -63,7 +63,7 @@ class enrol_flatfile_privacy_testcase extends provider_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/enrol/imsenterprise/tests/imsenterprise_test.php b/enrol/imsenterprise/tests/imsenterprise_test.php index b0b783a6e3f..bbf3e25cd00 100644 --- a/enrol/imsenterprise/tests/imsenterprise_test.php +++ b/enrol/imsenterprise/tests/imsenterprise_test.php @@ -47,7 +47,7 @@ class enrol_imsenterprise_testcase extends advanced_testcase { /** * Setup required for all tests. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); $this->imsplugin = enrol_get_plugin('imsenterprise'); $this->set_test_config(); diff --git a/enrol/lti/tests/data_connector_test.php b/enrol/lti/tests/data_connector_test.php index b01009e6c67..48cb7f0e483 100644 --- a/enrol/lti/tests/data_connector_test.php +++ b/enrol/lti/tests/data_connector_test.php @@ -49,7 +49,7 @@ class enrol_lti_data_connector_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // Set this user as the admin. diff --git a/enrol/lti/tests/helper_test.php b/enrol/lti/tests/helper_test.php index a601cf7f9d8..75a79cd3209 100644 --- a/enrol/lti/tests/helper_test.php +++ b/enrol/lti/tests/helper_test.php @@ -48,7 +48,7 @@ class enrol_lti_helper_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // Set this user as the admin. diff --git a/enrol/lti/tests/lib_test.php b/enrol/lti/tests/lib_test.php index 3e478660c9b..5e9873d3398 100644 --- a/enrol/lti/tests/lib_test.php +++ b/enrol/lti/tests/lib_test.php @@ -45,7 +45,7 @@ class enrol_lti_testcase extends advanced_testcase { * * This is executed before running any tests in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } diff --git a/enrol/lti/tests/privacy_provider_test.php b/enrol/lti/tests/privacy_provider_test.php index 984684cb1ca..dfcaf07dc2d 100644 --- a/enrol/lti/tests/privacy_provider_test.php +++ b/enrol/lti/tests/privacy_provider_test.php @@ -58,7 +58,7 @@ class enrol_lti_privacy_provider_testcase extends \core_privacy\tests\provider_t /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->course = $this->getDataGenerator()->create_course(); diff --git a/enrol/lti/tests/sync_members_test.php b/enrol/lti/tests/sync_members_test.php index f9061bf6d16..e39ec7aaf61 100644 --- a/enrol/lti/tests/sync_members_test.php +++ b/enrol/lti/tests/sync_members_test.php @@ -59,7 +59,7 @@ class sync_members_testcase extends advanced_testcase { /** @var ResourceLink $resourcelink */ protected $resourcelink; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // Set this user as the admin. diff --git a/enrol/lti/tests/tool_provider_test.php b/enrol/lti/tests/tool_provider_test.php index 5e673ec720f..c05987b5ba0 100644 --- a/enrol/lti/tests/tool_provider_test.php +++ b/enrol/lti/tests/tool_provider_test.php @@ -53,7 +53,7 @@ class tool_provider_testcase extends advanced_testcase { * * This is executed before running any tests in this file. */ - public function setUp() { + public function setUp(): void { global $SESSION; $this->resetAfterTest(); diff --git a/enrol/paypal/tests/privacy_provider_test.php b/enrol/paypal/tests/privacy_provider_test.php index f1077871309..25b63042b42 100644 --- a/enrol/paypal/tests/privacy_provider_test.php +++ b/enrol/paypal/tests/privacy_provider_test.php @@ -79,7 +79,7 @@ class enrol_paypal_privacy_provider_testcase extends \core_privacy\tests\provide /** @var stdClass A test course with 2 enrolments for student2 and student12. */ protected $course3; - protected function setUp() { + protected function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/tests/course_enrolment_manager_test.php b/enrol/tests/course_enrolment_manager_test.php index 6954ff37c9f..11c4146d410 100644 --- a/enrol/tests/course_enrolment_manager_test.php +++ b/enrol/tests/course_enrolment_manager_test.php @@ -54,7 +54,7 @@ class core_course_enrolment_manager_testcase extends advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/enrol/locallib.php'); $this->setAdminUser(); diff --git a/enrol/tests/role_external_test.php b/enrol/tests/role_external_test.php index 4009101fbf5..64b63f37793 100644 --- a/enrol/tests/role_external_test.php +++ b/enrol/tests/role_external_test.php @@ -35,7 +35,7 @@ class core_enrol_role_external_testcase extends externallib_advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/enrol/externallib.php'); } @@ -142,4 +142,4 @@ class core_enrol_role_external_testcase extends externallib_advanced_testcase { $categories = core_role_external::unassign_roles( array('roleid' => 3, 'userid' => $USER->id, 'contextid' => $context->id)); } -} \ No newline at end of file +} diff --git a/favourites/tests/component_favourite_service_test.php b/favourites/tests/component_favourite_service_test.php index b4440073aaa..cb56a431049 100644 --- a/favourites/tests/component_favourite_service_test.php +++ b/favourites/tests/component_favourite_service_test.php @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); */ class component_favourite_service_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/favourites/tests/privacy_test.php b/favourites/tests/privacy_test.php index 75076890935..d7fe912b9b3 100644 --- a/favourites/tests/privacy_test.php +++ b/favourites/tests/privacy_test.php @@ -37,7 +37,7 @@ use \core_privacy\local\request\transform; */ class privacy_test extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/favourites/tests/repository_test.php b/favourites/tests/repository_test.php index b95451a12e2..d06868a379e 100644 --- a/favourites/tests/repository_test.php +++ b/favourites/tests/repository_test.php @@ -36,7 +36,7 @@ use \core_favourites\local\entity\favourite; */ class favourite_repository_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/favourites/tests/user_favourite_service_test.php b/favourites/tests/user_favourite_service_test.php index be372f17583..f44a6386e0f 100644 --- a/favourites/tests/user_favourite_service_test.php +++ b/favourites/tests/user_favourite_service_test.php @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); */ class user_favourite_service_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/filter/algebra/tests/filter_test.php b/filter/algebra/tests/filter_test.php index 529b9ec415e..fbb8a7bdb70 100644 --- a/filter/algebra/tests/filter_test.php +++ b/filter/algebra/tests/filter_test.php @@ -44,7 +44,7 @@ class filter_algebra_testcase extends basic_testcase { protected $filter; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->filter = new filter_algebra(context_system::instance(), array()); } diff --git a/filter/displayh5p/tests/filter_test.php b/filter/displayh5p/tests/filter_test.php index 467118cea2c..cb9b3c4f790 100644 --- a/filter/displayh5p/tests/filter_test.php +++ b/filter/displayh5p/tests/filter_test.php @@ -36,7 +36,7 @@ require_once($CFG->dirroot.'/filter/displayh5p/filter.php'); */ class filter_displayh5p_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(true); @@ -96,4 +96,4 @@ class filter_displayh5p_testcase extends advanced_testcase { "\"[^>]*?>#"] ]; } -} \ No newline at end of file +} diff --git a/filter/multilang/tests/filter_test.php b/filter/multilang/tests/filter_test.php index 2dbefa2c821..65d8ce37716 100644 --- a/filter/multilang/tests/filter_test.php +++ b/filter/multilang/tests/filter_test.php @@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die(); */ class filter_multilang_filter_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(true); diff --git a/filter/tex/tests/filter_test.php b/filter/tex/tests/filter_test.php index 1b03725f347..02dc2b1b218 100644 --- a/filter/tex/tests/filter_test.php +++ b/filter/tex/tests/filter_test.php @@ -40,7 +40,7 @@ class filter_tex_testcase extends advanced_testcase { protected $filter; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); $this->filter = new filter_tex(context_system::instance(), array()); diff --git a/grade/export/ods/tests/logging_test.php b/grade/export/ods/tests/logging_test.php index 67ce6584385..b2e97920749 100644 --- a/grade/export/ods/tests/logging_test.php +++ b/grade/export/ods/tests/logging_test.php @@ -36,7 +36,7 @@ class ods_logging_events_testcase extends advanced_testcase { /** * Setup is called before calling test case. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } @@ -62,4 +62,4 @@ class ods_logging_events_testcase extends advanced_testcase { $this->assertEquals(context_course::instance($course->id), $event->get_context()); $this->assertEquals('ods', $event->get_export_type()); } -} \ No newline at end of file +} diff --git a/grade/export/txt/tests/logging_test.php b/grade/export/txt/tests/logging_test.php index e2e7d7bed74..3bc0b49e3c2 100644 --- a/grade/export/txt/tests/logging_test.php +++ b/grade/export/txt/tests/logging_test.php @@ -36,7 +36,7 @@ class txt_logging_events_testcase extends advanced_testcase { /** * Setup is called before calling test case. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } @@ -62,4 +62,4 @@ class txt_logging_events_testcase extends advanced_testcase { $this->assertEquals(context_course::instance($course->id), $event->get_context()); $this->assertEquals('txt', $event->get_export_type()); } -} \ No newline at end of file +} diff --git a/grade/export/xls/tests/logging_test.php b/grade/export/xls/tests/logging_test.php index fcada0d9e1c..277481f3f2b 100644 --- a/grade/export/xls/tests/logging_test.php +++ b/grade/export/xls/tests/logging_test.php @@ -36,7 +36,7 @@ class xls_logging_events_testcase extends advanced_testcase { /** * Setup is called before calling test case. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } @@ -62,4 +62,4 @@ class xls_logging_events_testcase extends advanced_testcase { $this->assertEquals(context_course::instance($course->id), $event->get_context()); $this->assertEquals('xls', $event->get_export_type()); } -} \ No newline at end of file +} diff --git a/grade/export/xml/tests/logging_test.php b/grade/export/xml/tests/logging_test.php index b88d953126d..2e8263290e5 100644 --- a/grade/export/xml/tests/logging_test.php +++ b/grade/export/xml/tests/logging_test.php @@ -36,7 +36,7 @@ class xml_logging_events_testcase extends advanced_testcase { /** * Setup is called before calling test case. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } @@ -62,4 +62,4 @@ class xml_logging_events_testcase extends advanced_testcase { $this->assertEquals(context_course::instance($course->id), $event->get_context()); $this->assertEquals('xml', $event->get_export_type()); } -} \ No newline at end of file +} diff --git a/grade/import/csv/tests/load_data_test.php b/grade/import/csv/tests/load_data_test.php index f05e8b5e311..b49d16e00bd 100644 --- a/grade/import/csv/tests/load_data_test.php +++ b/grade/import/csv/tests/load_data_test.php @@ -64,7 +64,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** @var array $columns The first row of the csv file. These are the columns of the import file.*/ protected $columns; - public function tearDown() { + public function tearDown(): void { $this->csvimport = null; } diff --git a/grade/report/grader/tests/privacy_test.php b/grade/report/grader/tests/privacy_test.php index 2be84b674bc..5c8b7a5ba55 100644 --- a/grade/report/grader/tests/privacy_test.php +++ b/grade/report/grader/tests/privacy_test.php @@ -42,7 +42,7 @@ class gradereport_grader_privacy_testcase extends \core_privacy\tests\provider_t /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/grade/report/overview/tests/externallib_test.php b/grade/report/overview/tests/externallib_test.php index 1301c0d84dc..592c0192307 100644 --- a/grade/report/overview/tests/externallib_test.php +++ b/grade/report/overview/tests/externallib_test.php @@ -42,7 +42,7 @@ class gradereport_overview_externallib_testcase extends externallib_advanced_tes /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(true); diff --git a/grade/report/user/tests/lib_test.php b/grade/report/user/tests/lib_test.php index 7af1a71dac2..f1ff2e815ab 100644 --- a/grade/report/user/tests/lib_test.php +++ b/grade/report/user/tests/lib_test.php @@ -51,7 +51,7 @@ class gradereport_user_lib_testcase extends advanced_testcase { */ private $tree; - public function setUp() { + public function setUp(): void { $this->user = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); diff --git a/grade/report/user/tests/privacy_test.php b/grade/report/user/tests/privacy_test.php index b44f8bff378..49a5425963f 100644 --- a/grade/report/user/tests/privacy_test.php +++ b/grade/report/user/tests/privacy_test.php @@ -40,7 +40,7 @@ class gradereport_user_privacy_testcase extends \core_privacy\tests\provider_tes /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/grade/tests/events_test.php b/grade/tests/events_test.php index 5789fcd3f48..1cf7e15ca9b 100644 --- a/grade/tests/events_test.php +++ b/grade/tests/events_test.php @@ -46,7 +46,7 @@ class core_grade_events_test extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/grade/tests/grades_grader_gradingpanel_point_external_store_test.php b/grade/tests/grades_grader_gradingpanel_point_external_store_test.php index 5c8a50b4eef..05494286f56 100644 --- a/grade/tests/grades_grader_gradingpanel_point_external_store_test.php +++ b/grade/tests/grades_grader_gradingpanel_point_external_store_test.php @@ -279,7 +279,7 @@ class store_test extends advanced_testcase { * @param int $maxvalue The max value of the forum * @param int $suppliedvalue The value that was submitted */ - public function test_execute_store_out_of__range(int $maxvalue, int $suppliedvalue): void { + public function test_execute_store_out_of__range(int $maxvalue, float $suppliedvalue): void { $this->resetAfterTest(); $forum = $this->get_forum_instance([ diff --git a/grade/tests/privacy_test.php b/grade/tests/privacy_test.php index d9c2d485450..d721dee8f52 100644 --- a/grade/tests/privacy_test.php +++ b/grade/tests/privacy_test.php @@ -46,7 +46,7 @@ require_once($CFG->libdir . '/gradelib.php'); */ class core_grades_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $PAGE; $this->resetAfterTest(); $PAGE->get_renderer('core'); diff --git a/h5p/tests/editor_ajax_test.php b/h5p/tests/editor_ajax_test.php index 13f46c9d861..04ab135033f 100644 --- a/h5p/tests/editor_ajax_test.php +++ b/h5p/tests/editor_ajax_test.php @@ -46,7 +46,7 @@ class editor_ajax_testcase extends \advanced_testcase { /** * Set up function for tests. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); autoloader::register(); diff --git a/h5p/tests/editor_framework_test.php b/h5p/tests/editor_framework_test.php index 1dd6b8cacd6..8e3e220a8b3 100644 --- a/h5p/tests/editor_framework_test.php +++ b/h5p/tests/editor_framework_test.php @@ -45,7 +45,7 @@ class editor_framework_testcase extends \advanced_testcase { /** * Set up function for tests. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); autoloader::register(); diff --git a/h5p/tests/event_h5p_deleted_test.php b/h5p/tests/event_h5p_deleted_test.php index c2c65f5766f..89d8ca94104 100644 --- a/h5p/tests/event_h5p_deleted_test.php +++ b/h5p/tests/event_h5p_deleted_test.php @@ -42,7 +42,7 @@ class core_h5p_event_h5p_deleted_testcase extends advanced_testcase { /** * Setup test. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); autoloader::register(); } diff --git a/h5p/tests/event_h5p_viewed_test.php b/h5p/tests/event_h5p_viewed_test.php index 75a7671b348..73eb2644b25 100644 --- a/h5p/tests/event_h5p_viewed_test.php +++ b/h5p/tests/event_h5p_viewed_test.php @@ -42,7 +42,7 @@ class core_h5p_event_h5p_viewed_testcase extends advanced_testcase { /** * Setup test. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); autoloader::register(); } diff --git a/h5p/tests/external_test.php b/h5p/tests/external_test.php index 42f1aea2d34..e2a842ac77d 100644 --- a/h5p/tests/external_test.php +++ b/h5p/tests/external_test.php @@ -46,7 +46,7 @@ use core_h5p\local\library\autoloader; */ class core_h5p_external_testcase extends externallib_advanced_testcase { - protected function setUp() { + protected function setUp(): void { parent::setUp(); autoloader::register(); } diff --git a/h5p/tests/framework_test.php b/h5p/tests/framework_test.php index 13883c1c40b..9e5c4492567 100644 --- a/h5p/tests/framework_test.php +++ b/h5p/tests/framework_test.php @@ -44,7 +44,7 @@ class framework_testcase extends \advanced_testcase { /** * Set up function for tests. */ - public function setUp() { + public function setUp(): void { $factory = new \core_h5p\factory(); $this->framework = $factory->get_framework(); } diff --git a/h5p/tests/generator_test.php b/h5p/tests/generator_test.php index 05be9670cd6..b43df426dbb 100644 --- a/h5p/tests/generator_test.php +++ b/h5p/tests/generator_test.php @@ -43,7 +43,7 @@ class generator_testcase extends \advanced_testcase { /** * Tests set up. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); autoloader::register(); diff --git a/h5p/tests/h5p_core_test.php b/h5p/tests/h5p_core_test.php index d441fdc4c19..a1bcb2c6cce 100644 --- a/h5p/tests/h5p_core_test.php +++ b/h5p/tests/h5p_core_test.php @@ -40,7 +40,7 @@ defined('MOODLE_INTERNAL') || die(); */ class h5p_core_testcase extends \advanced_testcase { - protected function setup() { + protected function setUp(): void { global $CFG; parent::setUp(); diff --git a/h5p/tests/h5p_file_storage_test.php b/h5p/tests/h5p_file_storage_test.php index 8cce6c2ed8c..8199d353ac9 100644 --- a/h5p/tests/h5p_file_storage_test.php +++ b/h5p/tests/h5p_file_storage_test.php @@ -60,7 +60,7 @@ class h5p_file_storage_testcase extends \advanced_testcase { /** @var int $libraryid an id for the library. */ protected $libraryid = 1; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); diff --git a/iplookup/tests/geoip_test.php b/iplookup/tests/geoip_test.php index d553bd8938a..f1a8a933ef5 100644 --- a/iplookup/tests/geoip_test.php +++ b/iplookup/tests/geoip_test.php @@ -35,7 +35,7 @@ require_once("{$CFG->dirroot}/iplookup/lib.php"); * GeoIp data file parsing test. */ class core_iplookup_geoip_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/iplookup/tests/geoplugin_test.php b/iplookup/tests/geoplugin_test.php index 79466bc0122..3ebe8b4fc7d 100644 --- a/iplookup/tests/geoplugin_test.php +++ b/iplookup/tests/geoplugin_test.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); */ class core_iplookup_geoplugin_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { global $CFG; require_once("$CFG->libdir/filelib.php"); require_once("$CFG->dirroot/iplookup/lib.php"); diff --git a/lib/antivirus/clamav/tests/scanner_test.php b/lib/antivirus/clamav/tests/scanner_test.php index 87a39b7b904..4a2eca7a10a 100644 --- a/lib/antivirus/clamav/tests/scanner_test.php +++ b/lib/antivirus/clamav/tests/scanner_test.php @@ -29,7 +29,7 @@ class antivirus_clamav_scanner_testcase extends advanced_testcase { /** @var string temporary file used in testing */ protected $tempfile; - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); // Create tempfile. @@ -38,7 +38,7 @@ class antivirus_clamav_scanner_testcase extends advanced_testcase { touch($this->tempfile); } - protected function tearDown() { + protected function tearDown(): void { @unlink($this->tempfile); } diff --git a/lib/ddl/tests/ddl_test.php b/lib/ddl/tests/ddl_test.php index 852b9e95133..35526acdf4e 100644 --- a/lib/ddl/tests/ddl_test.php +++ b/lib/ddl/tests/ddl_test.php @@ -31,7 +31,7 @@ class core_ddl_testcase extends database_driver_testcase { /** @var array table name => array of stdClass test records loaded into that table. Created in setUp. */ private $records = array(); - protected function setUp() { + protected function setUp(): void { parent::setUp(); $dbman = $this->tdb->get_manager(); // Loads DDL libs. diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index e23a456d573..d55c8094dea 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die(); class core_dml_testcase extends database_driver_testcase { - protected function setUp() { + protected function setUp(): void { parent::setUp(); $dbman = $this->tdb->get_manager(); // Loads DDL libs. } diff --git a/lib/dml/tests/pgsql_native_recordset_test.php b/lib/dml/tests/pgsql_native_recordset_test.php index 690d1283031..53a2ff1d32e 100644 --- a/lib/dml/tests/pgsql_native_recordset_test.php +++ b/lib/dml/tests/pgsql_native_recordset_test.php @@ -44,7 +44,7 @@ class pgsql_native_recordset_testcase extends basic_testcase { /** * Creates a second db connection and a temp table with values in for testing. */ - protected function setUp() { + protected function setUp(): void { global $DB; parent::setUp(); @@ -87,7 +87,7 @@ class pgsql_native_recordset_testcase extends basic_testcase { /** * Gets rid of the second db connection. */ - protected function tearDown() { + protected function tearDown(): void { if ($this->specialdb) { $table = new xmldb_table('silly_test_table'); $this->specialdb->get_manager()->drop_table($table); diff --git a/lib/dml/tests/recordset_walk_test.php b/lib/dml/tests/recordset_walk_test.php index bab70450a55..17b58df1034 100644 --- a/lib/dml/tests/recordset_walk_test.php +++ b/lib/dml/tests/recordset_walk_test.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class core_recordset_walk_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); } diff --git a/lib/dml/tests/sqlsrv_native_moodle_database_test.php b/lib/dml/tests/sqlsrv_native_moodle_database_test.php index 8736d795b8e..e5f08e8ed9d 100644 --- a/lib/dml/tests/sqlsrv_native_moodle_database_test.php +++ b/lib/dml/tests/sqlsrv_native_moodle_database_test.php @@ -38,7 +38,7 @@ require_once($CFG->dirroot.'/lib/dml/sqlsrv_native_moodle_database.php'); */ class sqlsrv_native_moodle_database_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); } diff --git a/lib/filebrowser/tests/file_browser_test.php b/lib/filebrowser/tests/file_browser_test.php index 2959646fc1f..064140854bf 100644 --- a/lib/filebrowser/tests/file_browser_test.php +++ b/lib/filebrowser/tests/file_browser_test.php @@ -59,7 +59,7 @@ class file_browser_testcase extends advanced_testcase { /** * Set up */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/filestorage/tests/file_system_filedir_test.php b/lib/filestorage/tests/file_system_filedir_test.php index 525d7706ae2..24653715fb6 100644 --- a/lib/filestorage/tests/file_system_filedir_test.php +++ b/lib/filestorage/tests/file_system_filedir_test.php @@ -43,7 +43,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { /** * Shared test setUp. */ - public function setUp() { + public function setUp(): void { // Reset the file storage so that subsequent fetches to get_file_storage are called after // configuration is prepared. get_file_storage(true); @@ -52,7 +52,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { /** * Shared teset tearDown. */ - public function tearDown() { + public function tearDown(): void { // Reset the file storage so that subsequent tests will use the standard file storage. get_file_storage(true); } diff --git a/lib/filestorage/tests/file_system_test.php b/lib/filestorage/tests/file_system_test.php index 387d047aecd..4858c1c7c96 100644 --- a/lib/filestorage/tests/file_system_test.php +++ b/lib/filestorage/tests/file_system_test.php @@ -39,11 +39,11 @@ require_once($CFG->libdir . '/filestorage/file_system.php'); */ class core_files_file_system_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { get_file_storage(true); } - public function tearDown() { + public function tearDown(): void { get_file_storage(true); } diff --git a/lib/filestorage/tests/zip_packer_test.php b/lib/filestorage/tests/zip_packer_test.php index 4b36265e2b9..56fd859c829 100644 --- a/lib/filestorage/tests/zip_packer_test.php +++ b/lib/filestorage/tests/zip_packer_test.php @@ -37,7 +37,7 @@ class core_files_zip_packer_testcase extends advanced_testcase implements file_p */ protected $progress; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->testfile = __DIR__.'/fixtures/test.txt'; diff --git a/lib/form/tests/dateselector_test.php b/lib/form/tests/dateselector_test.php index 12934141c68..96052209f2b 100644 --- a/lib/form/tests/dateselector_test.php +++ b/lib/form/tests/dateselector_test.php @@ -50,7 +50,7 @@ class core_form_dateselector_testcase extends advanced_testcase { /** * Initalize test wide variable, it is called in start of the testcase */ - protected function setUp() { + protected function setUp(): void { global $CFG; parent::setUp(); diff --git a/lib/form/tests/datetimeselector_test.php b/lib/form/tests/datetimeselector_test.php index ec452128254..6e635b35a97 100644 --- a/lib/form/tests/datetimeselector_test.php +++ b/lib/form/tests/datetimeselector_test.php @@ -50,7 +50,7 @@ class core_form_datetimeselector_testcase extends advanced_testcase { /** * Initalize test wide variable, it is called in start of the testcase */ - protected function setUp() { + protected function setUp(): void { global $CFG; parent::setUp(); diff --git a/lib/grade/tests/fixtures/lib.php b/lib/grade/tests/fixtures/lib.php index e2203a29d5a..16050c828d2 100644 --- a/lib/grade/tests/fixtures/lib.php +++ b/lib/grade/tests/fixtures/lib.php @@ -49,7 +49,7 @@ abstract class grade_base_testcase extends advanced_testcase { protected $courseid; protected $userid; - protected function setUp() { + protected function setUp(): void { global $CFG; parent::setup(); diff --git a/lib/phpunit/classes/database_driver_testcase.php b/lib/phpunit/classes/database_driver_testcase.php index 63a99d4d802..a255208276a 100644 --- a/lib/phpunit/classes/database_driver_testcase.php +++ b/lib/phpunit/classes/database_driver_testcase.php @@ -67,7 +67,7 @@ abstract class database_driver_testcase extends base_testcase { $this->setRunTestInSeparateProcess(false); } - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; parent::setUpBeforeClass(); @@ -101,7 +101,7 @@ abstract class database_driver_testcase extends base_testcase { self::$extradb = $d; } - protected function setUp() { + protected function setUp(): void { global $DB; parent::setUp(); @@ -112,7 +112,7 @@ abstract class database_driver_testcase extends base_testcase { } } - protected function tearDown() { + protected function tearDown(): void { // delete all test tables $dbman = $this->tdb->get_manager(); $tables = $this->tdb->get_tables(false); @@ -125,7 +125,7 @@ abstract class database_driver_testcase extends base_testcase { parent::tearDown(); } - public static function tearDownAfterClass() { + public static function tearDownAfterClass(): void { if (self::$extradb) { self::$extradb->dispose(); self::$extradb = null; diff --git a/lib/phpunit/classes/restore_date_testcase.php b/lib/phpunit/classes/restore_date_testcase.php index bc80ae79af7..48d0412118d 100644 --- a/lib/phpunit/classes/restore_date_testcase.php +++ b/lib/phpunit/classes/restore_date_testcase.php @@ -51,7 +51,7 @@ abstract class restore_date_testcase extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { global $CFG; parent::setUp(); @@ -160,4 +160,4 @@ abstract class restore_date_testcase extends advanced_testcase { return ($this->restorestartdate - $this->startdate); } -} \ No newline at end of file +} diff --git a/lib/phpunit/tests/basic_test.php b/lib/phpunit/tests/basic_test.php index 04b75c5caee..9ef7e1d995b 100644 --- a/lib/phpunit/tests/basic_test.php +++ b/lib/phpunit/tests/basic_test.php @@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die(); class core_phpunit_basic_testcase extends basic_testcase { protected $testassertexecuted = false; - protected function setUp() { + protected function setUp(): void { parent::setUp(); if ($this->getName() === 'test_setup_assert') { $this->assertTrue(true); diff --git a/lib/tests/ajaxlib_test.php b/lib/tests/ajaxlib_test.php index 18b459463a2..4ce4ca9d2a4 100644 --- a/lib/tests/ajaxlib_test.php +++ b/lib/tests/ajaxlib_test.php @@ -29,7 +29,7 @@ class core_ajaxlib_testcase extends advanced_testcase { /** @var string Original error log */ protected $oldlog; - protected function setUp() { + protected function setUp(): void { global $CFG; parent::setUp(); @@ -38,7 +38,7 @@ class core_ajaxlib_testcase extends advanced_testcase { ini_set('error_log', "$CFG->dataroot/testlog.log"); } - protected function tearDown() { + protected function tearDown(): void { ini_set('error_log', $this->oldlog); parent::tearDown(); } diff --git a/lib/tests/antivirus_test.php b/lib/tests/antivirus_test.php index 96fb1ce8b7c..fb92f8e013b 100644 --- a/lib/tests/antivirus_test.php +++ b/lib/tests/antivirus_test.php @@ -29,7 +29,7 @@ require_once(__DIR__ . '/fixtures/testable_antivirus.php'); class core_antivirus_testcase extends advanced_testcase { protected $tempfile; - protected function setUp() { + protected function setUp(): void { global $CFG; // Use our special testable fixture plugin. $CFG->antiviruses = 'testable'; @@ -42,7 +42,7 @@ class core_antivirus_testcase extends advanced_testcase { touch($this->tempfile); } - protected function tearDown() { + protected function tearDown(): void { @unlink($this->tempfile); } diff --git a/lib/tests/blocklib_test.php b/lib/tests/blocklib_test.php index 1cf455261c9..4fbd0a64416 100644 --- a/lib/tests/blocklib_test.php +++ b/lib/tests/blocklib_test.php @@ -39,7 +39,7 @@ class core_blocklib_testcase extends advanced_testcase { protected $blockmanager; protected $isediting = null; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->testpage = new moodle_page(); $this->testpage->set_context(context_system::instance()); @@ -47,7 +47,7 @@ class core_blocklib_testcase extends advanced_testcase { $this->blockmanager = new testable_block_manager($this->testpage); } - protected function tearDown() { + protected function tearDown(): void { $this->testpage = null; $this->blockmanager = null; parent::tearDown(); diff --git a/lib/tests/calendar_cron_task_test.php b/lib/tests/calendar_cron_task_test.php index 6b099876807..a880f9b0ff6 100644 --- a/lib/tests/calendar_cron_task_test.php +++ b/lib/tests/calendar_cron_task_test.php @@ -39,7 +39,7 @@ class core_calendar_cron_task_testcase extends advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); } diff --git a/lib/tests/collator_test.php b/lib/tests/collator_test.php index 7fb9eddb158..94604fec862 100644 --- a/lib/tests/collator_test.php +++ b/lib/tests/collator_test.php @@ -48,7 +48,7 @@ class core_collator_testcase extends advanced_testcase { /** * Prepares things for this test case. */ - protected function setUp() { + protected function setUp(): void { global $SESSION; if (isset($SESSION->lang)) { $this->initiallang = $SESSION->lang; @@ -65,7 +65,7 @@ class core_collator_testcase extends advanced_testcase { /** * Cleans things up after this test case has run. */ - protected function tearDown() { + protected function tearDown(): void { global $SESSION; parent::tearDown(); if ($this->initiallang !== null) { diff --git a/lib/tests/component_test.php b/lib/tests/component_test.php index f66a69daab1..0111d669672 100644 --- a/lib/tests/component_test.php +++ b/lib/tests/component_test.php @@ -38,7 +38,7 @@ class core_component_testcase extends advanced_testcase { */ const SUBSYSTEMCOUNT = 71; - public function setUp() { + public function setUp(): void { $psr0namespaces = new ReflectionProperty('core_component', 'psr0namespaces'); $psr0namespaces->setAccessible(true); $this->oldpsr0namespaces = $psr0namespaces->getValue(null); @@ -47,7 +47,7 @@ class core_component_testcase extends advanced_testcase { $psr4namespaces->setAccessible(true); $this->oldpsr4namespaces = $psr4namespaces->getValue(null); } - public function tearDown() { + public function tearDown(): void { $psr0namespaces = new ReflectionProperty('core_component', 'psr0namespaces'); $psr0namespaces->setAccessible(true); $psr0namespaces->setValue(null, $this->oldpsr0namespaces); diff --git a/lib/tests/core_media_player_native.php b/lib/tests/core_media_player_native.php index c7e925bf7f5..5feb310d138 100644 --- a/lib/tests/core_media_player_native.php +++ b/lib/tests/core_media_player_native.php @@ -40,7 +40,7 @@ class core_media_player_native_testcase extends advanced_testcase { /** * Pre-test setup. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); } @@ -160,4 +160,4 @@ class core_media_player_native_testcase extends advanced_testcase { $this->assertNotContains('', $content); $this->assertNotContains('', $content); } -} \ No newline at end of file +} diff --git a/lib/tests/csvclass_test.php b/lib/tests/csvclass_test.php index 55e84d14e67..7d7523b8c6d 100644 --- a/lib/tests/csvclass_test.php +++ b/lib/tests/csvclass_test.php @@ -36,7 +36,7 @@ class core_csvclass_testcase extends advanced_testcase { protected $teststring3 = ''; protected $teststring4 = ''; - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); diff --git a/lib/tests/customcontext_test.php b/lib/tests/customcontext_test.php index eaa2f3c888e..7dcd228f7f2 100644 --- a/lib/tests/customcontext_test.php +++ b/lib/tests/customcontext_test.php @@ -103,7 +103,7 @@ class customcontext_testcase extends advanced_testcase { /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } diff --git a/lib/tests/event/contentbank_content_created_test.php b/lib/tests/event/contentbank_content_created_test.php index 0e381b9e6d3..70a9f587aaa 100644 --- a/lib/tests/event/contentbank_content_created_test.php +++ b/lib/tests/event/contentbank_content_created_test.php @@ -39,7 +39,7 @@ class contentbank_content_created_testcase extends \advanced_testcase { /** * Setup to ensure that fixtures are loaded. */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php'); diff --git a/lib/tests/event/contentbank_content_deleted_test.php b/lib/tests/event/contentbank_content_deleted_test.php index 20c7517d846..5604bd8fe29 100644 --- a/lib/tests/event/contentbank_content_deleted_test.php +++ b/lib/tests/event/contentbank_content_deleted_test.php @@ -39,7 +39,7 @@ class contentbank_content_deleted_testcase extends \advanced_testcase { /** * Setup to ensure that fixtures are loaded. */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php'); diff --git a/lib/tests/event/contentbank_content_updated_test.php b/lib/tests/event/contentbank_content_updated_test.php index b6aeae790d3..e5fc2979683 100644 --- a/lib/tests/event/contentbank_content_updated_test.php +++ b/lib/tests/event/contentbank_content_updated_test.php @@ -39,7 +39,7 @@ class contentbank_content_updated_testcase extends \advanced_testcase { /** * Setup to ensure that fixtures are loaded. */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php'); diff --git a/lib/tests/event/contentbank_content_uploaded_test.php b/lib/tests/event/contentbank_content_uploaded_test.php index 93e6d7d045d..8e1fe8da262 100644 --- a/lib/tests/event/contentbank_content_uploaded_test.php +++ b/lib/tests/event/contentbank_content_uploaded_test.php @@ -41,7 +41,7 @@ class contentbank_content_uploaded_testcase extends \advanced_testcase { /** * Setup to ensure that fixtures are loaded. */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php'); diff --git a/lib/tests/event/contentbank_content_viewed_test.php b/lib/tests/event/contentbank_content_viewed_test.php index 3cf66ded4a1..e2bb7867fa2 100644 --- a/lib/tests/event/contentbank_content_viewed_test.php +++ b/lib/tests/event/contentbank_content_viewed_test.php @@ -39,7 +39,7 @@ class contentbank_content_viewed_testcase extends \advanced_testcase { /** * Setup to ensure that fixtures are loaded. */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php'); diff --git a/lib/tests/event_profile_field_test.php b/lib/tests/event_profile_field_test.php index b60f301a649..82154e7dcae 100644 --- a/lib/tests/event_profile_field_test.php +++ b/lib/tests/event_profile_field_test.php @@ -42,7 +42,7 @@ class core_event_profile_field_testcase extends advanced_testcase { /** * Test set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/lib/tests/event_user_graded_test.php b/lib/tests/event_user_graded_test.php index b0eb08497a1..e30e30ab033 100644 --- a/lib/tests/event_user_graded_test.php +++ b/lib/tests/event_user_graded_test.php @@ -44,7 +44,7 @@ class core_event_user_graded_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/lib/tests/events_test.php b/lib/tests/events_test.php index 9fc766aa1d6..fe1d24a65f7 100644 --- a/lib/tests/events_test.php +++ b/lib/tests/events_test.php @@ -34,7 +34,7 @@ class core_events_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/lib/tests/exporter_test.php b/lib/tests/exporter_test.php index b56cd130655..7b227577920 100644 --- a/lib/tests/exporter_test.php +++ b/lib/tests/exporter_test.php @@ -39,7 +39,7 @@ class core_exporter_testcase extends advanced_testcase { protected $validdata = null; protected $invaliddata = null; - public function setUp() { + public function setUp(): void { $s = new stdClass(); $this->validrelated = array( 'simplestdClass' => $s, diff --git a/lib/tests/externallib_test.php b/lib/tests/externallib_test.php index aa8101f3f4e..3d91acd1997 100644 --- a/lib/tests/externallib_test.php +++ b/lib/tests/externallib_test.php @@ -32,11 +32,11 @@ require_once($CFG->libdir . '/externallib.php'); class core_externallib_testcase extends advanced_testcase { protected $DB; - public function setUp() { + public function setUp(): void { $this->DB = null; } - public function tearDown() { + public function tearDown(): void { global $DB; if ($this->DB !== null) { $DB = $this->DB; diff --git a/lib/tests/gdlib_test.php b/lib/tests/gdlib_test.php index 8875c3c87d5..edc6d1df77b 100644 --- a/lib/tests/gdlib_test.php +++ b/lib/tests/gdlib_test.php @@ -38,7 +38,7 @@ class core_gdlib_testcase extends basic_testcase { private $fixturepath = null; - public function setUp() { + public function setUp(): void { $this->fixturepath = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; } diff --git a/lib/tests/h5p_get_content_types_task_test.php b/lib/tests/h5p_get_content_types_task_test.php index 3502a1bf285..00ac6183d27 100644 --- a/lib/tests/h5p_get_content_types_task_test.php +++ b/lib/tests/h5p_get_content_types_task_test.php @@ -38,7 +38,7 @@ defined('MOODLE_INTERNAL') || die(); */ class h5p_get_content_types_task_testcase extends advanced_testcase { - protected function setup() { + protected function setup(): void { global $CFG; parent::setUp(); diff --git a/lib/tests/lock_test.php b/lib/tests/lock_test.php index 2064621b2d3..d7c32111223 100644 --- a/lib/tests/lock_test.php +++ b/lib/tests/lock_test.php @@ -39,7 +39,7 @@ class lock_testcase extends advanced_testcase { /** * Some lock types will store data in the database. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); } diff --git a/lib/tests/medialib_test.php b/lib/tests/medialib_test.php index 8b230c94b1b..d92ba7a464f 100644 --- a/lib/tests/medialib_test.php +++ b/lib/tests/medialib_test.php @@ -34,7 +34,7 @@ class core_medialib_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Reset $CFG and $SERVER. @@ -496,4 +496,4 @@ class core_medialib_testcase extends advanced_testcase { } return $out; } -} \ No newline at end of file +} diff --git a/lib/tests/moodle_page_test.php b/lib/tests/moodle_page_test.php index bd68624333e..0159a6c5bec 100644 --- a/lib/tests/moodle_page_test.php +++ b/lib/tests/moodle_page_test.php @@ -37,7 +37,7 @@ class core_moodle_page_testcase extends advanced_testcase { */ protected $testpage; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->testpage = new testable_moodle_page(); diff --git a/lib/tests/myprofilelib_test.php b/lib/tests/myprofilelib_test.php index 6cb5dc91be3..20476c0d695 100644 --- a/lib/tests/myprofilelib_test.php +++ b/lib/tests/myprofilelib_test.php @@ -51,7 +51,7 @@ class core_myprofilelib_testcase extends advanced_testcase { */ private $tree; - public function setUp() { + public function setUp(): void { // Set the $PAGE->url value so core_myprofile_navigation() doesn't complain. global $PAGE; $PAGE->set_url('/test'); diff --git a/lib/tests/notification_test.php b/lib/tests/notification_test.php index 50d5adcd478..33078fe8d37 100644 --- a/lib/tests/notification_test.php +++ b/lib/tests/notification_test.php @@ -42,7 +42,7 @@ class core_notification_testcase extends advanced_testcase { * This includes emptying the list of notifications on the session, resetting any session which exists, and setting * up a new moodle_page object. */ - public function setUp() { + public function setUp(): void { global $PAGE, $SESSION; parent::setUp(); @@ -57,7 +57,7 @@ class core_notification_testcase extends advanced_testcase { * This includes emptying the list of notifications on the session, resetting any session which exists, and setting * up a new moodle_page object. */ - public function tearDown() { + public function tearDown(): void { global $PAGE, $SESSION; $PAGE = null; diff --git a/lib/tests/persistent_test.php b/lib/tests/persistent_test.php index 9446e2a5aec..711903e1c98 100644 --- a/lib/tests/persistent_test.php +++ b/lib/tests/persistent_test.php @@ -34,7 +34,7 @@ global $CFG; */ class core_persistent_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->make_persistent_table(); $this->resetAfterTest(); } diff --git a/lib/tests/plugin_manager_test.php b/lib/tests/plugin_manager_test.php index 009c57eae5f..41a7957244c 100644 --- a/lib/tests/plugin_manager_test.php +++ b/lib/tests/plugin_manager_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot.'/lib/tests/fixtures/testable_plugininfo_base.php'); */ class core_plugin_manager_testcase extends advanced_testcase { - public function tearDown() { + public function tearDown(): void { // The caches of the testable singleton must be reset explicitly. It is // safer to kill the whole testable singleton at the end of every test. testable_core_plugin_manager::reset_caches(); diff --git a/lib/tests/plugininfo/base_test.php b/lib/tests/plugininfo/base_test.php index d5b805fa992..e8f55661717 100644 --- a/lib/tests/plugininfo/base_test.php +++ b/lib/tests/plugininfo/base_test.php @@ -50,7 +50,7 @@ class base_testcase extends \advanced_testcase { /** * Tear down the testable plugin manager singleton between tests. */ - public function tearDown() { + public function tearDown(): void { // The caches of the testable singleton must be reset explicitly. It is // safer to kill the whole testable singleton at the end of every test. testable_core_plugin_manager::reset_caches(); diff --git a/lib/tests/questionlib_test.php b/lib/tests/questionlib_test.php index 3b79c46dac7..0ffa10cfe77 100644 --- a/lib/tests/questionlib_test.php +++ b/lib/tests/questionlib_test.php @@ -49,7 +49,7 @@ class core_questionlib_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/lib/tests/rsslib_test.php b/lib/tests/rsslib_test.php index c724f6a53b8..0db975b54a4 100644 --- a/lib/tests/rsslib_test.php +++ b/lib/tests/rsslib_test.php @@ -40,7 +40,7 @@ class core_rsslib_testcase extends advanced_testcase { // The number of seconds tests should wait for the server to respond (high to prevent false positives). const TIMEOUT = 10; - protected function setUp() { + protected function setUp(): void { moodle_simplepie::reset_cache(); } diff --git a/lib/tests/session_redis_test.php b/lib/tests/session_redis_test.php index cadbc3b5a34..46373d61ace 100644 --- a/lib/tests/session_redis_test.php +++ b/lib/tests/session_redis_test.php @@ -47,7 +47,7 @@ class core_session_redis_testcase extends advanced_testcase { /** @var $redis The current testing redis connection */ protected $redis = null; - public function setUp() { + public function setUp(): void { global $CFG; if (!extension_loaded('redis')) { @@ -79,7 +79,7 @@ class core_session_redis_testcase extends advanced_testcase { $this->redis->connect(TEST_SESSION_REDIS_HOST); } - public function tearDown() { + public function tearDown(): void { if (!extension_loaded('redis') || !defined('TEST_SESSION_REDIS_HOST')) { return; } diff --git a/lib/tests/statslib_test.php b/lib/tests/statslib_test.php index 7af80e024f8..7e45f9acbab 100644 --- a/lib/tests/statslib_test.php +++ b/lib/tests/statslib_test.php @@ -52,7 +52,7 @@ class core_statslib_testcase extends advanced_testcase { * Setup function * - Allow changes to CFG->debug for testing purposes. */ - protected function setUp() { + protected function setUp(): void { global $CFG, $DB; parent::setUp(); diff --git a/lib/tests/task_database_logger_test.php b/lib/tests/task_database_logger_test.php index d2c43b241a4..4ae0a661311 100644 --- a/lib/tests/task_database_logger_test.php +++ b/lib/tests/task_database_logger_test.php @@ -43,7 +43,7 @@ class task_database_logger_testcase extends advanced_testcase { /** * Setup to backup the database before mocking. */ - public function setUp() { + public function setUp(): void { global $DB; $this->DB = $DB; @@ -52,7 +52,7 @@ class task_database_logger_testcase extends advanced_testcase { /** * Tear down to unmock the database where it was mocked. */ - public function tearDown() { + public function tearDown(): void { global $DB; $DB = $this->DB; diff --git a/lib/tests/task_logging_test.php b/lib/tests/task_logging_test.php index d4f4e12de8b..39b86cd0729 100644 --- a/lib/tests/task_logging_test.php +++ b/lib/tests/task_logging_test.php @@ -43,7 +43,7 @@ class core_task_logmanager extends advanced_testcase { /** * Relevant tearDown for logging tests. */ - public function tearDown() { + public function tearDown(): void { global $DB; // Ensure that any logging is always ended. diff --git a/lib/tests/time_splittings_test.php b/lib/tests/time_splittings_test.php index d36f9b97b18..646bbf48d3d 100644 --- a/lib/tests/time_splittings_test.php +++ b/lib/tests/time_splittings_test.php @@ -44,7 +44,7 @@ class core_analytics_time_splittings_testcase extends advanced_testcase { * * @return void */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); diff --git a/lib/tests/user_test.php b/lib/tests/user_test.php index 6777f1f9caf..ecfd86be462 100644 --- a/lib/tests/user_test.php +++ b/lib/tests/user_test.php @@ -34,7 +34,7 @@ class core_user_testcase extends advanced_testcase { /** * Setup test data. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); } diff --git a/lib/tests/useragent_test.php b/lib/tests/useragent_test.php index 28a3b0031a3..9765e9127ed 100644 --- a/lib/tests/useragent_test.php +++ b/lib/tests/useragent_test.php @@ -34,7 +34,7 @@ class core_useragent_testcase extends advanced_testcase { /** * Restores the user agent to the default one. */ - public function tearDown() { + public function tearDown(): void { core_useragent::instance(true); } diff --git a/lib/xapi/tests/external/post_statement_test.php b/lib/xapi/tests/external/post_statement_test.php index 90e5000e64a..e6547a90fcd 100644 --- a/lib/xapi/tests/external/post_statement_test.php +++ b/lib/xapi/tests/external/post_statement_test.php @@ -64,7 +64,7 @@ class post_statement_testcase extends externallib_advanced_testcase { /** * Setup test. */ - public function setUp() { + public function setUp(): void { global $CFG; // We disable group actors on the test xapi_handler. $CFG->xapitestforcegroupactors = false; diff --git a/media/player/html5audio/tests/player_test.php b/media/player/html5audio/tests/player_test.php index 7dfe8e4f1ff..15e0ccdf51e 100644 --- a/media/player/html5audio/tests/player_test.php +++ b/media/player/html5audio/tests/player_test.php @@ -36,7 +36,7 @@ class media_html5audio_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Reset $CFG and $SERVER. diff --git a/media/player/html5video/tests/player_test.php b/media/player/html5video/tests/player_test.php index 3def9af83af..c4a20c1d715 100644 --- a/media/player/html5video/tests/player_test.php +++ b/media/player/html5video/tests/player_test.php @@ -36,7 +36,7 @@ class media_html5video_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Reset $CFG and $SERVER. diff --git a/media/player/swf/tests/player_test.php b/media/player/swf/tests/player_test.php index f7b053fc693..d072e33ff38 100644 --- a/media/player/swf/tests/player_test.php +++ b/media/player/swf/tests/player_test.php @@ -36,7 +36,7 @@ class media_swf_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { global $CFG; parent::setUp(); diff --git a/media/player/videojs/tests/player_test.php b/media/player/videojs/tests/player_test.php index aa8de9f56ee..c9069347eb4 100644 --- a/media/player/videojs/tests/player_test.php +++ b/media/player/videojs/tests/player_test.php @@ -36,7 +36,7 @@ class media_videojs_player_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Reset $CFG and $SERVER. diff --git a/media/player/vimeo/tests/player_test.php b/media/player/vimeo/tests/player_test.php index 3f4dcbf33c6..125e40fb5cc 100644 --- a/media/player/vimeo/tests/player_test.php +++ b/media/player/vimeo/tests/player_test.php @@ -36,7 +36,7 @@ class media_vimeo_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Reset $CFG and $SERVER. diff --git a/media/player/youtube/tests/player_test.php b/media/player/youtube/tests/player_test.php index 5c9d851731f..b5f298e1124 100644 --- a/media/player/youtube/tests/player_test.php +++ b/media/player/youtube/tests/player_test.php @@ -36,7 +36,7 @@ class media_youtube_testcase extends advanced_testcase { /** * Pre-test setup. Preserves $CFG. */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Reset $CFG and $SERVER. diff --git a/message/output/airnotifier/tests/externallib_test.php b/message/output/airnotifier/tests/externallib_test.php index d0d3a54b668..a4fbbf85245 100644 --- a/message/output/airnotifier/tests/externallib_test.php +++ b/message/output/airnotifier/tests/externallib_test.php @@ -42,7 +42,7 @@ class message_airnotifier_external_testcase extends externallib_advanced_testcas /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/message/output/airnotifier/externallib.php'); } diff --git a/message/output/airnotifier/tests/privacy_test.php b/message/output/airnotifier/tests/privacy_test.php index 96bd3478801..22cc63d99cb 100644 --- a/message/output/airnotifier/tests/privacy_test.php +++ b/message/output/airnotifier/tests/privacy_test.php @@ -38,7 +38,7 @@ class message_airnotifier_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/message/output/email/tests/privacy_test.php b/message/output/email/tests/privacy_test.php index dbfd9ba18a0..700c919bfc1 100644 --- a/message/output/email/tests/privacy_test.php +++ b/message/output/email/tests/privacy_test.php @@ -34,7 +34,7 @@ class message_email_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/message/output/jabber/tests/privacy_test.php b/message/output/jabber/tests/privacy_test.php index 99e16cf8e48..1475b275a05 100644 --- a/message/output/jabber/tests/privacy_test.php +++ b/message/output/jabber/tests/privacy_test.php @@ -36,7 +36,7 @@ class message_jabber_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/message/output/popup/tests/api_test.php b/message/output/popup/tests/api_test.php index 1d51f6a44fa..069e5f6cbd5 100644 --- a/message/output/popup/tests/api_test.php +++ b/message/output/popup/tests/api_test.php @@ -46,7 +46,7 @@ class message_popup_api_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->preventResetByRollback(); // Messaging is not compatible with transactions. $this->messagesink = $this->redirectMessages(); $this->resetAfterTest(); diff --git a/message/output/popup/tests/externallib_test.php b/message/output/popup/tests/externallib_test.php index 94fe0dbc42a..26da55f692c 100644 --- a/message/output/popup/tests/externallib_test.php +++ b/message/output/popup/tests/externallib_test.php @@ -44,7 +44,7 @@ class message_popup_externallib_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->preventResetByRollback(); // Messaging is not compatible with transactions. $this->messagesink = $this->redirectMessages(); $this->resetAfterTest(); diff --git a/message/tests/events_test.php b/message/tests/events_test.php index 00a6b19fae2..0ec24ea9c5d 100644 --- a/message/tests/events_test.php +++ b/message/tests/events_test.php @@ -44,7 +44,7 @@ class core_message_events_testcase extends core_message_messagelib_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php index 4fd7e6ea49d..c21c311fdc8 100644 --- a/message/tests/externallib_test.php +++ b/message/tests/externallib_test.php @@ -37,7 +37,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; require_once($CFG->dirroot . '/message/lib.php'); diff --git a/message/tests/helper_test.php b/message/tests/helper_test.php index 7b27d56ba1f..2bfa83e0986 100644 --- a/message/tests/helper_test.php +++ b/message/tests/helper_test.php @@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/message/tests/messagelib_test.php'); */ class core_message_helper_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/message/tests/inbound_test.php b/message/tests/inbound_test.php index e07b2f78c59..6db7eb4ab66 100644 --- a/message/tests/inbound_test.php +++ b/message/tests/inbound_test.php @@ -38,7 +38,7 @@ class core_message_inbound_testcase extends advanced_testcase { * This includes: * * configuring the messageinbound_mailbox. */ - public function setUp() { + public function setUp(): void { global $CFG; $this->resetAfterTest(true); diff --git a/message/tests/messagelib_test.php b/message/tests/messagelib_test.php index 5a75739fffd..7d195e7e1af 100644 --- a/message/tests/messagelib_test.php +++ b/message/tests/messagelib_test.php @@ -48,7 +48,7 @@ class core_message_messagelib_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->preventResetByRollback(); // Messaging is not compatible with transactions. $this->messagesink = $this->redirectMessages(); $this->resetAfterTest(); diff --git a/message/tests/migrate_message_data_task_test.php b/message/tests/migrate_message_data_task_test.php index a480e70e213..704396b669d 100644 --- a/message/tests/migrate_message_data_task_test.php +++ b/message/tests/migrate_message_data_task_test.php @@ -44,7 +44,7 @@ class core_message_migrate_message_data_task_testcase extends advanced_testcase * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/message/tests/search_received_test.php b/message/tests/search_received_test.php index c8f53ac366e..7e59a281eb8 100644 --- a/message/tests/search_received_test.php +++ b/message/tests/search_received_test.php @@ -45,7 +45,7 @@ class message_received_search_testcase extends advanced_testcase { * Setting up the test environment * @return void */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/message/tests/search_sent_test.php b/message/tests/search_sent_test.php index eb42216cb2e..91a0a6e4668 100644 --- a/message/tests/search_sent_test.php +++ b/message/tests/search_sent_test.php @@ -45,7 +45,7 @@ class message_sent_search_testcase extends advanced_testcase { * Setting up the test environment * @return void */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/mnet/service/enrol/tests/privacy_test.php b/mnet/service/enrol/tests/privacy_test.php index 005e0e38b0f..795ec779845 100644 --- a/mnet/service/enrol/tests/privacy_test.php +++ b/mnet/service/enrol/tests/privacy_test.php @@ -51,7 +51,7 @@ class mnetservice_enrol_privacy_testcase extends provider_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { global $DB; // Add a mnet host. @@ -340,4 +340,4 @@ class mnetservice_enrol_privacy_testcase extends provider_testcase { $course->rolename = 'student'; $DB->insert_record('mnetservice_enrol_courses', $course); } -} \ No newline at end of file +} diff --git a/mnet/tests/events_test.php b/mnet/tests/events_test.php index 451a1c6085f..599342bdeb4 100644 --- a/mnet/tests/events_test.php +++ b/mnet/tests/events_test.php @@ -39,7 +39,7 @@ class mnet_events_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/mod/assign/feedback/editpdf/tests/privacy_test.php b/mod/assign/feedback/editpdf/tests/privacy_test.php index af07abe51b9..cfd355eb84a 100644 --- a/mod/assign/feedback/editpdf/tests/privacy_test.php +++ b/mod/assign/feedback/editpdf/tests/privacy_test.php @@ -39,7 +39,7 @@ use \mod_assign\privacy\assign_plugin_request_data; */ class assignfeedback_editpdf_privacy_testcase extends \mod_assign\tests\mod_assign_privacy_testcase { - public function setUp() { + public function setUp(): void { // Skip this test if ghostscript is not supported. $result = \assignfeedback_editpdf\pdf::test_gs_path(false); if ($result->status !== \assignfeedback_editpdf\pdf::GSPATH_OK) { diff --git a/mod/assign/tests/base_test.php b/mod/assign/tests/base_test.php index d30f98986c5..3212fe37697 100644 --- a/mod/assign/tests/base_test.php +++ b/mod/assign/tests/base_test.php @@ -86,7 +86,7 @@ class mod_assign_base_testcase extends advanced_testcase { /** * Setup function - we will create a course and add an assign instance to it. */ - protected function setUp() { + protected function setUp(): void { global $DB; $this->resetAfterTest(true); diff --git a/mod/book/tests/events_test.php b/mod/book/tests/events_test.php index cd95aea24e3..dbda1846621 100644 --- a/mod/book/tests/events_test.php +++ b/mod/book/tests/events_test.php @@ -36,7 +36,7 @@ global $CFG; */ class mod_book_events_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/book/tests/lib_test.php b/mod/book/tests/lib_test.php index 247f29dda93..283997673f5 100644 --- a/mod/book/tests/lib_test.php +++ b/mod/book/tests/lib_test.php @@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/mod/book/lib.php'); */ class mod_book_lib_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } diff --git a/mod/book/tests/search_test.php b/mod/book/tests/search_test.php index 65e15896ba3..03bfd1e05d3 100644 --- a/mod/book/tests/search_test.php +++ b/mod/book/tests/search_test.php @@ -43,7 +43,7 @@ class mod_book_search_testcase extends advanced_testcase { */ protected $bookchapterareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/mod/book/tool/exportimscp/tests/events_test.php b/mod/book/tool/exportimscp/tests/events_test.php index 3132a41fb0e..91e16c70ce8 100644 --- a/mod/book/tool/exportimscp/tests/events_test.php +++ b/mod/book/tool/exportimscp/tests/events_test.php @@ -36,7 +36,7 @@ global $CFG; */ class booktool_exportimscp_events_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/book/tool/importhtml/tests/locallib_test.php b/mod/book/tool/importhtml/tests/locallib_test.php index 1ab755f4ac9..d0ccb051c95 100644 --- a/mod/book/tool/importhtml/tests/locallib_test.php +++ b/mod/book/tool/importhtml/tests/locallib_test.php @@ -38,7 +38,7 @@ require_once($CFG->dirroot.'/mod/book/tool/importhtml/locallib.php'); */ class booktool_importhtml_locallib_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/book/tool/print/tests/events_test.php b/mod/book/tool/print/tests/events_test.php index da071e58bb1..23c8a411bfa 100644 --- a/mod/book/tool/print/tests/events_test.php +++ b/mod/book/tool/print/tests/events_test.php @@ -36,7 +36,7 @@ global $CFG; */ class booktool_print_events_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/chat/tests/lib_test.php b/mod/chat/tests/lib_test.php index 7a864cfecb3..14cf9852bed 100644 --- a/mod/chat/tests/lib_test.php +++ b/mod/chat/tests/lib_test.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_chat_lib_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/chat/tests/privacy_test.php b/mod/chat/tests/privacy_test.php index e3b4d9b908c..12669f46b6a 100644 --- a/mod/chat/tests/privacy_test.php +++ b/mod/chat/tests/privacy_test.php @@ -47,7 +47,7 @@ require_once($CFG->dirroot . '/mod/chat/lib.php'); */ class mod_chat_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $PAGE; $this->resetAfterTest(); $PAGE->get_renderer('core'); diff --git a/mod/choice/tests/events_test.php b/mod/choice/tests/events_test.php index 41fb362ab11..c12258208b4 100644 --- a/mod/choice/tests/events_test.php +++ b/mod/choice/tests/events_test.php @@ -50,7 +50,7 @@ class mod_choice_events_testcase extends advanced_testcase { /** * Setup often used objects for the following tests. */ - protected function setup() { + protected function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/mod/choice/tests/privacy_provider_test.php b/mod/choice/tests/privacy_provider_test.php index e076cf98418..517d27bac42 100644 --- a/mod/choice/tests/privacy_provider_test.php +++ b/mod/choice/tests/privacy_provider_test.php @@ -48,7 +48,7 @@ class mod_choice_privacy_provider_testcase extends \core_privacy\tests\provider_ /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); global $DB; diff --git a/mod/data/tests/events_test.php b/mod/data/tests/events_test.php index 272d3a01aa7..9835201886f 100644 --- a/mod/data/tests/events_test.php +++ b/mod/data/tests/events_test.php @@ -34,7 +34,7 @@ class mod_data_events_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/data/tests/externallib_test.php b/mod/data/tests/externallib_test.php index c49c9be96fb..815744c5b60 100644 --- a/mod/data/tests/externallib_test.php +++ b/mod/data/tests/externallib_test.php @@ -83,7 +83,7 @@ class mod_data_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/data/tests/import_test.php b/mod/data/tests/import_test.php index ab5c826d881..aaa45572dbd 100644 --- a/mod/data/tests/import_test.php +++ b/mod/data/tests/import_test.php @@ -37,7 +37,7 @@ class mod_data_import_test extends advanced_testcase { /** * Set up function. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); global $CFG; diff --git a/mod/data/tests/lib_test.php b/mod/data/tests/lib_test.php index 84e8a7b4470..ef43165c113 100644 --- a/mod/data/tests/lib_test.php +++ b/mod/data/tests/lib_test.php @@ -45,7 +45,7 @@ class mod_data_lib_testcase extends advanced_testcase { /** * Tear Down to reset DB. */ - public function tearDown() { + public function tearDown(): void { global $DB; if (isset($this->DB)) { diff --git a/mod/data/tests/privacy_provider_test.php b/mod/data/tests/privacy_provider_test.php index 31d7c7bee80..c2b8ea39b70 100644 --- a/mod/data/tests/privacy_provider_test.php +++ b/mod/data/tests/privacy_provider_test.php @@ -52,7 +52,7 @@ class mod_data_privacy_provider_testcase extends \core_privacy\tests\provider_te /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); global $DB; diff --git a/mod/data/tests/search_test.php b/mod/data/tests/search_test.php index 8988ea67074..ceab97ed023 100644 --- a/mod/data/tests/search_test.php +++ b/mod/data/tests/search_test.php @@ -101,7 +101,7 @@ class mod_data_search_test extends advanced_testcase { * Set up function. In this instance we are setting up database * records to be used in the unit tests. */ - protected function setUp() { + protected function setUp(): void { global $DB, $CFG; parent::setUp(); diff --git a/mod/feedback/tests/events_test.php b/mod/feedback/tests/events_test.php index 4d6fe2318af..7d6382f2eb5 100644 --- a/mod/feedback/tests/events_test.php +++ b/mod/feedback/tests/events_test.php @@ -56,7 +56,7 @@ class mod_feedback_events_testcase extends advanced_testcase { /** @var stdClass value associated with $eventfeedbackitem . */ private $eventfeedbackvalue; - public function setUp() { + public function setUp(): void { global $DB; $this->setAdminUser(); diff --git a/mod/feedback/tests/external_test.php b/mod/feedback/tests/external_test.php index d920b9b84ac..8f4c715b826 100644 --- a/mod/feedback/tests/external_test.php +++ b/mod/feedback/tests/external_test.php @@ -47,7 +47,7 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/feedback/tests/privacy_test.php b/mod/feedback/tests/privacy_test.php index 248eef8d640..068a1eafb9a 100644 --- a/mod/feedback/tests/privacy_test.php +++ b/mod/feedback/tests/privacy_test.php @@ -46,7 +46,7 @@ require_once($CFG->dirroot . '/mod/feedback/lib.php'); */ class mod_feedback_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/folder/tests/events_test.php b/mod/folder/tests/events_test.php index 71723dc7e12..c14bb5331bc 100644 --- a/mod/folder/tests/events_test.php +++ b/mod/folder/tests/events_test.php @@ -30,7 +30,7 @@ class mod_folder_events_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/folder/tests/lib_test.php b/mod/folder/tests/lib_test.php index 5a42f632fcc..9ee17e68694 100644 --- a/mod/folder/tests/lib_test.php +++ b/mod/folder/tests/lib_test.php @@ -41,7 +41,7 @@ class mod_folder_lib_testcase extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } @@ -50,7 +50,7 @@ class mod_folder_lib_testcase extends advanced_testcase { * Prepares things before this test case is initialised * @return void */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/folder/lib.php'); } diff --git a/mod/folder/tests/search_test.php b/mod/folder/tests/search_test.php index 0c9f751fcb7..905f225f2a2 100644 --- a/mod/folder/tests/search_test.php +++ b/mod/folder/tests/search_test.php @@ -43,7 +43,7 @@ class mod_folder_search_testcase extends advanced_testcase { */ protected $folderareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/mod/forum/tests/builders_exported_posts_test.php b/mod/forum/tests/builders_exported_posts_test.php index a8875bb3c0b..f740ffbb81a 100644 --- a/mod/forum/tests/builders_exported_posts_test.php +++ b/mod/forum/tests/builders_exported_posts_test.php @@ -43,7 +43,7 @@ class mod_forum_builders_exported_posts_testcase extends advanced_testcase { /** * Set up function for tests. */ - public function setUp() { + public function setUp(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); @@ -55,7 +55,7 @@ class mod_forum_builders_exported_posts_testcase extends advanced_testcase { /** * Tear down function for tests. */ - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/events_test.php b/mod/forum/tests/events_test.php index bf54d50d640..01b203ae8e7 100644 --- a/mod/forum/tests/events_test.php +++ b/mod/forum/tests/events_test.php @@ -38,7 +38,7 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); @@ -46,7 +46,7 @@ class mod_forum_events_testcase extends advanced_testcase { $this->resetAfterTest(); } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/exporters_discussion_test.php b/mod/forum/tests/exporters_discussion_test.php index 7290395fc85..d31d1499a49 100644 --- a/mod/forum/tests/exporters_discussion_test.php +++ b/mod/forum/tests/exporters_discussion_test.php @@ -38,7 +38,7 @@ class mod_forum_exporters_discussion_testcase extends advanced_testcase { /** * Test set up function. */ - public function setUp() { + public function setUp(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); @@ -50,7 +50,7 @@ class mod_forum_exporters_discussion_testcase extends advanced_testcase { /** * Test tear down function. */ - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/externallib_test.php b/mod/forum/tests/externallib_test.php index 2430f272e58..ed523db9168 100644 --- a/mod/forum/tests/externallib_test.php +++ b/mod/forum/tests/externallib_test.php @@ -35,7 +35,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase { /** * Tests set up */ - protected function setUp() { + protected function setUp(): void { global $CFG; // We must clear the subscription caches. This has to be done both before each test, and after in case of other @@ -45,7 +45,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase { require_once($CFG->dirroot . '/mod/forum/externallib.php'); } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/generator_test.php b/mod/forum/tests/generator_test.php index 8a4e20fc403..0031d05a331 100644 --- a/mod/forum/tests/generator_test.php +++ b/mod/forum/tests/generator_test.php @@ -36,13 +36,13 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_forum_generator_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/lib_test.php b/mod/forum/tests/lib_test.php index 1cf30d536c8..e0635e89780 100644 --- a/mod/forum/tests/lib_test.php +++ b/mod/forum/tests/lib_test.php @@ -31,13 +31,13 @@ require_once($CFG->dirroot . '/rating/lib.php'); class mod_forum_lib_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/mail_group_test.php b/mod/forum/tests/mail_group_test.php index 904151f01cd..f7e24390d59 100644 --- a/mod/forum/tests/mail_group_test.php +++ b/mod/forum/tests/mail_group_test.php @@ -52,7 +52,7 @@ class mod_forum_mail_group_testcase extends advanced_testcase { */ protected $mailsink; - public function setUp() { + public function setUp(): void { global $CFG; // We must clear the subscription caches. This has to be done both before each test, and after in case of other @@ -72,7 +72,7 @@ class mod_forum_mail_group_testcase extends advanced_testcase { $CFG->maxeditingtime = -1; } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/mail_test.php b/mod/forum/tests/mail_test.php index 9902a29c0ec..26dc9d1554b 100644 --- a/mod/forum/tests/mail_test.php +++ b/mod/forum/tests/mail_test.php @@ -47,7 +47,7 @@ class mod_forum_mail_testcase extends advanced_testcase { */ protected $mailsink; - public function setUp() { + public function setUp(): void { global $CFG; // We must clear the subscription caches. This has to be done both before each test, and after in case of other @@ -67,7 +67,7 @@ class mod_forum_mail_testcase extends advanced_testcase { $CFG->maxeditingtime = -1; } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/maildigest_test.php b/mod/forum/tests/maildigest_test.php index efd8019c6e2..0bcae0f98ec 100644 --- a/mod/forum/tests/maildigest_test.php +++ b/mod/forum/tests/maildigest_test.php @@ -41,7 +41,7 @@ class mod_forum_maildigest_testcase extends advanced_testcase { * Set up message and mail sinks, and set up other requirements for the * cron to be tested here. */ - public function setUp() { + public function setUp(): void { global $CFG; // Messaging is not compatible with transactions... @@ -78,7 +78,7 @@ class mod_forum_maildigest_testcase extends advanced_testcase { /** * Clear the message sinks set up in this test. */ - public function tearDown() { + public function tearDown(): void { $this->messagesink->clear(); $this->messagesink->close(); diff --git a/mod/forum/tests/managers_capability_test.php b/mod/forum/tests/managers_capability_test.php index d0064df2588..a5301839d0c 100644 --- a/mod/forum/tests/managers_capability_test.php +++ b/mod/forum/tests/managers_capability_test.php @@ -81,7 +81,7 @@ class mod_forum_managers_capability_testcase extends advanced_testcase { /** * Setup function before each test. */ - public function setUp() { + public function setUp(): void { global $DB; // We must clear the subscription caches. This has to be done both before each test, and after in case of other @@ -113,7 +113,7 @@ class mod_forum_managers_capability_testcase extends advanced_testcase { /** * Tear down function after each test. */ - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/privacy_provider_test.php b/mod/forum/tests/privacy_provider_test.php index ac7ff4ed39c..047849eec13 100644 --- a/mod/forum/tests/privacy_provider_test.php +++ b/mod/forum/tests/privacy_provider_test.php @@ -56,7 +56,7 @@ class mod_forum_privacy_provider_testcase extends \core_privacy\tests\provider_t /** * Test setUp. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/mod/forum/tests/private_replies_test.php b/mod/forum/tests/private_replies_test.php index 27a47ce664b..f22cc7e34ec 100644 --- a/mod/forum/tests/private_replies_test.php +++ b/mod/forum/tests/private_replies_test.php @@ -42,7 +42,7 @@ class private_replies extends advanced_testcase { /** * Setup before tests. */ - public function setUp() { + public function setUp(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); @@ -51,7 +51,7 @@ class private_replies extends advanced_testcase { /** * Tear down after tests. */ - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/qanda_test.php b/mod/forum/tests/qanda_test.php index 3e4795250ab..2710d1bc3c7 100644 --- a/mod/forum/tests/qanda_test.php +++ b/mod/forum/tests/qanda_test.php @@ -52,7 +52,7 @@ class mod_forum_qanda_testcase extends advanced_testcase { */ protected $mailsink; - public function setUp() { + public function setUp(): void { global $CFG; // We must clear the subscription caches. This has to be done both before each test, and after in case of other @@ -72,7 +72,7 @@ class mod_forum_qanda_testcase extends advanced_testcase { $CFG->maxeditingtime = -1; } - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/search_test.php b/mod/forum/tests/search_test.php index 93095aab95e..68d33cad9f9 100644 --- a/mod/forum/tests/search_test.php +++ b/mod/forum/tests/search_test.php @@ -45,7 +45,7 @@ class mod_forum_search_testcase extends advanced_testcase { */ protected $forumpostareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/mod/forum/tests/subscriptions_test.php b/mod/forum/tests/subscriptions_test.php index df894958ce7..44595635e81 100644 --- a/mod/forum/tests/subscriptions_test.php +++ b/mod/forum/tests/subscriptions_test.php @@ -36,7 +36,7 @@ class mod_forum_subscriptions_testcase extends advanced_testcase { /** * Test setUp. */ - public function setUp() { + public function setUp(): void { global $DB; // We must clear the subscription caches. This has to be done both before each test, and after in case of other @@ -48,7 +48,7 @@ class mod_forum_subscriptions_testcase extends advanced_testcase { /** * Test tearDown. */ - public function tearDown() { + public function tearDown(): void { // We must clear the subscription caches. This has to be done both before each test, and after in case of other // tests using these functions. \mod_forum\subscriptions::reset_forum_cache(); diff --git a/mod/forum/tests/vaults_discussion_list_test.php b/mod/forum/tests/vaults_discussion_list_test.php index cac34353532..68bdabe241a 100644 --- a/mod/forum/tests/vaults_discussion_list_test.php +++ b/mod/forum/tests/vaults_discussion_list_test.php @@ -46,7 +46,7 @@ class mod_forum_vaults_discussion_list_testcase extends advanced_testcase { /** * Set up function for tests. */ - public function setUp() { + public function setUp(): void { $vaultfactory = \mod_forum\local\container::get_vault_factory(); $this->vault = $vaultfactory->get_discussions_in_forum_vault(); } diff --git a/mod/forum/tests/vaults_discussion_test.php b/mod/forum/tests/vaults_discussion_test.php index 3a575d939a0..3b27cc9f392 100644 --- a/mod/forum/tests/vaults_discussion_test.php +++ b/mod/forum/tests/vaults_discussion_test.php @@ -43,7 +43,7 @@ class mod_forum_vaults_discussion_testcase extends advanced_testcase { /** * Set up function for tests. */ - public function setUp() { + public function setUp(): void { $vaultfactory = \mod_forum\local\container::get_vault_factory(); $this->vault = $vaultfactory->get_discussion_vault(); } diff --git a/mod/forum/tests/vaults_post_test.php b/mod/forum/tests/vaults_post_test.php index de7838c0dd2..0057e6047d3 100644 --- a/mod/forum/tests/vaults_post_test.php +++ b/mod/forum/tests/vaults_post_test.php @@ -44,7 +44,7 @@ class mod_forum_vaults_post_testcase extends advanced_testcase { /** * Set up function for tests. */ - public function setUp() { + public function setUp(): void { $vaultfactory = \mod_forum\local\container::get_vault_factory(); $this->vault = $vaultfactory->get_post_vault(); } @@ -52,7 +52,7 @@ class mod_forum_vaults_post_testcase extends advanced_testcase { /** * Teardown for all tests. */ - public function tearDown() { + public function tearDown(): void { unset($this->vault); } diff --git a/mod/glossary/tests/events_test.php b/mod/glossary/tests/events_test.php index d0101555eed..2d30141ab60 100644 --- a/mod/glossary/tests/events_test.php +++ b/mod/glossary/tests/events_test.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class glossary_event_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/glossary/tests/privacy_provider_test.php b/mod/glossary/tests/privacy_provider_test.php index d763fc78ac0..6664e2f3b4b 100644 --- a/mod/glossary/tests/privacy_provider_test.php +++ b/mod/glossary/tests/privacy_provider_test.php @@ -58,7 +58,7 @@ class mod_glossary_privacy_provider_testcase extends \core_privacy\tests\provide /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(); global $DB; diff --git a/mod/glossary/tests/search_test.php b/mod/glossary/tests/search_test.php index cf8ddbe04bd..b8f7bc64d52 100644 --- a/mod/glossary/tests/search_test.php +++ b/mod/glossary/tests/search_test.php @@ -44,7 +44,7 @@ class mod_glossary_search_testcase extends advanced_testcase { */ protected $entryareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/mod/label/tests/lib_test.php b/mod/label/tests/lib_test.php index 20d581641ee..649fafd3320 100644 --- a/mod/label/tests/lib_test.php +++ b/mod/label/tests/lib_test.php @@ -39,7 +39,7 @@ class mod_label_lib_testcase extends advanced_testcase { /** * Set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } @@ -234,4 +234,4 @@ class mod_label_lib_testcase extends advanced_testcase { return calendar_event::create($event); } -} \ No newline at end of file +} diff --git a/mod/lesson/tests/events_test.php b/mod/lesson/tests/events_test.php index cbb1288b931..74526fb661b 100644 --- a/mod/lesson/tests/events_test.php +++ b/mod/lesson/tests/events_test.php @@ -42,7 +42,7 @@ class mod_lesson_events_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/lesson/tests/external_test.php b/mod/lesson/tests/external_test.php index 95246491516..a34be9b77ae 100644 --- a/mod/lesson/tests/external_test.php +++ b/mod/lesson/tests/external_test.php @@ -69,7 +69,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/lesson/tests/privacy_test.php b/mod/lesson/tests/privacy_test.php index 0cd6c23a49f..12aa9b6c5cf 100644 --- a/mod/lesson/tests/privacy_test.php +++ b/mod/lesson/tests/privacy_test.php @@ -44,7 +44,7 @@ use mod_lesson\privacy\provider; */ class mod_lesson_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $PAGE; $this->setAdminUser(); // The data generator complains without this. $this->resetAfterTest(); diff --git a/mod/lti/service/gradebookservices/tests/privacy_provider_test.php b/mod/lti/service/gradebookservices/tests/privacy_provider_test.php index d24c59c8f12..0f75ec201b3 100644 --- a/mod/lti/service/gradebookservices/tests/privacy_provider_test.php +++ b/mod/lti/service/gradebookservices/tests/privacy_provider_test.php @@ -36,7 +36,7 @@ class ltiservice_gradebookservices_privacy_provider_testcase extends provider_te /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/mod/lti/service/gradebookservices/tests/task_cleanup_test.php b/mod/lti/service/gradebookservices/tests/task_cleanup_test.php index c9ed00414b6..489aff04c6e 100644 --- a/mod/lti/service/gradebookservices/tests/task_cleanup_test.php +++ b/mod/lti/service/gradebookservices/tests/task_cleanup_test.php @@ -40,7 +40,7 @@ class ltiservice_gradebookservices_cleanup_task_testcase extends advanced_testca * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/lti/service/memberships/tests/privacy_provider_test.php b/mod/lti/service/memberships/tests/privacy_provider_test.php index a2e8d87e623..89886741771 100644 --- a/mod/lti/service/memberships/tests/privacy_provider_test.php +++ b/mod/lti/service/memberships/tests/privacy_provider_test.php @@ -36,7 +36,7 @@ class ltiservice_memberships_privacy_provider_testcase extends provider_testcase /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/mod/lti/tests/externallib_test.php b/mod/lti/tests/externallib_test.php index f56dc8330e2..f9f72f50430 100644 --- a/mod/lti/tests/externallib_test.php +++ b/mod/lti/tests/externallib_test.php @@ -45,7 +45,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/lti/tests/lib_test.php b/mod/lti/tests/lib_test.php index 564b5cff869..71d1e23fed0 100644 --- a/mod/lti/tests/lib_test.php +++ b/mod/lti/tests/lib_test.php @@ -41,7 +41,7 @@ class mod_lti_lib_testcase extends advanced_testcase { * Prepares things before this test case is initialised * @return void */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/lti/lib.php'); } diff --git a/mod/lti/tests/task_clean_access_tokens_test.php b/mod/lti/tests/task_clean_access_tokens_test.php index 5af37f08204..df063ce7f9a 100644 --- a/mod/lti/tests/task_clean_access_tokens_test.php +++ b/mod/lti/tests/task_clean_access_tokens_test.php @@ -40,7 +40,7 @@ class mod_lti_clean_access_tokens_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/page/tests/lib_test.php b/mod/page/tests/lib_test.php index e93d723f6c0..2932d159027 100644 --- a/mod/page/tests/lib_test.php +++ b/mod/page/tests/lib_test.php @@ -42,7 +42,7 @@ class mod_page_lib_testcase extends advanced_testcase { * Prepares things before this test case is initialised * @return void */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/page/lib.php'); } diff --git a/mod/quiz/accessrule/seb/tests/access_manager_test.php b/mod/quiz/accessrule/seb/tests/access_manager_test.php index eefa5b95f7b..6952ec010ce 100644 --- a/mod/quiz/accessrule/seb/tests/access_manager_test.php +++ b/mod/quiz/accessrule/seb/tests/access_manager_test.php @@ -43,7 +43,7 @@ class quizacces_seb_access_manager_testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); diff --git a/mod/quiz/accessrule/seb/tests/backup_restore_test.php b/mod/quiz/accessrule/seb/tests/backup_restore_test.php index dc01aa3faa1..049ea298d0e 100644 --- a/mod/quiz/accessrule/seb/tests/backup_restore_test.php +++ b/mod/quiz/accessrule/seb/tests/backup_restore_test.php @@ -44,7 +44,7 @@ class quizaccess_seb_backup_restore_testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { global $USER; parent::setUp(); diff --git a/mod/quiz/accessrule/seb/tests/event_test.php b/mod/quiz/accessrule/seb/tests/event_test.php index 354b310649f..ab4ef7afe99 100644 --- a/mod/quiz/accessrule/seb/tests/event_test.php +++ b/mod/quiz/accessrule/seb/tests/event_test.php @@ -40,7 +40,7 @@ class quizaccess_seb_event_testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); @@ -128,4 +128,4 @@ class quizaccess_seb_event_testcase extends advanced_testcase { $this->assertEquals($user->id, $event->userid); $this->assertEquals($template->get('id'), $event->objectid); } -} \ No newline at end of file +} diff --git a/mod/quiz/accessrule/seb/tests/link_generator_test.php b/mod/quiz/accessrule/seb/tests/link_generator_test.php index aa2091e8488..6d61979a706 100644 --- a/mod/quiz/accessrule/seb/tests/link_generator_test.php +++ b/mod/quiz/accessrule/seb/tests/link_generator_test.php @@ -38,7 +38,7 @@ class quizaccess_seb_link_generator_testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); } diff --git a/mod/quiz/accessrule/seb/tests/quiz_settings_test.php b/mod/quiz/accessrule/seb/tests/quiz_settings_test.php index d01b7e556a8..1e7c3946ec3 100644 --- a/mod/quiz/accessrule/seb/tests/quiz_settings_test.php +++ b/mod/quiz/accessrule/seb/tests/quiz_settings_test.php @@ -48,7 +48,7 @@ class quizaccess_seb_quiz_settings_testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); diff --git a/mod/quiz/accessrule/seb/tests/rule_test.php b/mod/quiz/accessrule/seb/tests/rule_test.php index a7db893d6c0..89c408e7036 100644 --- a/mod/quiz/accessrule/seb/tests/rule_test.php +++ b/mod/quiz/accessrule/seb/tests/rule_test.php @@ -42,7 +42,7 @@ class quizaccess_seb_rule__testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); @@ -84,7 +84,7 @@ class quizaccess_seb_rule__testcase extends advanced_testcase { */ public function valid_form_data_provider() : array { return [ - 'valid seb_requiresafeexambrowser' => ['seb_requiresafeexambrowser', 0], + 'valid seb_requiresafeexambrowser' => ['seb_requiresafeexambrowser', '0'], 'valid seb_linkquitseb0' => ['seb_linkquitseb', 'http://safeexambrowser.org/macosx'], 'valid seb_linkquitseb1' => ['seb_linkquitseb', 'safeexambrowser.org/macosx'], 'valid seb_linkquitseb2' => ['seb_linkquitseb', 'www.safeexambrowser.org/macosx'], diff --git a/mod/quiz/accessrule/seb/tests/template_test.php b/mod/quiz/accessrule/seb/tests/template_test.php index 9cbb5588281..0be6b6d4fa0 100644 --- a/mod/quiz/accessrule/seb/tests/template_test.php +++ b/mod/quiz/accessrule/seb/tests/template_test.php @@ -38,7 +38,7 @@ class quizaccess_seb_template_testcase extends advanced_testcase { /** * Called before every test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->resetAfterTest(); diff --git a/mod/quiz/tests/external_test.php b/mod/quiz/tests/external_test.php index 6de933da16f..0ea6a4eda6f 100644 --- a/mod/quiz/tests/external_test.php +++ b/mod/quiz/tests/external_test.php @@ -77,7 +77,7 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/quiz/tests/repaginate_test.php b/mod/quiz/tests/repaginate_test.php index f82c20cd0d1..9623b5d9bbf 100644 --- a/mod/quiz/tests/repaginate_test.php +++ b/mod/quiz/tests/repaginate_test.php @@ -68,12 +68,12 @@ class mod_quiz_repaginate_test extends advanced_testcase { /** @var mod_quiz_repaginate_testable the object being tested. */ private $repaginate = null; - public function setUp() { + public function setUp(): void { $this->set_quiz_slots($this->get_quiz_object()->get_slots()); $this->repaginate = new mod_quiz_repaginate_testable(0, $this->quizslots); } - public function tearDown() { + public function tearDown(): void { $this->repaginate = null; } diff --git a/mod/resource/tests/events_test.php b/mod/resource/tests/events_test.php index da21c0551a2..44f10c2f43e 100644 --- a/mod/resource/tests/events_test.php +++ b/mod/resource/tests/events_test.php @@ -36,7 +36,7 @@ class mod_resource_events_testcase extends advanced_testcase { /** * Setup is called before calling test case. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // Must be a non-guest user to create resources. diff --git a/mod/resource/tests/lib_test.php b/mod/resource/tests/lib_test.php index 787b815bbbf..d1de43cfca6 100644 --- a/mod/resource/tests/lib_test.php +++ b/mod/resource/tests/lib_test.php @@ -42,7 +42,7 @@ class mod_resource_lib_testcase extends advanced_testcase { * Prepares things before this test case is initialised * @return void */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/resource/lib.php'); } diff --git a/mod/resource/tests/search_test.php b/mod/resource/tests/search_test.php index c5d04dd3884..d52b96c4a19 100644 --- a/mod/resource/tests/search_test.php +++ b/mod/resource/tests/search_test.php @@ -43,7 +43,7 @@ class mod_resource_search_testcase extends advanced_testcase { */ protected $resourceareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/mod/scorm/report/basic/tests/privacy_test.php b/mod/scorm/report/basic/tests/privacy_test.php index ff06ce57658..0a57cbe1dbf 100644 --- a/mod/scorm/report/basic/tests/privacy_test.php +++ b/mod/scorm/report/basic/tests/privacy_test.php @@ -39,7 +39,7 @@ class scormreport_basic_privacy_testcase extends \core_privacy\tests\provider_te /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/mod/scorm/report/interactions/tests/privacy_test.php b/mod/scorm/report/interactions/tests/privacy_test.php index 80c63d2ce46..1e6951367bf 100644 --- a/mod/scorm/report/interactions/tests/privacy_test.php +++ b/mod/scorm/report/interactions/tests/privacy_test.php @@ -39,7 +39,7 @@ class scormreport_interactions_privacy_testcase extends \core_privacy\tests\prov /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/mod/scorm/report/objectives/tests/privacy_test.php b/mod/scorm/report/objectives/tests/privacy_test.php index 90ae77e8eb7..148598145b1 100644 --- a/mod/scorm/report/objectives/tests/privacy_test.php +++ b/mod/scorm/report/objectives/tests/privacy_test.php @@ -39,7 +39,7 @@ class scormreport_objectives_privacy_testcase extends \core_privacy\tests\provid /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/mod/scorm/tests/events_test.php b/mod/scorm/tests/events_test.php index bf44adf56bf..24e41b295a6 100644 --- a/mod/scorm/tests/events_test.php +++ b/mod/scorm/tests/events_test.php @@ -47,7 +47,7 @@ class mod_scorm_event_testcase extends advanced_testcase { /** @var stdClass store course module object */ protected $eventcm; - protected function setUp() { + protected function setUp(): void { $this->setAdminUser(); $this->eventcourse = $this->getDataGenerator()->create_course(); $this->eventuser = $this->getDataGenerator()->create_user(); diff --git a/mod/scorm/tests/externallib_test.php b/mod/scorm/tests/externallib_test.php index b6ac0fddf75..79d8f529753 100644 --- a/mod/scorm/tests/externallib_test.php +++ b/mod/scorm/tests/externallib_test.php @@ -45,7 +45,7 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB, $CFG; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/scorm/tests/lib_test.php b/mod/scorm/tests/lib_test.php index bc6971f34fe..55e3d198ab2 100644 --- a/mod/scorm/tests/lib_test.php +++ b/mod/scorm/tests/lib_test.php @@ -45,7 +45,7 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/scorm/tests/locallib_test.php b/mod/scorm/tests/locallib_test.php index f33791ed56d..ae0ebbb6f10 100644 --- a/mod/scorm/tests/locallib_test.php +++ b/mod/scorm/tests/locallib_test.php @@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/mod/scorm/lib.php'); */ class mod_scorm_locallib_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/survey/tests/events_test.php b/mod/survey/tests/events_test.php index 433b4d3f715..32020269802 100644 --- a/mod/survey/tests/events_test.php +++ b/mod/survey/tests/events_test.php @@ -36,7 +36,7 @@ class mod_survey_events_testcase extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/mod/survey/tests/externallib_test.php b/mod/survey/tests/externallib_test.php index 30de66b68ec..1a086ac8ac1 100644 --- a/mod/survey/tests/externallib_test.php +++ b/mod/survey/tests/externallib_test.php @@ -45,7 +45,7 @@ class mod_survey_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/survey/tests/lib_test.php b/mod/survey/tests/lib_test.php index 069e88d7acd..43c682a15ca 100644 --- a/mod/survey/tests/lib_test.php +++ b/mod/survey/tests/lib_test.php @@ -42,7 +42,7 @@ class mod_survey_lib_testcase extends advanced_testcase { * Prepares things before this test case is initialised * @return void */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/survey/lib.php'); } diff --git a/mod/survey/tests/privacy_test.php b/mod/survey/tests/privacy_test.php index 75ea2f2fe0a..95f887e54bd 100644 --- a/mod/survey/tests/privacy_test.php +++ b/mod/survey/tests/privacy_test.php @@ -47,7 +47,7 @@ require_once($CFG->dirroot . '/mod/survey/lib.php'); */ class mod_survey_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { global $PAGE; $this->resetAfterTest(); $PAGE->get_renderer('core'); diff --git a/mod/url/tests/lib_test.php b/mod/url/tests/lib_test.php index 50198f03e81..fb0c7f0f041 100644 --- a/mod/url/tests/lib_test.php +++ b/mod/url/tests/lib_test.php @@ -40,7 +40,7 @@ class mod_url_lib_testcase extends advanced_testcase { * Prepares things before this test case is initialised * @return void */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { global $CFG; require_once($CFG->dirroot . '/mod/url/lib.php'); require_once($CFG->dirroot . '/mod/url/locallib.php'); @@ -264,4 +264,4 @@ class mod_url_lib_testcase extends advanced_testcase { return calendar_event::create($event); } -} \ No newline at end of file +} diff --git a/mod/wiki/tests/events_test.php b/mod/wiki/tests/events_test.php index b7cf118458c..2714ab263ee 100644 --- a/mod/wiki/tests/events_test.php +++ b/mod/wiki/tests/events_test.php @@ -44,7 +44,7 @@ class mod_wiki_events_testcase extends advanced_testcase { /** * Setup test data. */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/mod/wiki/tests/externallib_test.php b/mod/wiki/tests/externallib_test.php index 522cfbe44a7..c5303cf7d4e 100644 --- a/mod/wiki/tests/externallib_test.php +++ b/mod/wiki/tests/externallib_test.php @@ -45,7 +45,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/wiki/tests/privacy_test.php b/mod/wiki/tests/privacy_test.php index b2699e46987..e28f6db1588 100644 --- a/mod/wiki/tests/privacy_test.php +++ b/mod/wiki/tests/privacy_test.php @@ -71,7 +71,7 @@ class mod_wiki_privacy_testcase extends provider_testcase { * In the export data they have paths: * $this->pagepaths[1][1], $this->pagepaths[1][2], $this->pagepaths[1][3] */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/mod/wiki/tests/search_test.php b/mod/wiki/tests/search_test.php index 9c3f9078fc6..a7d1171542c 100644 --- a/mod/wiki/tests/search_test.php +++ b/mod/wiki/tests/search_test.php @@ -43,7 +43,7 @@ class mod_wiki_search_testcase extends advanced_testcase { */ protected $wikicollabpageareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); $this->setAdminUser(); set_config('enableglobalsearch', true); diff --git a/mod/workshop/allocation/random/tests/allocator_test.php b/mod/workshop/allocation/random/tests/allocator_test.php index 9beeff1a7dd..f04fc98580e 100644 --- a/mod/workshop/allocation/random/tests/allocator_test.php +++ b/mod/workshop/allocation/random/tests/allocator_test.php @@ -39,7 +39,7 @@ class workshopallocation_random_testcase extends advanced_testcase { /** allocator instance */ protected $allocator; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); @@ -50,7 +50,7 @@ class workshopallocation_random_testcase extends advanced_testcase { $this->allocator = new testable_workshop_random_allocator($this->workshop); } - protected function tearDown() { + protected function tearDown(): void { $this->allocator = null; $this->workshop = null; parent::tearDown(); diff --git a/mod/workshop/eval/best/tests/lib_test.php b/mod/workshop/eval/best/tests/lib_test.php index a11f5bb394a..8a02ca65465 100644 --- a/mod/workshop/eval/best/tests/lib_test.php +++ b/mod/workshop/eval/best/tests/lib_test.php @@ -43,7 +43,7 @@ class workshopeval_best_evaluation_testcase extends advanced_testcase { /** * Setup testing environment */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); @@ -54,7 +54,7 @@ class workshopeval_best_evaluation_testcase extends advanced_testcase { $this->evaluator = new testable_workshop_best_evaluation($this->workshop); } - protected function tearDown() { + protected function tearDown(): void { $this->workshop = null; $this->evaluator = null; parent::tearDown(); diff --git a/mod/workshop/form/accumulative/tests/lib_test.php b/mod/workshop/form/accumulative/tests/lib_test.php index e61d73b0402..42b23e13852 100644 --- a/mod/workshop/form/accumulative/tests/lib_test.php +++ b/mod/workshop/form/accumulative/tests/lib_test.php @@ -41,7 +41,7 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase { /** * Setup testing environment */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); @@ -52,7 +52,7 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase { $this->strategy = new testable_workshop_accumulative_strategy($this->workshop); } - protected function tearDown() { + protected function tearDown(): void { $this->workshop = null; $this->strategy = null; parent::tearDown(); diff --git a/mod/workshop/form/numerrors/tests/lib_test.php b/mod/workshop/form/numerrors/tests/lib_test.php index d350b55dc8f..f11258d01fd 100644 --- a/mod/workshop/form/numerrors/tests/lib_test.php +++ b/mod/workshop/form/numerrors/tests/lib_test.php @@ -43,7 +43,7 @@ class workshopform_numerrors_strategy_testcase extends advanced_testcase { /** * Setup testing environment */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); @@ -54,7 +54,7 @@ class workshopform_numerrors_strategy_testcase extends advanced_testcase { $this->strategy = new testable_workshop_numerrors_strategy($this->workshop); } - protected function tearDown() { + protected function tearDown(): void { $this->workshop = null; $this->strategy = null; parent::tearDown(); diff --git a/mod/workshop/form/rubric/tests/lib_test.php b/mod/workshop/form/rubric/tests/lib_test.php index adb8d663b1c..a83c5de2e54 100644 --- a/mod/workshop/form/rubric/tests/lib_test.php +++ b/mod/workshop/form/rubric/tests/lib_test.php @@ -42,7 +42,7 @@ class workshopform_rubric_strategy_test extends advanced_testcase { /** * Setup testing environment */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); @@ -79,7 +79,7 @@ class workshopform_rubric_strategy_test extends advanced_testcase { } - protected function tearDown() { + protected function tearDown(): void { $this->strategy = null; $this->workshop = null; parent::tearDown(); diff --git a/mod/workshop/tests/events_test.php b/mod/workshop/tests/events_test.php index ea86df9462e..f590bef4b88 100644 --- a/mod/workshop/tests/events_test.php +++ b/mod/workshop/tests/events_test.php @@ -49,7 +49,7 @@ class mod_workshop_events_testcase extends advanced_testcase { /** * Set up the testing environment. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->setAdminUser(); @@ -60,7 +60,7 @@ class mod_workshop_events_testcase extends advanced_testcase { $this->context = context_module::instance($this->cm->id); } - protected function tearDown() { + protected function tearDown(): void { $this->workshop = null; $this->course = null; $this->cm = null; diff --git a/mod/workshop/tests/external_test.php b/mod/workshop/tests/external_test.php index 1338a51e167..7b5940c35e8 100644 --- a/mod/workshop/tests/external_test.php +++ b/mod/workshop/tests/external_test.php @@ -65,7 +65,7 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/mod/workshop/tests/locallib_test.php b/mod/workshop/tests/locallib_test.php index a81ea0f8b1f..0e12a86c73e 100644 --- a/mod/workshop/tests/locallib_test.php +++ b/mod/workshop/tests/locallib_test.php @@ -42,7 +42,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase { protected $workshop; /** setup testing environment */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->setAdminUser(); $this->course = $this->getDataGenerator()->create_course(); @@ -51,7 +51,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase { $this->workshop = new testable_workshop($workshop, $cm, $this->course); } - protected function tearDown() { + protected function tearDown(): void { $this->workshop = null; parent::tearDown(); } diff --git a/mod/workshop/tests/portfolio_caller_test.php b/mod/workshop/tests/portfolio_caller_test.php index f93805e014c..958694bfbb6 100644 --- a/mod/workshop/tests/portfolio_caller_test.php +++ b/mod/workshop/tests/portfolio_caller_test.php @@ -47,7 +47,7 @@ class mod_workshop_porfolio_caller_testcase extends advanced_testcase { /** * Setup testing environment. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); @@ -59,7 +59,7 @@ class mod_workshop_porfolio_caller_testcase extends advanced_testcase { /** * Tear down. */ - protected function tearDown() { + protected function tearDown(): void { $this->workshop = null; $this->cm = null; parent::tearDown(); diff --git a/mod/workshop/tests/privacy_provider_test.php b/mod/workshop/tests/privacy_provider_test.php index a59388deea8..7a093845aa8 100644 --- a/mod/workshop/tests/privacy_provider_test.php +++ b/mod/workshop/tests/privacy_provider_test.php @@ -120,7 +120,7 @@ class mod_workshop_privacy_provider_testcase extends advanced_testcase { * * etc. */ - protected function setUp() { + protected function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/my/tests/events_test.php b/my/tests/events_test.php index 3fe006a23f6..f5d0a37475b 100644 --- a/my/tests/events_test.php +++ b/my/tests/events_test.php @@ -40,7 +40,7 @@ class dashboard_events_testcase extends advanced_testcase { /** * Setup often used objects for the following tests. */ - protected function setup() { + protected function setUp(): void { global $USER; $this->resetAfterTest(); diff --git a/notes/tests/events_test.php b/notes/tests/events_test.php index 02d5dbe7034..655fb28e5f3 100644 --- a/notes/tests/events_test.php +++ b/notes/tests/events_test.php @@ -41,7 +41,7 @@ class core_notes_events_testcase extends advanced_testcase { /** @var stdClass A complete record from post table */ private $noterecord; - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/notes/tests/lib_test.php b/notes/tests/lib_test.php index 69b0001967b..db21796e16b 100644 --- a/notes/tests/lib_test.php +++ b/notes/tests/lib_test.php @@ -50,7 +50,7 @@ class core_notes_lib_testcase extends advanced_testcase { */ private $tree; - public function setUp() { + public function setUp(): void { $this->user = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); @@ -114,4 +114,4 @@ class core_notes_lib_testcase extends advanced_testcase { $nodes->setAccessible(true); $this->assertArrayNotHasKey('notes', $nodes->getValue($this->tree)); } -} \ No newline at end of file +} diff --git a/privacy/classes/tests/provider_testcase.php b/privacy/classes/tests/provider_testcase.php index 92b30b51621..c4405041a79 100644 --- a/privacy/classes/tests/provider_testcase.php +++ b/privacy/classes/tests/provider_testcase.php @@ -39,7 +39,7 @@ abstract class provider_testcase extends \advanced_testcase { /** * Test tearDown. */ - public function tearDown() { + public function tearDown(): void { \core_privacy\local\request\writer::reset(); } diff --git a/privacy/tests/manager_test.php b/privacy/tests/manager_test.php index eb1a0551df7..d395091baf0 100644 --- a/privacy/tests/manager_test.php +++ b/privacy/tests/manager_test.php @@ -45,7 +45,7 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test tearDown. */ - public function tearDown() { + public function tearDown(): void { \core_privacy\local\request\writer::reset(); } diff --git a/privacy/tests/writer_test.php b/privacy/tests/writer_test.php index be8bb465cca..47960afd270 100644 --- a/privacy/tests/writer_test.php +++ b/privacy/tests/writer_test.php @@ -45,7 +45,7 @@ class writer_test extends advanced_testcase { * Ensure that the writer is cleared away as appropriate after each * test. */ - public function tearDown() { + public function tearDown(): void { writer::reset(); } diff --git a/question/behaviour/adaptive/tests/behaviourtype_test.php b/question/behaviour/adaptive/tests/behaviourtype_test.php index 58cd548ec39..82951113920 100644 --- a/question/behaviour/adaptive/tests/behaviourtype_test.php +++ b/question/behaviour/adaptive/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_adaptive_type_test extends basic_testcase { /** @var qbehaviour_adaptive_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('adaptive'); } diff --git a/question/behaviour/adaptive/tests/mark_display_test.php b/question/behaviour/adaptive/tests/mark_display_test.php index 5a91a25bb95..f8d7fedcd46 100644 --- a/question/behaviour/adaptive/tests/mark_display_test.php +++ b/question/behaviour/adaptive/tests/mark_display_test.php @@ -44,7 +44,7 @@ class qbehaviour_adaptive_mark_display_test extends basic_testcase { /** @var question_display_options display options to use when rendering. */ protected $options; - protected function setUp() { + protected function setUp(): void { global $PAGE; parent::setUp(); $this->renderer = $PAGE->get_renderer('qbehaviour_adaptive'); diff --git a/question/behaviour/deferredcbm/tests/behaviourtype_test.php b/question/behaviour/deferredcbm/tests/behaviourtype_test.php index a4892e6247e..5fdff4959b3 100644 --- a/question/behaviour/deferredcbm/tests/behaviourtype_test.php +++ b/question/behaviour/deferredcbm/tests/behaviourtype_test.php @@ -43,7 +43,7 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base /** @var qbehaviour_deferredcbm_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('deferredcbm'); } diff --git a/question/behaviour/deferredfeedback/tests/behaviourtype_test.php b/question/behaviour/deferredfeedback/tests/behaviourtype_test.php index 3bedc80fd53..9bb1eff7927 100644 --- a/question/behaviour/deferredfeedback/tests/behaviourtype_test.php +++ b/question/behaviour/deferredfeedback/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_deferredfeedback_type_test extends qbehaviour_walkthrough_test_ /** @var qbehaviour_deferredfeedback_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('deferredfeedback'); } diff --git a/question/behaviour/immediatecbm/tests/behaviourtype_test.php b/question/behaviour/immediatecbm/tests/behaviourtype_test.php index 8c137599f9e..6c4ca9ee2bd 100644 --- a/question/behaviour/immediatecbm/tests/behaviourtype_test.php +++ b/question/behaviour/immediatecbm/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_immediatecbm_type_test extends qbehaviour_walkthrough_test_base /** @var qbehaviour_immediatecbm_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('immediatecbm'); } diff --git a/question/behaviour/immediatefeedback/tests/behaviourtype_test.php b/question/behaviour/immediatefeedback/tests/behaviourtype_test.php index 2d9b5cafdeb..354dccd4b44 100644 --- a/question/behaviour/immediatefeedback/tests/behaviourtype_test.php +++ b/question/behaviour/immediatefeedback/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_immediatefeedback_type_test extends basic_testcase { /** @var qbehaviour_immediatefeedback_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('immediatefeedback'); } diff --git a/question/behaviour/informationitem/tests/behaviourtype_test.php b/question/behaviour/informationitem/tests/behaviourtype_test.php index e8f56cca71e..35c9e7d1fa5 100644 --- a/question/behaviour/informationitem/tests/behaviourtype_test.php +++ b/question/behaviour/informationitem/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_informationitem_type_testcase extends basic_testcase { /** @var qbehaviour_informationitem_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('informationitem'); } diff --git a/question/behaviour/interactive/tests/behaviourtype_test.php b/question/behaviour/interactive/tests/behaviourtype_test.php index 36af6bb734c..7f4eab7a957 100644 --- a/question/behaviour/interactive/tests/behaviourtype_test.php +++ b/question/behaviour/interactive/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_interactive_type_test extends basic_testcase { /** @var qbehaviour_interactive_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('interactive'); } diff --git a/question/behaviour/interactivecountback/tests/behaviourtype_test.php b/question/behaviour/interactivecountback/tests/behaviourtype_test.php index 0ce525310a6..ed5f20e1f32 100644 --- a/question/behaviour/interactivecountback/tests/behaviourtype_test.php +++ b/question/behaviour/interactivecountback/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_interactivecountback_type_test extends basic_testcase { /** @var qbehaviour_interactivecountback_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('interactivecountback'); } diff --git a/question/behaviour/manualgraded/tests/behaviourtype_test.php b/question/behaviour/manualgraded/tests/behaviourtype_test.php index b0a987b0f55..0ba9aff5946 100644 --- a/question/behaviour/manualgraded/tests/behaviourtype_test.php +++ b/question/behaviour/manualgraded/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_manualgraded_type_test extends basic_testcase { /** @var qbehaviour_manualgraded_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('manualgraded'); } diff --git a/question/behaviour/missing/tests/behaviourtype_test.php b/question/behaviour/missing/tests/behaviourtype_test.php index 3fd52145207..34d092f5418 100644 --- a/question/behaviour/missing/tests/behaviourtype_test.php +++ b/question/behaviour/missing/tests/behaviourtype_test.php @@ -42,7 +42,7 @@ class qbehaviour_missing_type_test extends basic_testcase { /** @var qbehaviour_missing_type */ protected $behaviourtype; - public function setUp() { + public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('missing'); } diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index 13d48b93fff..df59c5eec3d 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -796,7 +796,7 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase { */ protected $currentoutput = ''; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); @@ -805,7 +805,7 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase { context_system::instance()); } - protected function tearDown() { + protected function tearDown(): void { $this->displayoptions = null; $this->quba = null; parent::tearDown(); diff --git a/question/engine/tests/questionattempt_test.php b/question/engine/tests/questionattempt_test.php index 7047a41a0a2..6ef1436fd35 100644 --- a/question/engine/tests/questionattempt_test.php +++ b/question/engine/tests/questionattempt_test.php @@ -50,14 +50,14 @@ class question_attempt_testcase extends advanced_testcase { /** @var question_attempt a question attempt that can be used in the tests. */ private $qa; - protected function setUp() { + protected function setUp(): void { $this->question = test_question_maker::make_question('description'); $this->question->defaultmark = 3; $this->usageid = 13; $this->qa = new question_attempt($this->question, $this->usageid); } - protected function tearDown() { + protected function tearDown(): void { $this->question = null; $this->useageid = null; $this->qa = null; diff --git a/question/engine/tests/questionattempt_with_steps_test.php b/question/engine/tests/questionattempt_with_steps_test.php index b5194c008ac..7849943591f 100644 --- a/question/engine/tests/questionattempt_with_steps_test.php +++ b/question/engine/tests/questionattempt_with_steps_test.php @@ -44,7 +44,7 @@ class question_attempt_with_steps_test extends advanced_testcase { private $question; private $qa; - protected function setUp() { + protected function setUp(): void { $this->question = test_question_maker::make_question('description'); $this->qa = new testable_question_attempt($this->question, 0, null, 2); for ($i = 0; $i < 3; $i++) { @@ -53,7 +53,7 @@ class question_attempt_with_steps_test extends advanced_testcase { } } - protected function tearDown() { + protected function tearDown(): void { $this->qa = null; } diff --git a/question/engine/tests/questionattemptiterator_test.php b/question/engine/tests/questionattemptiterator_test.php index 81f20cab8e0..5453567e3b1 100644 --- a/question/engine/tests/questionattemptiterator_test.php +++ b/question/engine/tests/questionattemptiterator_test.php @@ -42,7 +42,7 @@ class question_attempt_iterator_test extends advanced_testcase { private $qas = array(); private $iterator; - protected function setUp() { + protected function setUp(): void { $this->quba = question_engine::make_questions_usage_by_activity('unit_test', context_system::instance()); $this->quba->set_preferred_behaviour('deferredfeedback'); @@ -56,7 +56,7 @@ class question_attempt_iterator_test extends advanced_testcase { $this->iterator = $this->quba->get_attempt_iterator(); } - protected function tearDown() { + protected function tearDown(): void { $this->quba = null; $this->iterator = null; } @@ -122,4 +122,4 @@ class question_attempt_iterator_test extends advanced_testcase { public function test_cannot_unset() { unset($this->iterator[2]); } -} \ No newline at end of file +} diff --git a/question/engine/tests/questionattemptstepiterator_test.php b/question/engine/tests/questionattemptstepiterator_test.php index 9d90654b65a..543282c6db3 100644 --- a/question/engine/tests/questionattemptstepiterator_test.php +++ b/question/engine/tests/questionattemptstepiterator_test.php @@ -41,7 +41,7 @@ class question_attempt_step_iterator_test extends advanced_testcase { private $qa; private $iterator; - protected function setUp() { + protected function setUp(): void { $question = test_question_maker::make_question('description'); $this->qa = new testable_question_attempt($question, 0); for ($i = 0; $i < 3; $i++) { @@ -51,7 +51,7 @@ class question_attempt_step_iterator_test extends advanced_testcase { $this->iterator = $this->qa->get_step_iterator(); } - protected function tearDown() { + protected function tearDown(): void { $this->qa = null; $this->iterator = null; } @@ -141,4 +141,4 @@ class question_attempt_step_iterator_test extends advanced_testcase { public function test_cannot_unset() { unset($this->iterator[2]); } -} \ No newline at end of file +} diff --git a/question/engine/tests/questionusage_autosave_test.php b/question/engine/tests/questionusage_autosave_test.php index 6ca87f43ad8..a5d9f977293 100644 --- a/question/engine/tests/questionusage_autosave_test.php +++ b/question/engine/tests/questionusage_autosave_test.php @@ -747,7 +747,7 @@ class question_usage_autosave_test extends qbehaviour_walkthrough_test_base { $this->delete_quba(); } - protected function tearDown() { + protected function tearDown(): void { // This test relies on the destructor for the second DB connection being called before running the next test. // Without this change - there will be unit test failures on "some" DBs (MySQL). gc_collect_cycles(); diff --git a/question/engine/tests/unitofwork_test.php b/question/engine/tests/unitofwork_test.php index 3756dc594e5..af86f114e42 100644 --- a/question/engine/tests/unitofwork_test.php +++ b/question/engine/tests/unitofwork_test.php @@ -47,7 +47,7 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base { /** @var testable_question_engine_unit_of_work the unit of work we are testing. */ protected $observer; - protected function setUp() { + protected function setUp(): void { // Create a usage in an initial state, with one shortanswer question added, // and attempted in interactive mode submitted responses 'toad' then 'frog'. // Then set it to use a new unit of work for any subsequent changes. @@ -64,7 +64,7 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base { $this->setup_initial_test_state($this->get_test_data()); } - public function tearDown() { + public function tearDown(): void { question_bank::end_unit_test(); } diff --git a/question/engine/upgrade/tests/helper.php b/question/engine/upgrade/tests/helper.php index b7614dbec04..7967ae2b324 100644 --- a/question/engine/upgrade/tests/helper.php +++ b/question/engine/upgrade/tests/helper.php @@ -97,14 +97,14 @@ abstract class question_attempt_upgrader_test_base extends advanced_testcase { protected $updater; protected $loader; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $logger = new dummy_question_engine_assumption_logger(); $this->loader = new test_question_engine_upgrade_question_loader($logger); $this->updater = new test_question_engine_attempt_upgrader($this->loader, $logger); } - protected function tearDown() { + protected function tearDown(): void { $this->updater = null; parent::tearDown(); } diff --git a/question/tests/category_class_test.php b/question/tests/category_class_test.php index 4bfaf200950..adbe41cea3a 100644 --- a/question/tests/category_class_test.php +++ b/question/tests/category_class_test.php @@ -46,7 +46,7 @@ class core_question_category_class_testcase extends advanced_testcase { */ protected $topcat; - protected function setUp() { + protected function setUp(): void { parent::setUp(); self::setAdminUser(); $this->resetAfterTest(); diff --git a/question/tests/events_test.php b/question/tests/events_test.php index 0f93b8605f9..bc03892bad5 100644 --- a/question/tests/events_test.php +++ b/question/tests/events_test.php @@ -34,7 +34,7 @@ class core_question_events_testcase extends advanced_testcase { /** * Tests set up. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/question/tests/externallib_test.php b/question/tests/externallib_test.php index 523198ec2dc..2315ae2afd6 100644 --- a/question/tests/externallib_test.php +++ b/question/tests/externallib_test.php @@ -45,7 +45,7 @@ class core_question_external_testcase extends externallib_advanced_testcase { /** * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/question/type/calculated/tests/questiontype_test.php b/question/type/calculated/tests/questiontype_test.php index 1292760e43c..46fcb70c31a 100644 --- a/question/type/calculated/tests/questiontype_test.php +++ b/question/type/calculated/tests/questiontype_test.php @@ -45,11 +45,11 @@ class qtype_calculated_test extends advanced_testcase { protected $tolerance = 0.00000001; protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_calculated(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/calculatedsimple/tests/questiontype_test.php b/question/type/calculatedsimple/tests/questiontype_test.php index 3f4ca511eed..35483c6732a 100644 --- a/question/type/calculatedsimple/tests/questiontype_test.php +++ b/question/type/calculatedsimple/tests/questiontype_test.php @@ -48,11 +48,11 @@ class qtype_calculatedsimple_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_calculatedsimple(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/ddimageortext/tests/questiontype_test.php b/question/type/ddimageortext/tests/questiontype_test.php index 0c36e33b858..8b6fbf52b36 100644 --- a/question/type/ddimageortext/tests/questiontype_test.php +++ b/question/type/ddimageortext/tests/questiontype_test.php @@ -40,11 +40,11 @@ class qtype_ddimageortext_test extends basic_testcase { /** @var qtype_ddimageortext instance of the question type class to test. */ protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = question_bank::get_qtype('ddimageortext');; } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/ddmarker/tests/questiontype_test.php b/question/type/ddmarker/tests/questiontype_test.php index 8bd3692113e..664577c21ac 100644 --- a/question/type/ddmarker/tests/questiontype_test.php +++ b/question/type/ddmarker/tests/questiontype_test.php @@ -41,11 +41,11 @@ class qtype_ddmarker_test extends advanced_testcase { /** @var qtype_ddmarker instance of the question type class to test. */ protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = question_bank::get_qtype('ddmarker');; } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/ddwtos/tests/questiontype_test.php b/question/type/ddwtos/tests/questiontype_test.php index ca7f562f0bd..2f650ca0b25 100644 --- a/question/type/ddwtos/tests/questiontype_test.php +++ b/question/type/ddwtos/tests/questiontype_test.php @@ -40,11 +40,11 @@ class qtype_ddwtos_test extends question_testcase { /** @var qtype_ddwtos instance of the question type class to test. */ protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = question_bank::get_qtype('ddwtos');; } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/description/tests/questiontype_test.php b/question/type/description/tests/questiontype_test.php index 60da13ef1c8..b2444800cee 100644 --- a/question/type/description/tests/questiontype_test.php +++ b/question/type/description/tests/questiontype_test.php @@ -41,11 +41,11 @@ require_once($CFG->dirroot . '/question/type/description/edit_description_form.p class qtype_description_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_description(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/essay/tests/questiontype_test.php b/question/type/essay/tests/questiontype_test.php index 1a34c3ab0e9..3dc8767bed6 100644 --- a/question/type/essay/tests/questiontype_test.php +++ b/question/type/essay/tests/questiontype_test.php @@ -39,11 +39,11 @@ require_once($CFG->dirroot . '/question/type/essay/questiontype.php'); class qtype_essay_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_essay(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/gapselect/tests/questiontype_test.php b/question/type/gapselect/tests/questiontype_test.php index 88ccadf28af..6598983ead6 100644 --- a/question/type/gapselect/tests/questiontype_test.php +++ b/question/type/gapselect/tests/questiontype_test.php @@ -39,11 +39,11 @@ class qtype_gapselect_test extends question_testcase { /** @var qtype_gapselect instance of the question type class to test. */ protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = question_bank::get_qtype('gapselect'); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/match/tests/questiontype_test.php b/question/type/match/tests/questiontype_test.php index baaf44daa21..0da8cacb219 100644 --- a/question/type/match/tests/questiontype_test.php +++ b/question/type/match/tests/questiontype_test.php @@ -42,11 +42,11 @@ class qtype_match_test extends advanced_testcase { /** @var qtype_match instance of the question type class to test. */ protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_match(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/multianswer/tests/questiontype_test.php b/question/type/multianswer/tests/questiontype_test.php index 22616347453..eb8e6071d4b 100644 --- a/question/type/multianswer/tests/questiontype_test.php +++ b/question/type/multianswer/tests/questiontype_test.php @@ -43,11 +43,11 @@ class qtype_multianswer_test extends advanced_testcase { /** @var qtype_multianswer instance of the question type class to test. */ protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_multianswer(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/multichoice/tests/questiontype_test.php b/question/type/multichoice/tests/questiontype_test.php index 4c9f1980f6c..c18ead0627c 100644 --- a/question/type/multichoice/tests/questiontype_test.php +++ b/question/type/multichoice/tests/questiontype_test.php @@ -40,11 +40,11 @@ require_once($CFG->dirroot . '/question/type/multichoice/edit_multichoice_form.p class qtype_multichoice_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_multichoice(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/numerical/tests/questiontype_test.php b/question/type/numerical/tests/questiontype_test.php index 90a087e0f22..9a39cde39f4 100644 --- a/question/type/numerical/tests/questiontype_test.php +++ b/question/type/numerical/tests/questiontype_test.php @@ -47,11 +47,11 @@ class qtype_numerical_test extends advanced_testcase { protected $tolerance = 0.00000001; protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_numerical(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/random/tests/questiontype_test.php b/question/type/random/tests/questiontype_test.php index 289966fdc15..38a38d29f61 100644 --- a/question/type/random/tests/questiontype_test.php +++ b/question/type/random/tests/questiontype_test.php @@ -40,11 +40,11 @@ require_once($CFG->dirroot . '/question/type/random/questiontype.php'); class qtype_random_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_random(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/shortanswer/tests/questiontype_test.php b/question/type/shortanswer/tests/questiontype_test.php index 2bfa9a90a82..71ec1fe72fb 100644 --- a/question/type/shortanswer/tests/questiontype_test.php +++ b/question/type/shortanswer/tests/questiontype_test.php @@ -45,11 +45,11 @@ class qtype_shortanswer_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_shortanswer(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/question/type/tests/question_first_matching_answer_grading_strategy_test.php b/question/type/tests/question_first_matching_answer_grading_strategy_test.php index 569d5f24a9a..5f1967f6e7b 100644 --- a/question/type/tests/question_first_matching_answer_grading_strategy_test.php +++ b/question/type/tests/question_first_matching_answer_grading_strategy_test.php @@ -58,10 +58,10 @@ class test_response_answer_comparer implements question_response_answer_comparer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_first_matching_answer_grading_strategy_testcase extends advanced_testcase { - protected function setUp() { + protected function setUp(): void { } - protected function tearDown() { + protected function tearDown(): void { } public function test_no_answers_gives_null() { diff --git a/question/type/truefalse/tests/questiontype_test.php b/question/type/truefalse/tests/questiontype_test.php index 5f1a639f872..1408a443cc6 100644 --- a/question/type/truefalse/tests/questiontype_test.php +++ b/question/type/truefalse/tests/questiontype_test.php @@ -41,11 +41,11 @@ require_once($CFG->dirroot . '/question/type/truefalse/edit_truefalse_form.php') class qtype_truefalse_test extends advanced_testcase { protected $qtype; - protected function setUp() { + protected function setUp(): void { $this->qtype = new qtype_truefalse(); } - protected function tearDown() { + protected function tearDown(): void { $this->qtype = null; } diff --git a/rating/tests/externallib_test.php b/rating/tests/externallib_test.php index 1468d59e93c..4ffed3b5780 100644 --- a/rating/tests/externallib_test.php +++ b/rating/tests/externallib_test.php @@ -43,7 +43,7 @@ class core_rating_externallib_testcase extends externallib_advanced_testcase { /* * Set up for every test */ - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); diff --git a/rating/tests/rating_test.php b/rating/tests/rating_test.php index c066978da57..896a8bfcc4c 100644 --- a/rating/tests/rating_test.php +++ b/rating/tests/rating_test.php @@ -39,7 +39,7 @@ class core_rating_testcase extends advanced_testcase { protected $neededcaps = array('view', 'viewall', 'viewany', 'rate'); protected $originaldefaultfrontpageroleid; - public function setUp() { + public function setUp(): void { global $CFG; parent::setUp(); diff --git a/report/completion/tests/events_test.php b/report/completion/tests/events_test.php index a2b2dac43da..b18bd5ca748 100644 --- a/report/completion/tests/events_test.php +++ b/report/completion/tests/events_test.php @@ -38,7 +38,7 @@ class report_completion_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/report/log/tests/events_test.php b/report/log/tests/events_test.php index 0426838aa18..67b36ac202e 100644 --- a/report/log/tests/events_test.php +++ b/report/log/tests/events_test.php @@ -38,7 +38,7 @@ class report_log_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/report/log/tests/lib_test.php b/report/log/tests/lib_test.php index d35bc04c792..4ba92c1f0c0 100644 --- a/report/log/tests/lib_test.php +++ b/report/log/tests/lib_test.php @@ -50,7 +50,7 @@ class report_log_lib_testcase extends advanced_testcase { */ private $tree; - public function setUp() { + public function setUp(): void { $this->user = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); diff --git a/report/loglive/tests/events_test.php b/report/loglive/tests/events_test.php index df95829007e..a5dd4676665 100644 --- a/report/loglive/tests/events_test.php +++ b/report/loglive/tests/events_test.php @@ -38,7 +38,7 @@ class report_loglive_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/report/outline/tests/lib_test.php b/report/outline/tests/lib_test.php index fa9f20811f0..4d7bb49e1d1 100644 --- a/report/outline/tests/lib_test.php +++ b/report/outline/tests/lib_test.php @@ -60,7 +60,7 @@ class report_outline_lib_testcase extends advanced_testcase { */ private $roleid; - public function setUp() { + public function setUp(): void { $this->user = $this->getDataGenerator()->create_user(); $this->user2 = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); diff --git a/report/questioninstances/tests/events_test.php b/report/questioninstances/tests/events_test.php index f002176c5b0..53288e10140 100644 --- a/report/questioninstances/tests/events_test.php +++ b/report/questioninstances/tests/events_test.php @@ -36,7 +36,7 @@ class report_questioninstances_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/report/stats/tests/events_test.php b/report/stats/tests/events_test.php index 74bd64b54ef..564dded59ae 100644 --- a/report/stats/tests/events_test.php +++ b/report/stats/tests/events_test.php @@ -38,7 +38,7 @@ class report_stats_events_testcase extends advanced_testcase { /** * Setup testcase. */ - public function setUp() { + public function setUp(): void { $this->setAdminUser(); $this->resetAfterTest(); } diff --git a/report/stats/tests/lib_test.php b/report/stats/tests/lib_test.php index cd935ecdb76..a4df67695cb 100644 --- a/report/stats/tests/lib_test.php +++ b/report/stats/tests/lib_test.php @@ -48,7 +48,7 @@ class report_stats_lib_testcase extends advanced_testcase { */ private $tree; - public function setUp() { + public function setUp(): void { $this->user = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); diff --git a/report/usersessions/tests/lib_test.php b/report/usersessions/tests/lib_test.php index 6bade9193b7..03ea06bb5df 100644 --- a/report/usersessions/tests/lib_test.php +++ b/report/usersessions/tests/lib_test.php @@ -52,7 +52,7 @@ class report_usersessions_lib_testcase extends advanced_testcase { */ private $tree; - public function setUp() { + public function setUp(): void { $this->user = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); diff --git a/repository/flickr/tests/privacy_test.php b/repository/flickr/tests/privacy_test.php index c86476be86b..71d1bba2648 100644 --- a/repository/flickr/tests/privacy_test.php +++ b/repository/flickr/tests/privacy_test.php @@ -38,7 +38,7 @@ class repository_flickr_privacy_testcase extends provider_testcase { /** * Overriding setUp() function to always reset after tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/repository/nextcloud/tests/access_controlled_link_manager_test.php b/repository/nextcloud/tests/access_controlled_link_manager_test.php index 178adefd762..78a98cf049a 100644 --- a/repository/nextcloud/tests/access_controlled_link_manager_test.php +++ b/repository/nextcloud/tests/access_controlled_link_manager_test.php @@ -53,7 +53,7 @@ class repository_nextcloud_access_controlled_link_manager_testcase extends advan /** * SetUp to create an repository instance. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); // Admin is necessary to create issuer object. @@ -630,4 +630,4 @@ XML; } } -} \ No newline at end of file +} diff --git a/repository/nextcloud/tests/lib_test.php b/repository/nextcloud/tests/lib_test.php index c8f3ec36c74..cf6fe64f5a1 100644 --- a/repository/nextcloud/tests/lib_test.php +++ b/repository/nextcloud/tests/lib_test.php @@ -45,7 +45,7 @@ class repository_nextcloud_lib_testcase extends advanced_testcase { /** * SetUp to create an repository instance. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); // Admin is neccessary to create api and issuer objects. diff --git a/repository/nextcloud/tests/ocs_test.php b/repository/nextcloud/tests/ocs_test.php index a96691b8953..a22747ce1e8 100644 --- a/repository/nextcloud/tests/ocs_test.php +++ b/repository/nextcloud/tests/ocs_test.php @@ -40,7 +40,7 @@ class repository_nextcloud_ocs_testcase extends advanced_testcase { /** * SetUp to create issuer and endpoints for OCS testing. */ - protected function setUp() { + protected function setUp(): void { $this->resetAfterTest(true); // Admin is neccessary to create issuer object. diff --git a/repository/onedrive/tests/privacy_test.php b/repository/onedrive/tests/privacy_test.php index afd258938b9..fd39f1e68b2 100644 --- a/repository/onedrive/tests/privacy_test.php +++ b/repository/onedrive/tests/privacy_test.php @@ -38,7 +38,7 @@ class repository_onedrive_privacy_testcase extends \core_privacy\tests\provider_ /** * Overriding setUp() function to always reset after tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/repository/recent/tests/lib_test.php b/repository/recent/tests/lib_test.php index 080999b2eae..66160d4294d 100644 --- a/repository/recent/tests/lib_test.php +++ b/repository/recent/tests/lib_test.php @@ -49,7 +49,7 @@ class repository_recent_lib_testcase extends advanced_testcase { /** * SetUp to create an repository instance. */ - protected function setUp() { + protected function setUp(): void { global $USER; $this->setAdminUser(); $this->usercontext = context_user::instance($USER->id); diff --git a/repository/tests/privacy_test.php b/repository/tests/privacy_test.php index 736d55187f2..9340baecace 100644 --- a/repository/tests/privacy_test.php +++ b/repository/tests/privacy_test.php @@ -41,7 +41,7 @@ class core_repository_privacy_testcase extends \core_privacy\tests\provider_test /** * Overriding setUp() function to always reset after tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/rss/tests/privacy_test.php b/rss/tests/privacy_test.php index 070b2abffbd..c49c24e202f 100644 --- a/rss/tests/privacy_test.php +++ b/rss/tests/privacy_test.php @@ -40,7 +40,7 @@ class core_rss_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/search/engine/simpledb/tests/engine_test.php b/search/engine/simpledb/tests/engine_test.php index 5ec0a699fdd..7c51dab6714 100644 --- a/search/engine/simpledb/tests/engine_test.php +++ b/search/engine/simpledb/tests/engine_test.php @@ -59,7 +59,7 @@ class search_simpledb_engine_testcase extends advanced_testcase { * * @return void */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); if ($this->requires_manual_index_update()) { @@ -86,7 +86,7 @@ class search_simpledb_engine_testcase extends advanced_testcase { * * @return void */ - public function tearDown() { + public function tearDown(): void { // For unit tests before PHP 7, teardown is called even on skip. So only do our teardown if we did setup. if ($this->generator) { // Moodle DML freaks out if we don't teardown the temp table after each run. diff --git a/search/engine/simpledb/tests/privacy_test.php b/search/engine/simpledb/tests/privacy_test.php index f88830c6501..23b1d31059a 100644 --- a/search/engine/simpledb/tests/privacy_test.php +++ b/search/engine/simpledb/tests/privacy_test.php @@ -41,7 +41,7 @@ require_once($CFG->dirroot . '/search/tests/fixtures/mock_search_area.php'); */ class privacy_model_testcase extends \core_privacy\tests\provider_testcase { - public function setUp() { + public function setUp(): void { global $DB; if ($this->requires_manual_index_update()) { @@ -103,7 +103,7 @@ class privacy_model_testcase extends \core_privacy\tests\provider_testcase { * * @return void */ - public function tearDown() { + public function tearDown(): void { // Call parent tearDown() first. parent::tearDown(); diff --git a/search/engine/solr/tests/engine_test.php b/search/engine/solr/tests/engine_test.php index 0acc303b3be..8c9f4917d79 100644 --- a/search/engine/solr/tests/engine_test.php +++ b/search/engine/solr/tests/engine_test.php @@ -68,7 +68,7 @@ class search_solr_engine_testcase extends advanced_testcase { */ protected $engine = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); set_config('enableglobalsearch', true); set_config('searchengine', 'solr'); @@ -136,7 +136,7 @@ class search_solr_engine_testcase extends advanced_testcase { $schema->setup(false); } - public function tearDown() { + public function tearDown(): void { // For unit tests before PHP 7, teardown is called even on skip. So only do our teardown if we did setup. if ($this->generator) { // Moodle DML freaks out if we don't teardown the temp table after each run. diff --git a/search/tests/base_activity_test.php b/search/tests/base_activity_test.php index 8f99a292d28..c58719911be 100644 --- a/search/tests/base_activity_test.php +++ b/search/tests/base_activity_test.php @@ -57,7 +57,7 @@ class search_base_activity_testcase extends advanced_testcase { /** @var stdClass[] Array of test forum objects */ protected $forums; - public function setUp() { + public function setUp(): void { global $DB; $this->resetAfterTest(); set_config('enableglobalsearch', true); @@ -102,7 +102,7 @@ class search_base_activity_testcase extends advanced_testcase { } } - public function tearDown() { + public function tearDown(): void { // For unit tests before PHP 7, teardown is called even on skip. So only do our teardown if we did setup. if ($this->generator) { // Moodle DML freaks out if we don't teardown the temp table after each run. diff --git a/search/tests/base_test.php b/search/tests/base_test.php index f55ac434964..f0a2ff17786 100644 --- a/search/tests/base_test.php +++ b/search/tests/base_test.php @@ -51,7 +51,7 @@ class search_base_testcase extends advanced_testcase { */ protected $engine = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); set_config('enableglobalsearch', true); @@ -62,7 +62,7 @@ class search_base_testcase extends advanced_testcase { $this->generator->setup(); } - public function tearDown() { + public function tearDown(): void { // For unit tests before PHP 7, teardown is called even on skip. So only do our teardown if we did setup. if ($this->generator) { // Moodle DML freaks out if we don't teardown the temp table after each run. diff --git a/search/tests/document_test.php b/search/tests/document_test.php index d74a2aab592..c60acba18e4 100644 --- a/search/tests/document_test.php +++ b/search/tests/document_test.php @@ -43,7 +43,7 @@ class search_document_testcase extends advanced_testcase { */ protected $generator = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); set_config('enableglobalsearch', true); @@ -119,7 +119,7 @@ class search_document_testcase extends advanced_testcase { $this->assertEquals($docicon, $document->get_doc_icon()); } - public function tearDown() { + public function tearDown(): void { // For unit tests before PHP 7, teardown is called even on skip. So only do our teardown if we did setup. if ($this->generator) { // Moodle DML freaks out if we don't teardown the temp table after each run. diff --git a/search/tests/engine_test.php b/search/tests/engine_test.php index 4fdba57f5a5..4ccd556a14a 100644 --- a/search/tests/engine_test.php +++ b/search/tests/engine_test.php @@ -38,7 +38,7 @@ require_once(__DIR__ . '/fixtures/mock_search_area.php'); */ class search_engine_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); set_config('enableglobalsearch', true); diff --git a/search/tests/external_test.php b/search/tests/external_test.php index fd4fc411b38..8f0a51401d9 100644 --- a/search/tests/external_test.php +++ b/search/tests/external_test.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class external_testcase extends \advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/search/tests/generator/lib.php b/search/tests/generator/lib.php index 562232e1f99..e042e28c775 100644 --- a/search/tests/generator/lib.php +++ b/search/tests/generator/lib.php @@ -37,7 +37,7 @@ class core_search_generator extends component_generator_base { /** * Creates the mock search area temp table. */ - public function setup() { + public function setUp(): void { global $DB; $dbman = $DB->get_manager(); @@ -56,7 +56,7 @@ class core_search_generator extends component_generator_base { /** * Destroys the mock search area temp table. */ - public function teardown() { + public function tearDown(): void { global $DB; $dbman = $DB->get_manager(); diff --git a/search/tests/manager_test.php b/search/tests/manager_test.php index 4cc4162b74c..27ed476adbb 100644 --- a/search/tests/manager_test.php +++ b/search/tests/manager_test.php @@ -53,12 +53,12 @@ class search_manager_testcase extends advanced_testcase { */ protected $coursesareaid = null; - public function setUp() { + public function setUp(): void { $this->forumpostareaid = \core_search\manager::generate_areaid('mod_forum', 'post'); $this->coursesareaid = \core_search\manager::generate_areaid('core_course', 'course'); } - protected function tearDown() { + protected function tearDown(): void { // Stop it from faking time in the search manager (if set by test). testable_core_search::fake_current_time(); parent::tearDown(); diff --git a/tag/tests/events_test.php b/tag/tests/events_test.php index 6c15e829d38..00e4d01d986 100644 --- a/tag/tests/events_test.php +++ b/tag/tests/events_test.php @@ -38,7 +38,7 @@ class core_tag_events_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/tag/tests/taglib_test.php b/tag/tests/taglib_test.php index 2fe96fafd73..28c62f9b7cb 100644 --- a/tag/tests/taglib_test.php +++ b/tag/tests/taglib_test.php @@ -34,7 +34,7 @@ class core_tag_taglib_testcase extends advanced_testcase { * * This is executed before running any test in this file. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/user/profile/field/checkbox/tests/privacy_test.php b/user/profile/field/checkbox/tests/privacy_test.php index a1a3d1f5b09..9f4862e84bb 100644 --- a/user/profile/field/checkbox/tests/privacy_test.php +++ b/user/profile/field/checkbox/tests/privacy_test.php @@ -39,7 +39,7 @@ class profilefield_checkbox_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/user/profile/field/datetime/tests/privacy_test.php b/user/profile/field/datetime/tests/privacy_test.php index ce789d29ecc..d18026e044a 100644 --- a/user/profile/field/datetime/tests/privacy_test.php +++ b/user/profile/field/datetime/tests/privacy_test.php @@ -39,7 +39,7 @@ class profilefield_datetime_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/user/profile/field/menu/tests/privacy_test.php b/user/profile/field/menu/tests/privacy_test.php index 208eab214d0..ff399ebb7d6 100644 --- a/user/profile/field/menu/tests/privacy_test.php +++ b/user/profile/field/menu/tests/privacy_test.php @@ -39,7 +39,7 @@ class profilefield_menu_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/user/profile/field/text/tests/privacy_test.php b/user/profile/field/text/tests/privacy_test.php index 57e3f3461f8..a5c35d5ff1c 100644 --- a/user/profile/field/text/tests/privacy_test.php +++ b/user/profile/field/text/tests/privacy_test.php @@ -39,7 +39,7 @@ class profilefield_text_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/user/profile/field/textarea/tests/privacy_test.php b/user/profile/field/textarea/tests/privacy_test.php index 52347f43964..5ed8bb49b61 100644 --- a/user/profile/field/textarea/tests/privacy_test.php +++ b/user/profile/field/textarea/tests/privacy_test.php @@ -39,7 +39,7 @@ class profilefield_textarea_testcase extends provider_testcase { /** * Basic setup for these tests. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); } diff --git a/user/tests/search_test.php b/user/tests/search_test.php index 710681d5fd8..0cf7d23b0d9 100644 --- a/user/tests/search_test.php +++ b/user/tests/search_test.php @@ -41,7 +41,7 @@ class user_search_testcase extends advanced_testcase { */ protected $userareaid = null; - public function setUp() { + public function setUp(): void { $this->resetAfterTest(true); set_config('enableglobalsearch', true); diff --git a/webservice/tests/events_test.php b/webservice/tests/events_test.php index 955d49b1fcf..467340a7271 100644 --- a/webservice/tests/events_test.php +++ b/webservice/tests/events_test.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class core_webservice_events_testcase extends advanced_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/webservice/tests/externallib_test.php b/webservice/tests/externallib_test.php index fe56e750563..1fe5fcc0eb8 100644 --- a/webservice/tests/externallib_test.php +++ b/webservice/tests/externallib_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php'); */ class core_webservice_externallib_testcase extends externallib_advanced_testcase { - public function setUp() { + public function setUp(): void { // Calling parent is good, always parent::setUp(); diff --git a/webservice/tests/lib_test.php b/webservice/tests/lib_test.php index 59d741c7415..407556b0dda 100644 --- a/webservice/tests/lib_test.php +++ b/webservice/tests/lib_test.php @@ -40,7 +40,7 @@ class webservice_test extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { // Calling parent is good, always. parent::setUp(); diff --git a/webservice/tests/privacy_test.php b/webservice/tests/privacy_test.php index d7b4da0ec00..d18f18fef40 100644 --- a/webservice/tests/privacy_test.php +++ b/webservice/tests/privacy_test.php @@ -47,7 +47,7 @@ require_once($CFG->dirroot . '/webservice/lib.php'); */ class core_webservice_privacy_testcase extends provider_testcase { - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); } diff --git a/webservice/xmlrpc/tests/lib_test.php b/webservice/xmlrpc/tests/lib_test.php index c97c36f1076..32862a77d63 100644 --- a/webservice/xmlrpc/tests/lib_test.php +++ b/webservice/xmlrpc/tests/lib_test.php @@ -41,7 +41,7 @@ class webservice_xmlrpc_test extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { $this->resetAfterTest(); // All tests require xmlrpc. Skip tests, if xmlrpc is not installed. diff --git a/webservice/xmlrpc/tests/locallib_test.php b/webservice/xmlrpc/tests/locallib_test.php index ad99cbed8eb..54371da1ae8 100644 --- a/webservice/xmlrpc/tests/locallib_test.php +++ b/webservice/xmlrpc/tests/locallib_test.php @@ -41,7 +41,7 @@ class webservice_xmlrpc_locallib_testcase extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { if (!function_exists('xmlrpc_decode')) { $this->markTestSkipped('XMLRPC is not installed.'); } diff --git a/webservice/xmlrpc/tests/xmlrpc_server_test.php b/webservice/xmlrpc/tests/xmlrpc_server_test.php index a4f6feaa740..1641266b0b1 100644 --- a/webservice/xmlrpc/tests/xmlrpc_server_test.php +++ b/webservice/xmlrpc/tests/xmlrpc_server_test.php @@ -41,7 +41,7 @@ class xmlrpc_server_test extends advanced_testcase { /** * Setup. */ - public function setUp() { + public function setUp(): void { if (!function_exists('xmlrpc_decode')) { $this->markTestSkipped('XMLRPC is not installed.'); } From 80be8d2204631e5907deff98fa0f825ccbc0983c Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 2 Aug 2020 10:50:59 +0200 Subject: [PATCH 03/15] MDL-67673 phpunit: phpunit_constraint_object_is_equal_with_exceptions Constraints are now declared final, so we cannot extend them anymore. Hence, instead of extending PHPUnit\Framework\Constraint\IsEqual we are just wrapping it into our constraint. --- ...straint_object_is_equal_with_exceptions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php b/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php index 5fa1d25d4eb..b4685750d4b 100644 --- a/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php +++ b/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php @@ -32,7 +32,7 @@ * @copyright 2015 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framework\Constraint\IsEqual { +class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framework\Constraint\Constraint { /** * @var array $keys The list of exceptions. @@ -44,12 +44,17 @@ class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framewo */ protected $capturedvalue; + /** + * @var \PHPUnit\Framework\Constraint\IsEqual $isequal original constraint to be used internally. + */ + protected $isequal; + /** * Override constructor to capture value */ public function __construct($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false) { - parent::__construct($value, $delta, $maxDepth, $canonicalize, $ignoreCase); + $this->isequal = new \PHPUnit\Framework\Constraint\IsEqual($value, $delta, $maxDepth, $canonicalize, $ignoreCase); $this->capturedvalue = $value; } @@ -93,8 +98,13 @@ class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framewo } } - // Run the parent evaluation (isEqual). - return parent::evaluate($other, $description, $shouldreturnesult); + // Run the IsEqual evaluation. + return $this->isequal->evaluate($other, $description, $shouldreturnesult); + } + + // \PHPUnit\Framework\Constraint\IsEqual wrapping. + public function toString(): string { + return $this->isequal->toString(); } } From f94195c3200ff1dff22b698f6a3782b8503eca59 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 2 Aug 2020 13:08:42 +0200 Subject: [PATCH 04/15] MDL-67673 phpunit: Remove deprecated assertInternalType() While this is not strictly required, because removal will happen in PHPUnit 9.0, we are already getting rid of all uses in core. From release notes:https://phpunit.de/announcements/phpunit-8.html assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(), assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(), assertIsResource(), assertIsString(), assertIsScalar(), assertIsCallable(), or assertIsIterable() instead. --- .../installaddon/tests/installer_test.php | 2 +- admin/tool/log/tests/manager_test.php | 14 +++--- admin/tool/usertours/tests/cache_test.php | 8 +-- analytics/tests/model_test.php | 2 +- badges/tests/badgeslib_test.php | 2 +- cache/tests/administration_helper_test.php | 16 +++--- cache/tests/cache_test.php | 30 +++++------ cache/tests/config_writer_test.php | 2 +- cache/tests/fixtures/stores.php | 8 +-- course/tests/courselib_test.php | 18 +++---- course/tests/management_helper_test.php | 50 +++++++++---------- files/tests/conversion_test.php | 2 +- iplookup/tests/geoip_test.php | 16 +++--- lib/dml/tests/dml_test.php | 24 ++++----- lib/form/tests/external_test.php | 4 +- lib/form/tests/filetypes_util_test.php | 4 +- lib/phpunit/tests/advanced_test.php | 8 +-- lib/tests/accesslib_test.php | 10 ++-- lib/tests/jquery_test.php | 2 +- lib/tests/moodlelib_test.php | 20 ++++---- lib/tests/plugin_manager_test.php | 6 +-- lib/tests/scheduled_task_test.php | 10 ++-- lib/tests/update_checker_test.php | 10 ++-- lib/tests/update_code_manager_test.php | 6 +-- lib/tests/update_validator_test.php | 4 +- mod/forum/tests/subscriptions_test.php | 8 +-- mod/wiki/tests/externallib_test.php | 8 +-- privacy/tests/manager_test.php | 2 +- privacy/tests/provider_test.php | 16 +++--- privacy/tests/request_transform_test.php | 4 +- .../tests/formula_validation_test.php | 2 +- repository/tests/repositorylib_test.php | 2 +- user/tests/userlib_test.php | 4 +- 33 files changed, 162 insertions(+), 162 deletions(-) diff --git a/admin/tool/installaddon/tests/installer_test.php b/admin/tool/installaddon/tests/installer_test.php index 55a06086650..cff9578831f 100644 --- a/admin/tool/installaddon/tests/installer_test.php +++ b/admin/tool/installaddon/tests/installer_test.php @@ -44,7 +44,7 @@ class tool_installaddon_installer_testcase extends advanced_testcase { $this->assertEquals(1, preg_match('~^site=(.+)$~', $query, $matches)); $site = rawurldecode($matches[1]); $site = json_decode(base64_decode($site), true); - $this->assertInternalType('array', $site); + $this->assertIsArray($site); $this->assertEquals(3, count($site)); $this->assertSame('Nasty site', $site['fullname']); $this->assertSame('file:///etc/passwd', $site['url']); diff --git a/admin/tool/log/tests/manager_test.php b/admin/tool/log/tests/manager_test.php index e9e31648d42..1cd1a92dd18 100644 --- a/admin/tool/log/tests/manager_test.php +++ b/admin/tool/log/tests/manager_test.php @@ -33,7 +33,7 @@ class tool_log_manager_testcase extends advanced_testcase { $this->assertInstanceOf('core\log\manager', $manager); $stores = $manager->get_readers(); - $this->assertInternalType('array', $stores); + $this->assertIsArray($stores); $this->assertCount(0, $stores); $this->assertFileExists("$CFG->dirroot/$CFG->admin/tool/log/store/standard/version.php"); @@ -44,27 +44,27 @@ class tool_log_manager_testcase extends advanced_testcase { $this->assertInstanceOf('core\log\manager', $manager); $stores = $manager->get_readers(); - $this->assertInternalType('array', $stores); + $this->assertIsArray($stores); $this->assertCount(2, $stores); foreach ($stores as $key => $store) { - $this->assertInternalType('string', $key); + $this->assertIsString($key); $this->assertInstanceOf('core\log\sql_reader', $store); } $stores = $manager->get_readers('core\log\sql_internal_table_reader'); - $this->assertInternalType('array', $stores); + $this->assertIsArray($stores); $this->assertCount(1, $stores); foreach ($stores as $key => $store) { - $this->assertInternalType('string', $key); + $this->assertIsString($key); $this->assertSame('logstore_standard', $key); $this->assertInstanceOf('core\log\sql_internal_table_reader', $store); } $stores = $manager->get_readers('core\log\sql_reader'); - $this->assertInternalType('array', $stores); + $this->assertIsArray($stores); $this->assertCount(2, $stores); foreach ($stores as $key => $store) { - $this->assertInternalType('string', $key); + $this->assertIsString($key); $this->assertInstanceOf('core\log\sql_reader', $store); } } diff --git a/admin/tool/usertours/tests/cache_test.php b/admin/tool/usertours/tests/cache_test.php index 4e0c2b12911..557e0755e29 100644 --- a/admin/tool/usertours/tests/cache_test.php +++ b/admin/tool/usertours/tests/cache_test.php @@ -248,7 +248,7 @@ class cache_testcase extends advanced_testcase { $tour = $this->helper_create_tour((object)['enabled' => false]); $data = \tool_usertours\cache::get_stepdata($tour->get_id()); - $this->assertInternalType('array', $data); + $this->assertIsArray($data); $this->assertEmpty($data); } @@ -265,11 +265,11 @@ class cache_testcase extends advanced_testcase { $tour2 = $this->helper_create_tour((object)['enabled' => false]); $data = \tool_usertours\cache::get_stepdata($tour1->get_id()); - $this->assertInternalType('array', $data); + $this->assertIsArray($data); $this->assertCount(3, $data); $data = \tool_usertours\cache::get_stepdata($tour2->get_id()); - $this->assertInternalType('array', $data); + $this->assertIsArray($data); $this->assertEmpty($data); } @@ -292,7 +292,7 @@ class cache_testcase extends advanced_testcase { $steps[0]->set_sortorder(10)->persist(); $data = \tool_usertours\cache::get_stepdata($tour->get_id()); - $this->assertInternalType('array', $data); + $this->assertIsArray($data); $this->assertCount(4, $data); // Re-order the steps. diff --git a/analytics/tests/model_test.php b/analytics/tests/model_test.php index a1004fb563f..c4a5c5cdfaf 100644 --- a/analytics/tests/model_test.php +++ b/analytics/tests/model_test.php @@ -424,7 +424,7 @@ class analytics_model_testcase extends advanced_testcase { $modeldata = $method->invoke($modelconfig); $this->assertArrayHasKey('core', $modeldata->dependencies); - $this->assertInternalType('float', $modeldata->dependencies['core']); + $this->assertIsFloat($modeldata->dependencies['core']); $this->assertNotEmpty($modeldata->target); $this->assertNotEmpty($modeldata->timesplitting); $this->assertCount(3, $modeldata->indicators); diff --git a/badges/tests/badgeslib_test.php b/badges/tests/badgeslib_test.php index 0dac8de0348..4c5c05930a4 100644 --- a/badges/tests/badgeslib_test.php +++ b/badges/tests/badgeslib_test.php @@ -385,7 +385,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase { // Make sure the first user has no badges. $result = badges_get_user_badges($user1->id); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(0, $result); // Check that the second user has the expected 11 badges. diff --git a/cache/tests/administration_helper_test.php b/cache/tests/administration_helper_test.php index b392114fb51..39418717000 100644 --- a/cache/tests/administration_helper_test.php +++ b/cache/tests/administration_helper_test.php @@ -74,7 +74,7 @@ class core_cache_administration_helper_testcase extends advanced_testcase { ))); $storesummaries = core_cache\administration_helper::get_store_instance_summaries(); - $this->assertInternalType('array', $storesummaries); + $this->assertIsArray($storesummaries); $this->assertArrayHasKey('summariesstore', $storesummaries); $summary = $storesummaries['summariesstore']; // Check the keys @@ -100,7 +100,7 @@ class core_cache_administration_helper_testcase extends advanced_testcase { $this->assertEquals($mappingcount, $summary['mappings']); $definitionsummaries = core_cache\administration_helper::get_definition_summaries(); - $this->assertInternalType('array', $definitionsummaries); + $this->assertIsArray($definitionsummaries); $this->assertArrayHasKey('core/eventinvalidation', $definitionsummaries); $summary = $definitionsummaries['core/eventinvalidation']; // Check the keys @@ -116,11 +116,11 @@ class core_cache_administration_helper_testcase extends advanced_testcase { $this->assertEquals(cache_store::MODE_APPLICATION, $summary['mode']); $this->assertEquals('core', $summary['component']); $this->assertEquals('eventinvalidation', $summary['area']); - $this->assertInternalType('array', $summary['mappings']); + $this->assertIsArray($summary['mappings']); $this->assertContains('summariesstore', $summary['mappings']); $pluginsummaries = core_cache\administration_helper::get_store_plugin_summaries(); - $this->assertInternalType('array', $pluginsummaries); + $this->assertIsArray($pluginsummaries); $this->assertArrayHasKey('file', $pluginsummaries); $summary = $pluginsummaries['file']; // Check the keys @@ -132,18 +132,18 @@ class core_cache_administration_helper_testcase extends advanced_testcase { $this->assertArrayHasKey('canaddinstance', $summary); $locksummaries = core_cache\administration_helper::get_lock_summaries(); - $this->assertInternalType('array', $locksummaries); + $this->assertIsArray($locksummaries); $this->assertTrue(count($locksummaries) > 0); $mappings = core_cache\administration_helper::get_default_mode_stores(); - $this->assertInternalType('array', $mappings); + $this->assertIsArray($mappings); $this->assertCount(3, $mappings); $this->assertArrayHasKey(cache_store::MODE_APPLICATION, $mappings); - $this->assertInternalType('array', $mappings[cache_store::MODE_APPLICATION]); + $this->assertIsArray($mappings[cache_store::MODE_APPLICATION]); $this->assertContains('summariesstore', $mappings[cache_store::MODE_APPLICATION]); $potentials = core_cache\administration_helper::get_definition_store_options('core', 'eventinvalidation'); - $this->assertInternalType('array', $potentials); // Currently used, suitable, default + $this->assertIsArray($potentials); // Currently used, suitable, default $this->assertCount(3, $potentials); $this->assertArrayHasKey('summariesstore', $potentials[0]); $this->assertArrayHasKey('summariesstore', $potentials[1]); diff --git a/cache/tests/cache_test.php b/cache/tests/cache_test.php index ffbb1dfd53e..7d9c52f934a 100644 --- a/cache/tests/cache_test.php +++ b/cache/tests/cache_test.php @@ -122,7 +122,7 @@ class core_cache_testcase extends advanced_testcase { $this->assertCount(3, $stores); foreach ($stores as $name => $store) { // Check its an array. - $this->assertInternalType('array', $store); + $this->assertIsArray($store); // Check the name is the key. $this->assertEquals($name, $store['name']); // Check that it has been declared default. @@ -370,11 +370,11 @@ class core_cache_testcase extends advanced_testcase { 'key1' => array(1, 2, 3), 'key2' => array(3, 2, 1), )); - $this->assertInternalType('array', $cache->get('key1')); - $this->assertInternalType('array', $cache->get('key2')); + $this->assertIsArray($cache->get('key1')); + $this->assertIsArray($cache->get('key2')); $this->assertCount(3, $cache->get('key1')); $this->assertCount(3, $cache->get('key2')); - $this->assertInternalType('array', $cache->get_many(array('key1', 'key2'))); + $this->assertIsArray($cache->get_many(array('key1', 'key2'))); $this->assertCount(2, $cache->get_many(array('key1', 'key2'))); $this->assertEquals(2, $cache->delete_many(array('key1', 'key2'))); @@ -539,7 +539,7 @@ class core_cache_testcase extends advanced_testcase { $this->assertTrue($cache->purge()); $this->assertTrue($cache->set('b', 'B')); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -675,7 +675,7 @@ class core_cache_testcase extends advanced_testcase { // Test with multiple keys. $this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -686,7 +686,7 @@ class core_cache_testcase extends advanced_testcase { // Test with multiple keys including missing ones. $result = $cache->get_many(array('a', 'c', 'e')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('c', $result); @@ -724,7 +724,7 @@ class core_cache_testcase extends advanced_testcase { // Test with multiple keys. $this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -735,7 +735,7 @@ class core_cache_testcase extends advanced_testcase { // Test with multiple keys including missing ones. $result = $cache->get_many(array('a', 'c', 'e')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('c', $result); @@ -773,7 +773,7 @@ class core_cache_testcase extends advanced_testcase { // Test with multiple keys. $this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -784,7 +784,7 @@ class core_cache_testcase extends advanced_testcase { // Test with multiple keys including missing ones. $result = $cache->get_many(array('a', 'c', 'e')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('c', $result); @@ -1401,7 +1401,7 @@ class core_cache_testcase extends advanced_testcase { // Test the many commands. $this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -1412,7 +1412,7 @@ class core_cache_testcase extends advanced_testcase { $this->assertEquals($result, $cache->get_many(array('a', 'b', 'c'))); $this->assertEquals(2, $cache->delete_many(array('a', 'c'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -1470,7 +1470,7 @@ class core_cache_testcase extends advanced_testcase { // Test the many commands. $this->assertEquals(3, $cache->set_many(array('a' => 'A', 'b' => 'B', 'c' => 'C'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); @@ -1481,7 +1481,7 @@ class core_cache_testcase extends advanced_testcase { $this->assertEquals($result, $cache->get_many(array('a', 'b', 'c'))); $this->assertEquals(2, $cache->delete_many(array('a', 'c'))); $result = $cache->get_many(array('a', 'b', 'c')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(3, $result); $this->assertArrayHasKey('a', $result); $this->assertArrayHasKey('b', $result); diff --git a/cache/tests/config_writer_test.php b/cache/tests/config_writer_test.php index 8fa28d737c7..a88aa10b7c3 100644 --- a/cache/tests/config_writer_test.php +++ b/cache/tests/config_writer_test.php @@ -270,7 +270,7 @@ class core_cache_config_writer_testcase extends advanced_testcase { $config = cache_config_writer::instance(); $this->assertTrue($config->add_store_instance('setdefinitiontest', 'file')); - $this->assertInternalType('array', $config->get_definition_by_id('phpunit/testdefinition')); + $this->assertIsArray($config->get_definition_by_id('phpunit/testdefinition')); $config->set_definition_mappings('phpunit/testdefinition', array('setdefinitiontest', 'default_application')); try { diff --git a/cache/tests/fixtures/stores.php b/cache/tests/fixtures/stores.php index b266f4e1d69..36329c4ab62 100644 --- a/cache/tests/fixtures/stores.php +++ b/cache/tests/fixtures/stores.php @@ -131,16 +131,16 @@ abstract class cachestore_tests extends advanced_testcase { // Test get with an int. $this->assertSame(1, $instance->get('test1')); - $this->assertInternalType('int', $instance->get('test1')); + $this->assertIsInt($instance->get('test1')); $this->assertSame(2, $instance->get('test2')); - $this->assertInternalType('int', $instance->get('test2')); + $this->assertIsInt($instance->get('test2')); // Test set with a bool. $this->assertTrue($instance->set('test1', true)); // Test get with an bool. $this->assertSame(true, $instance->get('test1')); - $this->assertInternalType('boolean', $instance->get('test1')); + $this->assertIsBool($instance->get('test1')); // Test with an object. $this->assertTrue($instance->set('obj', $object)); @@ -177,7 +177,7 @@ abstract class cachestore_tests extends advanced_testcase { // Test get_many. $result = $instance->get_many(array('many1', 'many3', 'many5', 'many6')); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertCount(4, $result); $this->assertSame(array( 'many1' => 'many1', diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php index 8f00f155602..3ba00bd80fc 100644 --- a/course/tests/courselib_test.php +++ b/course/tests/courselib_test.php @@ -2807,7 +2807,7 @@ class core_course_courselib_testcase extends advanced_testcase { $caps = course_capability_assignment::allow('moodle/category:manage', $roleid, $context->id); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2815,7 +2815,7 @@ class core_course_courselib_testcase extends advanced_testcase { // Test moving down. $this->assertTrue(course_change_sortorder_after_course($course1->id, $course3->id)); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2823,7 +2823,7 @@ class core_course_courselib_testcase extends advanced_testcase { // Test moving up. $this->assertTrue(course_change_sortorder_after_course($course1->id, $course2->id)); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course1->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2831,7 +2831,7 @@ class core_course_courselib_testcase extends advanced_testcase { // Test moving to the top. $this->assertTrue(course_change_sortorder_after_course($course1->id, 0)); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2878,7 +2878,7 @@ class core_course_courselib_testcase extends advanced_testcase { $course1 = $generator->create_course(array('category' => $category->id)); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2887,7 +2887,7 @@ class core_course_courselib_testcase extends advanced_testcase { $course1 = get_course($course1->id); $this->assertTrue(course_change_sortorder_by_one($course1, false)); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course1->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2896,7 +2896,7 @@ class core_course_courselib_testcase extends advanced_testcase { $course1 = get_course($course1->id); $this->assertTrue(course_change_sortorder_by_one($course1, true)); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2906,7 +2906,7 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertFalse(course_change_sortorder_by_one($course1, true)); // Check nothing changed. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -2916,7 +2916,7 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertFalse(course_change_sortorder_by_one($course3, false)); // Check nothing changed. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); diff --git a/course/tests/management_helper_test.php b/course/tests/management_helper_test.php index 2af8193582f..ea3c2c25206 100644 --- a/course/tests/management_helper_test.php +++ b/course/tests/management_helper_test.php @@ -681,14 +681,14 @@ class core_course_management_helper_test extends advanced_testcase { // Check that sort order in the DB matches what we've got in the cache. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); // Resort by fullname. \core_course\management\helper::action_category_resort_courses($category, 'fullname'); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course3->id, $course1->id, $course2->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -696,7 +696,7 @@ class core_course_management_helper_test extends advanced_testcase { // Resort by shortname. \core_course\management\helper::action_category_resort_courses($category, 'shortname'); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course3->id, $course2->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -704,7 +704,7 @@ class core_course_management_helper_test extends advanced_testcase { // Resort by idnumber. \core_course\management\helper::action_category_resort_courses($category, 'idnumber'); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course3->id, $course2->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -716,7 +716,7 @@ class core_course_management_helper_test extends advanced_testcase { } catch (coding_exception $exception) { // Test things are as they were before. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course3->id, $course2->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -729,7 +729,7 @@ class core_course_management_helper_test extends advanced_testcase { } catch (coding_exception $exception) { // Test things are as they were before. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course3->id, $course2->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -749,7 +749,7 @@ class core_course_management_helper_test extends advanced_testcase { $this->assertEquals('core_course_category::can_resort', $exception->debuginfo); // Test things are as they were before. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course3->id, $course2->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -776,14 +776,14 @@ class core_course_management_helper_test extends advanced_testcase { $caps = course_capability_assignment::allow(self::CATEGORY_MANAGE, $roleid, $syscontext->id); $categories = $parent->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $dbcategories = $DB->get_records('course_categories', array('parent' => $parent->id), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); // Test sorting by name. \core_course\management\helper::action_category_resort_subcategories($parent, 'name'); $categories = $parent->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $this->assertEquals(array($cat3->id, $cat2->id, $cat1->id), array_keys($categories)); $dbcategories = $DB->get_records('course_categories', array('parent' => $parent->id), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); @@ -791,7 +791,7 @@ class core_course_management_helper_test extends advanced_testcase { // Test sorting by idnumber. \core_course\management\helper::action_category_resort_subcategories($parent, 'idnumber'); $categories = $parent->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $this->assertEquals(array($cat1->id, $cat3->id, $cat2->id), array_keys($categories)); $dbcategories = $DB->get_records('course_categories', array('parent' => $parent->id), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); @@ -803,7 +803,7 @@ class core_course_management_helper_test extends advanced_testcase { } catch (coding_exception $exception) { // Check that nothing was changed. $categories = $parent->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $this->assertEquals(array($cat1->id, $cat3->id, $cat2->id), array_keys($categories)); $dbcategories = $DB->get_records('course_categories', array('parent' => $parent->id), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); @@ -816,7 +816,7 @@ class core_course_management_helper_test extends advanced_testcase { } catch (coding_exception $exception) { // Check that nothing was changed. $categories = $parent->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $this->assertEquals(array($cat1->id, $cat3->id, $cat2->id), array_keys($categories)); $dbcategories = $DB->get_records('course_categories', array('parent' => $parent->id), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); @@ -826,7 +826,7 @@ class core_course_management_helper_test extends advanced_testcase { $topcat = core_course_category::get(0); \core_course\management\helper::action_category_resort_subcategories($topcat, 'name'); $categories = $topcat->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $dbcategories = $DB->get_records('course_categories', array('parent' => '0'), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); @@ -844,7 +844,7 @@ class core_course_management_helper_test extends advanced_testcase { $this->assertEquals('core_course_category::can_resort', $exception->debuginfo); // Test things are as they were before. $categories = $parent->get_children(); - $this->assertInternalType('array', $categories); + $this->assertIsArray($categories); $this->assertEquals(array($cat1->id, $cat3->id, $cat2->id), array_keys($categories)); $dbcategories = $DB->get_records('course_categories', array('parent' => $parent->id), 'sortorder'); $this->assertEquals(array_keys($dbcategories), array_keys($categories)); @@ -1001,7 +1001,7 @@ class core_course_management_helper_test extends advanced_testcase { $caps = course_capability_assignment::allow(self::CATEGORY_MANAGE, $roleid, $context->id); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1012,7 +1012,7 @@ class core_course_management_helper_test extends advanced_testcase { new core_course_list_element(get_course($course1->id)), $category) ); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course1->id, $course3->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1023,7 +1023,7 @@ class core_course_management_helper_test extends advanced_testcase { new core_course_list_element(get_course($course3->id)), $category) ); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1033,7 +1033,7 @@ class core_course_management_helper_test extends advanced_testcase { \core_course\management\helper::action_course_change_sortorder_down_one_by_record(get_course($course2->id), $category) ); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course3->id, $course2->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1043,7 +1043,7 @@ class core_course_management_helper_test extends advanced_testcase { \core_course\management\helper::action_course_change_sortorder_up_one_by_record(get_course($course2->id), $category) ); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1054,7 +1054,7 @@ class core_course_management_helper_test extends advanced_testcase { new core_course_list_element(get_course($course1->id)), $category) ); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1065,7 +1065,7 @@ class core_course_management_helper_test extends advanced_testcase { new core_course_list_element(get_course($course2->id)), $category) ); $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1082,7 +1082,7 @@ class core_course_management_helper_test extends advanced_testcase { } catch (moodle_exception $exception) { // Check nothing has changed. $courses = $category->get_courses(); - $this->assertInternalType('array', $courses); + $this->assertIsArray($courses); $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses)); $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id'); $this->assertEquals(array_keys($dbcourses), array_keys($courses)); @@ -1111,7 +1111,7 @@ class core_course_management_helper_test extends advanced_testcase { ), $roleid, $context->id); $actions = \core_course\management\helper::get_category_listitem_actions($category); - $this->assertInternalType('array', $actions); + $this->assertIsArray($actions); $this->assertArrayHasKey('edit', $actions); $this->assertArrayHasKey('hide', $actions); $this->assertArrayHasKey('show', $actions); @@ -1147,7 +1147,7 @@ class core_course_management_helper_test extends advanced_testcase { ), $roleid, $context->id); $actions = \core_course\management\helper::get_course_detail_actions(new core_course_list_element($course)); - $this->assertInternalType('array', $actions); + $this->assertIsArray($actions); $this->assertArrayHasKey('view', $actions); $this->assertArrayHasKey('edit', $actions); $this->assertArrayHasKey('enrolledusers', $actions); @@ -1181,7 +1181,7 @@ class core_course_management_helper_test extends advanced_testcase { ), $roleid, $context->id); $details = \core_course\management\helper::get_course_detail_array(new core_course_list_element($course)); - $this->assertInternalType('array', $details); + $this->assertIsArray($details); $this->assertArrayHasKey('format', $details); $this->assertArrayHasKey('fullname', $details); $this->assertArrayHasKey('shortname', $details); diff --git a/files/tests/conversion_test.php b/files/tests/conversion_test.php index 3293bcc8502..c92ad0f4cb0 100644 --- a/files/tests/conversion_test.php +++ b/files/tests/conversion_test.php @@ -342,7 +342,7 @@ class core_files_conversion_testcase extends advanced_testcase { 'status' => (string) 1, ]); - $this->assertInternalType('integer', $conversion->get('status')); + $this->assertIsInt($conversion->get('status')); } /** diff --git a/iplookup/tests/geoip_test.php b/iplookup/tests/geoip_test.php index f1a8a933ef5..f4e2cfddea4 100644 --- a/iplookup/tests/geoip_test.php +++ b/iplookup/tests/geoip_test.php @@ -62,14 +62,14 @@ class core_iplookup_geoip_testcase extends advanced_testcase { $result = iplookup_find_location($ip); - $this->assertInternalType('array', $result); - $this->assertInternalType('float', $result['latitude']); - $this->assertInternalType('float', $result['longitude']); - $this->assertInternalType('string', $result['city']); - $this->assertInternalType('string', $result['country']); - $this->assertInternalType('array', $result['title']); - $this->assertInternalType('string', $result['title'][0]); - $this->assertInternalType('string', $result['title'][1]); + $this->assertIsArray($result); + $this->assertIsFloat($result['latitude']); + $this->assertIsFloat($result['longitude']); + $this->assertIsString($result['city']); + $this->assertIsString($result['country']); + $this->assertIsArray($result['title']); + $this->assertIsString($result['title'][0]); + $this->assertIsString($result['title'][1]); $this->assertNull($result['error']); } diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index d55c8094dea..c2fc921bad0 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -73,7 +73,7 @@ class core_dml_testcase extends database_driver_testcase { public function test_get_server_info() { $DB = $this->tdb; $result = $DB->get_server_info(); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertArrayHasKey('description', $result); $this->assertArrayHasKey('version', $result); } @@ -382,7 +382,7 @@ class core_dml_testcase extends database_driver_testcase { $params[] = 1; $params[] = time(); $sqlarray = $DB->fix_sql_params($sql, $params); - $this->assertInternalType('array', $sqlarray); + $this->assertIsArray($sqlarray); $this->assertCount(3, $sqlarray[1]); // Named params missing from array. @@ -410,7 +410,7 @@ class core_dml_testcase extends database_driver_testcase { $sql = "SELECT * FROM {{$tablename}} WHERE name = :name, course = :course"; $params = array('name' => 'record1', 'course' => 1, 'extrastuff'=>'haha'); $sqlarray = $DB->fix_sql_params($sql, $params); - $this->assertInternalType('array', $sqlarray); + $this->assertIsArray($sqlarray); $this->assertCount(2, $sqlarray[1]); // Params exceeding 30 chars length. @@ -690,7 +690,7 @@ EOD; $dbman->create_table($table); $indices = $DB->get_indexes($tablename); - $this->assertInternalType('array', $indices); + $this->assertIsArray($indices); $this->assertCount(2, $indices); // We do not care about index names for now. $first = array_shift($indices); @@ -744,7 +744,7 @@ EOD; $dbman->create_table($table); $columns = $DB->get_columns($tablename); - $this->assertInternalType('array', $columns); + $this->assertIsArray($columns); $fields = $table->getFields(); $this->assertCount(count($columns), $fields); @@ -1539,7 +1539,7 @@ EOD; $DB->insert_record($tablename, array('course' => 2)); $records = $DB->get_records_list($tablename, 'course', array(3, 2)); - $this->assertInternalType('array', $records); + $this->assertIsArray($records); $this->assertCount(3, $records); $this->assertEquals(1, reset($records)->id); $this->assertEquals(2, next($records)->id); @@ -1688,7 +1688,7 @@ EOD; $DB->insert_record($tablename, array('course' => 2)); $records = $DB->get_records_menu($tablename, array('course' => 3)); - $this->assertInternalType('array', $records); + $this->assertIsArray($records); $this->assertCount(2, $records); $this->assertNotEmpty($records[1]); $this->assertNotEmpty($records[2]); @@ -1716,7 +1716,7 @@ EOD; $DB->insert_record($tablename, array('course' => 5)); $records = $DB->get_records_select_menu($tablename, "course > ?", array(2)); - $this->assertInternalType('array', $records); + $this->assertIsArray($records); $this->assertCount(3, $records); $this->assertArrayHasKey(1, $records); @@ -1748,7 +1748,7 @@ EOD; $DB->insert_record($tablename, array('course' => 5)); $records = $DB->get_records_sql_menu("SELECT * FROM {{$tablename}} WHERE course > ?", array(2)); - $this->assertInternalType('array', $records); + $this->assertIsArray($records); $this->assertCount(3, $records); $this->assertArrayHasKey(1, $records); @@ -1964,7 +1964,7 @@ EOD; $DB->insert_record($tablename, array('course' => 6)); $fieldset = $DB->get_fieldset_select($tablename, 'course', "course > ?", array(1)); - $this->assertInternalType('array', $fieldset); + $this->assertIsArray($fieldset); $this->assertCount(3, $fieldset); $this->assertEquals(3, $fieldset[0]); @@ -1993,7 +1993,7 @@ EOD; $DB->insert_record($tablename, array('course' => 6, 'onebinary' => $binarydata)); $fieldset = $DB->get_fieldset_sql("SELECT * FROM {{$tablename}} WHERE course > ?", array(1)); - $this->assertInternalType('array', $fieldset); + $this->assertIsArray($fieldset); $this->assertCount(3, $fieldset); $this->assertEquals(2, $fieldset[0]); @@ -2001,7 +2001,7 @@ EOD; $this->assertEquals(4, $fieldset[2]); $fieldset = $DB->get_fieldset_sql("SELECT onebinary FROM {{$tablename}} WHERE course > ?", array(1)); - $this->assertInternalType('array', $fieldset); + $this->assertIsArray($fieldset); $this->assertCount(3, $fieldset); $this->assertEquals($binarydata, $fieldset[0]); diff --git a/lib/form/tests/external_test.php b/lib/form/tests/external_test.php index 46643e8fcb1..3b968a2fc9f 100644 --- a/lib/form/tests/external_test.php +++ b/lib/form/tests/external_test.php @@ -51,7 +51,7 @@ class external_testcase extends advanced_testcase { // The actual data are tested in filetypes_util_test.php, here we just // make sure that the external function wrapper seems to work. - $this->assertInternalType('object', $data); - $this->assertInternalType('array', $data->groups); + $this->assertIsObject($data); + $this->assertIsArray($data->groups); } } diff --git a/lib/form/tests/filetypes_util_test.php b/lib/form/tests/filetypes_util_test.php index 623ca69b476..f33e47b364a 100644 --- a/lib/form/tests/filetypes_util_test.php +++ b/lib/form/tests/filetypes_util_test.php @@ -100,8 +100,8 @@ class filetypes_util_testcase extends advanced_testcase { $audio = $util->is_filetype_group('audio'); $this->assertNotFalse($audio); - $this->assertInternalType('array', $audio->extensions); - $this->assertInternalType('array', $audio->mimetypes); + $this->assertIsArray($audio->extensions); + $this->assertIsArray($audio->mimetypes); $this->assertFalse($util->is_filetype_group('.gif')); $this->assertFalse($util->is_filetype_group('somethingveryunlikelytoeverexist')); diff --git a/lib/phpunit/tests/advanced_test.php b/lib/phpunit/tests/advanced_test.php index 525325d2a38..f1fd50db7fe 100644 --- a/lib/phpunit/tests/advanced_test.php +++ b/lib/phpunit/tests/advanced_test.php @@ -467,7 +467,7 @@ class core_phpunit_advanced_testcase extends advanced_testcase { $this->assertGreaterThanOrEqual($mid1, $mid2); $messages = $sink->get_messages(); - $this->assertInternalType('array', $messages); + $this->assertIsArray($messages); $this->assertCount(2, $messages); $this->assertEquals($mid1, $messages[0]->id); $this->assertEquals($message1->userto->id, $messages[0]->useridto); @@ -481,18 +481,18 @@ class core_phpunit_advanced_testcase extends advanced_testcase { // Test resetting. $sink->clear(); $messages = $sink->get_messages(); - $this->assertInternalType('array', $messages); + $this->assertIsArray($messages); $this->assertCount(0, $messages); message_send($message1); $messages = $sink->get_messages(); - $this->assertInternalType('array', $messages); + $this->assertIsArray($messages); $this->assertCount(1, $messages); // Test closing. $sink->close(); $messages = $sink->get_messages(); - $this->assertInternalType('array', $messages); + $this->assertIsArray($messages); $this->assertCount(1, $messages, 'Messages in sink are supposed to stay there after close'); // Test debugging is enabled again. diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index f5abbd10223..568db66b18b 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -942,16 +942,16 @@ class core_accesslib_testcase extends advanced_testcase { foreach ($archetypes as $archetype) { $result = get_default_role_archetype_allows('assign', $archetype); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $result = get_default_role_archetype_allows('override', $archetype); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $result = get_default_role_archetype_allows('switch', $archetype); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $result = get_default_role_archetype_allows('view', $archetype); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); } $result = get_default_role_archetype_allows('assign', ''); @@ -1482,7 +1482,7 @@ class core_accesslib_testcase extends advanced_testcase { $alllevels = context_helper::get_all_levels(); foreach ($archetypes as $archetype) { $defaults = get_default_contextlevels($archetype); - $this->assertInternalType('array', $defaults); + $this->assertIsArray($defaults); foreach ($defaults as $level) { $this->assertTrue(isset($alllevels[$level])); } diff --git a/lib/tests/jquery_test.php b/lib/tests/jquery_test.php index aeed5455880..c436f35736a 100644 --- a/lib/tests/jquery_test.php +++ b/lib/tests/jquery_test.php @@ -45,7 +45,7 @@ class core_jquery_testcase extends basic_testcase { $plugins = null; require($CFG->libdir . '/jquery/plugins.php'); - $this->assertInternalType('array', $plugins); + $this->assertIsArray($plugins); $this->assertEquals(array('jquery', 'ui', 'ui-css'), array_keys($plugins)); foreach ($plugins as $type => $files) { diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index c1fba03dbee..20366f624b8 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -2099,33 +2099,33 @@ class core_moodlelib_testcase extends advanced_testcase { $yes = get_string('yes'); $yesexpected = 'Yes'; - $this->assertInternalType('string', $yes); + $this->assertIsString($yes); $this->assertSame($yesexpected, $yes); $yes = get_string('yes', 'moodle'); - $this->assertInternalType('string', $yes); + $this->assertIsString($yes); $this->assertSame($yesexpected, $yes); $yes = get_string('yes', 'core'); - $this->assertInternalType('string', $yes); + $this->assertIsString($yes); $this->assertSame($yesexpected, $yes); $yes = get_string('yes', ''); - $this->assertInternalType('string', $yes); + $this->assertIsString($yes); $this->assertSame($yesexpected, $yes); $yes = get_string('yes', null); - $this->assertInternalType('string', $yes); + $this->assertIsString($yes); $this->assertSame($yesexpected, $yes); $yes = get_string('yes', null, 1); - $this->assertInternalType('string', $yes); + $this->assertIsString($yes); $this->assertSame($yesexpected, $yes); $days = 1; $numdays = get_string('numdays', 'core', '1'); $numdaysexpected = $days.' days'; - $this->assertInternalType('string', $numdays); + $this->assertIsString($numdays); $this->assertSame($numdaysexpected, $numdays); $yes = get_string('yes', null, null, true); @@ -2137,7 +2137,7 @@ class core_moodlelib_testcase extends advanced_testcase { $test = new lang_string('yes', null, null, true); $testexpected = get_string('numdays', 'core', get_string('yes')); $testresult = get_string('numdays', null, $test); - $this->assertInternalType('string', $testresult); + $this->assertIsString($testresult); $this->assertSame($testexpected, $testresult); // Test using a lang_string object as the $a argument for an object @@ -2644,8 +2644,8 @@ class core_moodlelib_testcase extends advanced_testcase { // Test cache invalidation. $cache = cache::make('core', 'config'); - $this->assertInternalType('array', $cache->get('core')); - $this->assertInternalType('array', $cache->get('mod_forum')); + $this->assertIsArray($cache->get('core')); + $this->assertIsArray($cache->get('mod_forum')); set_config('phpunit_test_get_config_1', 'test b'); $this->assertFalse($cache->get('core')); set_config('phpunit_test_get_config_4', 'test c', 'mod_forum'); diff --git a/lib/tests/plugin_manager_test.php b/lib/tests/plugin_manager_test.php index 41a7957244c..d118b447025 100644 --- a/lib/tests/plugin_manager_test.php +++ b/lib/tests/plugin_manager_test.php @@ -81,7 +81,7 @@ class core_plugin_manager_testcase extends advanced_testcase { public function test_get_plugin_types() { // Make sure there are no warnings or errors. $types = core_plugin_manager::instance()->get_plugin_types(); - $this->assertInternalType('array', $types); + $this->assertIsArray($types); foreach ($types as $type => $fulldir) { $this->assertFileExists($fulldir); } @@ -120,7 +120,7 @@ class core_plugin_manager_testcase extends advanced_testcase { if (is_array($present)) { foreach ($present as $plugin => $version) { $this->assertRegExp('/^[a-z]+[a-z0-9_]*$/', $plugin, 'All plugins are supposed to have version.php file.'); - $this->assertInternalType('object', $version); + $this->assertIsObject($version); $this->assertTrue(is_numeric($version->version), 'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.'); } } else { @@ -189,7 +189,7 @@ class core_plugin_manager_testcase extends advanced_testcase { public function test_get_subplugins() { // Tested already indirectly from test_get_subplugins_of_plugin(). $subplugins = core_plugin_manager::instance()->get_subplugins(); - $this->assertInternalType('array', $subplugins); + $this->assertIsArray($subplugins); } public function test_get_parent_of_subplugin() { diff --git a/lib/tests/scheduled_task_test.php b/lib/tests/scheduled_task_test.php index 6b46272f009..54eed4d9867 100644 --- a/lib/tests/scheduled_task_test.php +++ b/lib/tests/scheduled_task_test.php @@ -396,8 +396,8 @@ class core_scheduled_task_testcase extends advanced_testcase { $testclass = new \core\task\scheduled_test_task(); // The test task defaults to '*'. - $this->assertInternalType('string', $testclass->get_minute()); - $this->assertInternalType('string', $testclass->get_hour()); + $this->assertIsString($testclass->get_minute()); + $this->assertIsString($testclass->get_hour()); // Set a random value. $testclass->set_minute('R'); @@ -406,19 +406,19 @@ class core_scheduled_task_testcase extends advanced_testcase { // Verify the minute has changed within allowed bounds. $minute = $testclass->get_minute(); - $this->assertInternalType('int', $minute); + $this->assertIsInt($minute); $this->assertGreaterThanOrEqual(0, $minute); $this->assertLessThanOrEqual(59, $minute); // Verify the hour has changed within allowed bounds. $hour = $testclass->get_hour(); - $this->assertInternalType('int', $hour); + $this->assertIsInt($hour); $this->assertGreaterThanOrEqual(0, $hour); $this->assertLessThanOrEqual(23, $hour); // Verify the dayofweek has changed within allowed bounds. $dayofweek = $testclass->get_day_of_week(); - $this->assertInternalType('int', $dayofweek); + $this->assertIsInt($dayofweek); $this->assertGreaterThanOrEqual(0, $dayofweek); $this->assertLessThanOrEqual(6, $dayofweek); } diff --git a/lib/tests/update_checker_test.php b/lib/tests/update_checker_test.php index 08052c8bf56..102a699f8ec 100644 --- a/lib/tests/update_checker_test.php +++ b/lib/tests/update_checker_test.php @@ -148,7 +148,7 @@ class core_update_checker_testcase extends advanced_testcase { $old = array(); $new = array(); $cmp = $provider->compare_responses($old, $new); - $this->assertInternalType('array', $cmp); + $this->assertIsArray($cmp); $this->assertEmpty($cmp); } @@ -165,7 +165,7 @@ class core_update_checker_testcase extends advanced_testcase { ) ); $cmp = $provider->compare_responses($old, $new); - $this->assertInternalType('array', $cmp); + $this->assertIsArray($cmp); $this->assertNotEmpty($cmp); $this->assertTrue(isset($cmp['core'][0]['version'])); $this->assertEquals(2012060103, $cmp['core'][0]['version']); @@ -191,7 +191,7 @@ class core_update_checker_testcase extends advanced_testcase { ) ); $cmp = $provider->compare_responses($old, $new); - $this->assertInternalType('array', $cmp); + $this->assertIsArray($cmp); $this->assertEmpty($cmp); } @@ -224,7 +224,7 @@ class core_update_checker_testcase extends advanced_testcase { ) ); $cmp = $provider->compare_responses($old, $new); - $this->assertInternalType('array', $cmp); + $this->assertIsArray($cmp); $this->assertNotEmpty($cmp); $this->assertCount(1, $cmp); $this->assertCount(1, $cmp['core']); @@ -252,7 +252,7 @@ class core_update_checker_testcase extends advanced_testcase { ) ); $cmp = $provider->compare_responses($old, $new); - $this->assertInternalType('array', $cmp); + $this->assertIsArray($cmp); $this->assertNotEmpty($cmp); $this->assertCount(1, $cmp); $this->assertCount(1, $cmp['mod_foo']); diff --git a/lib/tests/update_code_manager_test.php b/lib/tests/update_code_manager_test.php index b127c714a8b..872057f9675 100644 --- a/lib/tests/update_code_manager_test.php +++ b/lib/tests/update_code_manager_test.php @@ -77,7 +77,7 @@ class core_update_code_manager_testcase extends advanced_testcase { $files = $codeman->unzip_plugin_file($zipfilepath, $targetdir); - $this->assertInternalType('array', $files); + $this->assertIsArray($files); $this->assertCount(4, $files); $this->assertSame(true, $files['invalid-root/']); $this->assertSame(true, $files['invalid-root/lang/']); @@ -93,7 +93,7 @@ class core_update_code_manager_testcase extends advanced_testcase { $files = $codeman->unzip_plugin_file($zipfilepath, $targetdir, 'fixed_root'); - $this->assertInternalType('array', $files); + $this->assertIsArray($files); $this->assertCount(4, $files); $this->assertSame(true, $files['fixed_root/']); $this->assertSame(true, $files['fixed_root/lang/']); @@ -139,7 +139,7 @@ class core_update_code_manager_testcase extends advanced_testcase { $fixtures = __DIR__.'/fixtures/update_validator/plugindir'; $codeman = new \core\update\testable_code_manager(); $files = $codeman->list_plugin_folder_files($fixtures.'/foobar'); - $this->assertInternalType('array', $files); + $this->assertIsArray($files); $this->assertEquals(6, count($files)); $fixtures = str_replace(DIRECTORY_SEPARATOR, '/', $fixtures); $this->assertEquals($files['foobar/'], $fixtures.'/foobar'); diff --git a/lib/tests/update_validator_test.php b/lib/tests/update_validator_test.php index 99e7f03f560..840a24590b1 100644 --- a/lib/tests/update_validator_test.php +++ b/lib/tests/update_validator_test.php @@ -181,7 +181,7 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertEquals('foobar', $validator->get_rootdir()); $this->assertTrue($this->has_message($validator->get_messages(), $validator::INFO, 'rootdir', 'foobar')); $versionphpinfo = $validator->get_versionphp_info(); - $this->assertInternalType('array', $versionphpinfo); + $this->assertIsArray($versionphpinfo); $this->assertCount(4, $versionphpinfo); $this->assertEquals(2013031900, $versionphpinfo['version']); $this->assertEquals(2013031200, $versionphpinfo['requires']); @@ -318,7 +318,7 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertEquals('testable_core_update_validator', get_class($validator)); $info = $validator->testable_parse_version_php($fixtures.'/version1.php'); - $this->assertInternalType('array', $info); + $this->assertIsArray($info); $this->assertCount(7, $info); $this->assertEquals('block_foobar', $info['plugin->component']); // Later in the file. $this->assertEquals('2013010100', $info['plugin->version']); // Numeric wins over strings. diff --git a/mod/forum/tests/subscriptions_test.php b/mod/forum/tests/subscriptions_test.php index 44595635e81..ba0d8a54e2a 100644 --- a/mod/forum/tests/subscriptions_test.php +++ b/mod/forum/tests/subscriptions_test.php @@ -393,7 +393,7 @@ class mod_forum_subscriptions_testcase extends advanced_testcase { // Enrol the user in the forum. // If a subscription was added, we get the record ID. - $this->assertInternalType('int', \mod_forum\subscriptions::subscribe_user($author->id, $forum)); + $this->assertIsInt(\mod_forum\subscriptions::subscribe_user($author->id, $forum)); // If we already have a subscription when subscribing the user, we get a boolean (true). $this->assertTrue(\mod_forum\subscriptions::subscribe_user($author->id, $forum)); @@ -652,7 +652,7 @@ class mod_forum_subscriptions_testcase extends advanced_testcase { // And should have reset the discussion cache value. $result = \mod_forum\subscriptions::fetch_discussion_subscription($forum->id, $author->id); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertFalse(isset($result[$discussion->id])); } @@ -1107,7 +1107,7 @@ class mod_forum_subscriptions_testcase extends advanced_testcase { // the cache and not perform additional queries. foreach ($users as $user) { $result = \mod_forum\subscriptions::fetch_discussion_subscription($forum->id, $user->id); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); } $finalcount = $DB->perf_get_reads(); $this->assertEquals(0, $finalcount - $postfillcount); @@ -1165,7 +1165,7 @@ class mod_forum_subscriptions_testcase extends advanced_testcase { // the cache and not perform additional queries. foreach ($users as $user) { $result = \mod_forum\subscriptions::fetch_discussion_subscription($forum->id, $user->id); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); } $finalcount = $DB->perf_get_reads(); $this->assertNotEquals($finalcount, $startcount); diff --git a/mod/wiki/tests/externallib_test.php b/mod/wiki/tests/externallib_test.php index c5303cf7d4e..6d543154ffa 100644 --- a/mod/wiki/tests/externallib_test.php +++ b/mod/wiki/tests/externallib_test.php @@ -1301,7 +1301,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { // Test on existing subwiki. $result = mod_wiki_external::new_page($pagetitle, $pagecontent, 'html', $this->fpsepg1indstu->subwikiid); $result = external_api::clean_returnvalue(mod_wiki_external::new_page_returns(), $result); - $this->assertInternalType('int', $result['pageid']); + $this->assertIsInt($result['pageid']); $version = wiki_get_current_version($result['pageid']); $this->assertEquals($pagecontent, $version->content); @@ -1323,7 +1323,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { $result = mod_wiki_external::new_page($pagetitle, $pagecontent, 'html', null, $this->wikisepind->id, $this->student->id, $this->group2->id); $result = external_api::clean_returnvalue(mod_wiki_external::new_page_returns(), $result); - $this->assertInternalType('int', $result['pageid']); + $this->assertIsInt($result['pageid']); $version = wiki_get_current_version($result['pageid']); $this->assertEquals($pagecontent, $version->content); @@ -1376,7 +1376,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { $result = mod_wiki_external::edit_page($newpage->id, $newpagecontent); $result = external_api::clean_returnvalue(mod_wiki_external::edit_page_returns(), $result); - $this->assertInternalType('int', $result['pageid']); + $this->assertIsInt($result['pageid']); $version = wiki_get_current_version($result['pageid']); $this->assertEquals($newpagecontent, $version->content); @@ -1387,7 +1387,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { $result = mod_wiki_external::edit_page($newpage->id, $newsectioncontent, $section); $result = external_api::clean_returnvalue(mod_wiki_external::edit_page_returns(), $result); - $this->assertInternalType('int', $result['pageid']); + $this->assertIsInt($result['pageid']); $expected = $sectioncontent . $newsectioncontent; diff --git a/privacy/tests/manager_test.php b/privacy/tests/manager_test.php index d395091baf0..11a544fe7c2 100644 --- a/privacy/tests/manager_test.php +++ b/privacy/tests/manager_test.php @@ -491,7 +491,7 @@ class privacy_manager_testcase extends advanced_testcase { $metadata = $mockman->get_metadata_for_components(); $this->assertDebuggingCalled(); - $this->assertInternalType('array', $metadata); + $this->assertIsArray($metadata); $this->assertCount(1, $metadata); } } diff --git a/privacy/tests/provider_test.php b/privacy/tests/provider_test.php index ce6c4435345..900b9b15704 100644 --- a/privacy/tests/provider_test.php +++ b/privacy/tests/provider_test.php @@ -85,9 +85,9 @@ class provider_testcase extends advanced_testcase { */ public function test_null_provider($component, $classname) { $reason = $classname::get_reason(); - $this->assertInternalType('string', $reason); + $this->assertIsString($reason); - $this->assertInternalType('string', get_string($reason, $component)); + $this->assertIsString(get_string($reason, $component)); $this->assertDebuggingNotCalled(); } @@ -124,7 +124,7 @@ class provider_testcase extends advanced_testcase { foreach ($metadata->get_collection() as $item) { // All items must have a valid string name. // Note: This is not a string identifier. - $this->assertInternalType('string', $item->get_name()); + $this->assertIsString($item->get_name()); if ($item instanceof database_table) { // Check that the table is valid. @@ -145,21 +145,21 @@ class provider_testcase extends advanced_testcase { if ($summary = $item->get_summary()) { // Summary is optional, but when provided must be a valid string identifier. - $this->assertInternalType('string', $summary); + $this->assertIsString($summary); // Check that the string is also correctly defined. - $this->assertInternalType('string', get_string($summary, $component)); + $this->assertIsString(get_string($summary, $component)); $this->assertDebuggingNotCalled(); } if ($fields = $item->get_privacy_fields()) { // Privacy fields are optional, but when provided must be a valid string identifier. foreach ($fields as $field => $identifier) { - $this->assertInternalType('string', $field); - $this->assertInternalType('string', $identifier); + $this->assertIsString($field); + $this->assertIsString($identifier); // Check that the string is also correctly defined. - $this->assertInternalType('string', get_string($identifier, $component)); + $this->assertIsString(get_string($identifier, $component)); $this->assertDebuggingNotCalled(); } } diff --git a/privacy/tests/request_transform_test.php b/privacy/tests/request_transform_test.php index 644b825af9b..4182273158b 100644 --- a/privacy/tests/request_transform_test.php +++ b/privacy/tests/request_transform_test.php @@ -63,7 +63,7 @@ class request_transform_test extends advanced_testcase { $datestr = transform::datetime($time); // Assert it is a string. - $this->assertInternalType('string', $datestr); + $this->assertIsString($datestr); // To prevent failures on MAC where we are returned with a lower-case 'am' we want to convert this to 'AM'. $datestr = str_replace('am', 'AM', $datestr); @@ -85,7 +85,7 @@ class request_transform_test extends advanced_testcase { $datestr = transform::date($time); // Assert it is a string. - $this->assertInternalType('string', $datestr); + $this->assertIsString($datestr); // Assert the formatted date is correct. $dateobj = new DateTime(); diff --git a/question/type/calculated/tests/formula_validation_test.php b/question/type/calculated/tests/formula_validation_test.php index 4f6cb4ebb69..3e87ccd169b 100644 --- a/question/type/calculated/tests/formula_validation_test.php +++ b/question/type/calculated/tests/formula_validation_test.php @@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/type/calculated/questiontype.php'); */ class qtype_calculated_formula_validation_testcase extends basic_testcase { protected function assert_nonempty_string($actual) { - $this->assertInternalType('string', $actual); + $this->assertIsString($actual); $this->assertNotEquals('', $actual); } diff --git a/repository/tests/repositorylib_test.php b/repository/tests/repositorylib_test.php index d8885c8df99..bdaac85bb0f 100644 --- a/repository/tests/repositorylib_test.php +++ b/repository/tests/repositorylib_test.php @@ -49,7 +49,7 @@ class core_repositorylib_testcase extends advanced_testcase { $plugintype = new repository_type($repositorypluginname); $pluginid = $plugintype->create(false); - $this->assertInternalType('int', $pluginid); + $this->assertIsInt($pluginid); $args = array(); $args['type'] = $repositorypluginname; $repos = repository::get_instances($args); diff --git a/user/tests/userlib_test.php b/user/tests/userlib_test.php index fcec1fe45db..51de4a67464 100644 --- a/user/tests/userlib_test.php +++ b/user/tests/userlib_test.php @@ -95,7 +95,7 @@ class core_userliblib_testcase extends advanced_testcase { $this->setUser($user1); $userdetails = user_get_user_details_courses($user2); - $this->assertInternalType('array', $userdetails); + $this->assertIsArray($userdetails); $this->assertEquals($user2->id, $userdetails['id']); } @@ -133,7 +133,7 @@ class core_userliblib_testcase extends advanced_testcase { $this->setUser($user1); $userdetails = user_get_user_details_courses($user2); - $this->assertInternalType('array', $userdetails); + $this->assertIsArray($userdetails); $this->assertEquals($user2->id, $userdetails['id']); } From 598d578af7fd2487313e7a22339cc2370a70c391 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 2 Aug 2020 13:43:32 +0200 Subject: [PATCH 05/15] MDL-67673 phpunit: Remove deprecated assertArraySubset() While this is not strictly required, because removal will happen in PHPUnit 9.0, we are already getting rid of all uses in core. From release notes:https://phpunit.de/announcements/phpunit-8.html assertArraySubset() is deprecated and will be removed in PHPUnit 9. --- lib/tests/accesslib_test.php | 7 +++++-- mod/forum/tests/grades_gradeitems_test.php | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index 568db66b18b..42d147a5dd8 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -3567,9 +3567,12 @@ class core_accesslib_testcase extends advanced_testcase { protected function assert_capability_list_contains($expected, $actual) { $actualnames = []; foreach ($actual as $cap) { - $actualnames[$cap->name] = $cap->name; + $actualnames[] = $cap->name; + } + // Verify each expected element exists. + foreach ($expected as $key => $value) { + $this->assertContains($value, $actualnames); } - $this->assertArraySubset(array_combine($expected, $expected), $actualnames); } /** diff --git a/mod/forum/tests/grades_gradeitems_test.php b/mod/forum/tests/grades_gradeitems_test.php index 40df1658709..b68c84cf95f 100644 --- a/mod/forum/tests/grades_gradeitems_test.php +++ b/mod/forum/tests/grades_gradeitems_test.php @@ -48,8 +48,12 @@ class gradeitems_test extends advanced_testcase { $mappings = component_gradeitems::get_itemname_mapping_for_component('mod_forum'); $this->assertIsArray($mappings); $this->assertCount(2, $mappings); - $this->assertArraySubset([0 => 'rating'], $mappings); - $this->assertArraySubset([1 => 'forum'], $mappings); + $expected = [0 => 'rating', 1 => 'forum']; + // Verify each expected element exists and its value matches. + foreach ($expected as $key => $value) { + $this->assertArrayHasKey($key, $mappings); + $this->assertSame($value, $mappings[$key]); + } } /** From d95c3787714386101efb2c8b8804153468e6406b Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 3 Aug 2020 01:19:50 +0200 Subject: [PATCH 06/15] MDL-67673 phpunit: Remove expectedException annotations While this is not strictly required, because removal will happen in PHPUnit 9.0, we are already getting rid of all uses in core. From release notes:https://phpunit.de/announcements/phpunit-8.html The annotations `@expectedException`, `@expectedExceptionCode`, `@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp` are now deprecated. Using these annotations will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these annotations will be removed. Also, all uses of expectExceptionMessageRegExp() has been moved to expectExceptionMessageMatches(). See https://github.com/sebastianbergmann/phpunit/issues/3957 TODO: Various weirdness found while doing the changes with these tests: - vendor/bin/phpunit lib/tests/exporter_test.php (created MDL-69700) - vendor/bin/phpunit competency/tests/external_test.php (same issue than prev one) - vendor/bin/phpunit question/engine/tests/questionengine_test.php (created MDL-69624) - vendor/bin/phpunit lib/tests/event_test.php (created MDL-69688) --- admin/tool/analytics/tests/external_test.php | 3 +- admin/tool/cohortroles/tests/api_test.php | 16 +- admin/tool/langimport/tests/events_test.php | 18 +- .../tool/monitor/tests/subscription_test.php | 3 +- admin/tool/uploadcourse/tests/course_test.php | 10 +- .../uploadcourse/tests/processor_test.php | 8 +- analytics/tests/indicator_test.php | 2 +- .../moodle1/tests/moodle1_converter_test.php | 16 +- calendar/tests/externallib_test.php | 3 +- cohort/tests/cohortlib_test.php | 6 +- cohort/tests/externallib_test.php | 21 +- competency/tests/api_test.php | 14 +- competency/tests/event_test.php | 5 +- competency/tests/external_test.php | 30 +-- competency/tests/plan_test.php | 6 +- course/tests/externallib_test.php | 2 +- enrol/tests/externallib_test.php | 3 +- grade/grading/tests/grading_manager_test.php | 3 +- lib/filestorage/tests/file_storage_test.php | 106 ++++---- .../tests/file_system_filedir_test.php | 10 +- lib/form/tests/duration_test.php | 2 +- lib/testing/tests/generator_test.php | 5 +- lib/tests/admintree_test.php | 8 +- lib/tests/blocklib_test.php | 14 +- lib/tests/event_test.php | 11 +- lib/tests/exporter_test.php | 11 +- lib/tests/filterlib_test.php | 16 +- lib/tests/moodle_page_test.php | 32 +-- lib/tests/moodle_url_test.php | 15 +- lib/tests/moodlelib_test.php | 4 +- lib/tests/mustache_template_finder_test.php | 6 +- lib/tests/persistent_test.php | 10 +- lib/tests/plugin_manager_test.php | 3 +- lib/tests/update_checker_test.php | 10 +- lib/tests/update_code_manager_test.php | 4 +- lib/tests/user_test.php | 6 +- message/tests/externallib_test.php | 2 +- mod/assign/tests/externallib_test.php | 35 +-- mod/choice/tests/events_test.php | 3 +- mod/choice/tests/lib_test.php | 4 +- mod/forum/tests/events_test.php | 252 +++++++----------- mod/glossary/tests/external_test.php | 12 +- .../seb/tests/link_generator_test.php | 2 +- mod/quiz/tests/structure_test.php | 19 +- mod/scorm/tests/events_test.php | 8 +- mod/scorm/tests/externallib_test.php | 12 +- mod/wiki/tests/externallib_test.php | 51 ++-- .../random/tests/allocator_test.php | 4 +- .../form/accumulative/tests/lib_test.php | 8 +- mod/workshop/tests/locallib_test.php | 8 +- .../missing/tests/missingbehaviour_test.php | 16 +- .../tests/questionattempt_with_steps_test.php | 8 +- .../tests/questionattemptiterator_test.php | 16 +- .../questionattemptstepiterator_test.php | 16 +- question/engine/tests/questionengine_test.php | 4 +- question/engine/tests/questionutils_test.php | 12 +- .../tests/variablesubstituter_test.php | 16 +- .../missingtype/tests/missingtype_test.php | 8 +- user/tests/myprofile_test.php | 20 +- 59 files changed, 345 insertions(+), 633 deletions(-) diff --git a/admin/tool/analytics/tests/external_test.php b/admin/tool/analytics/tests/external_test.php index ff26c646b8c..597dda7b9e1 100644 --- a/admin/tool/analytics/tests/external_test.php +++ b/admin/tool/analytics/tests/external_test.php @@ -66,8 +66,6 @@ class tool_analytics_external_testcase extends externallib_advanced_testcase { /** * test_potential_contexts description - * - * @expectedException required_capability_exception */ public function test_potential_contexts_no_manager() { $this->resetAfterTest(); @@ -75,6 +73,7 @@ class tool_analytics_external_testcase extends externallib_advanced_testcase { $user = $this->getDataGenerator()->create_user(); $this->setUser($user); + $this->expectException(required_capability_exception::class); $this->assertCount(2, \tool_analytics\external::potential_contexts()); } } diff --git a/admin/tool/cohortroles/tests/api_test.php b/admin/tool/cohortroles/tests/api_test.php index f023b71840b..0464370d39b 100644 --- a/admin/tool/cohortroles/tests/api_test.php +++ b/admin/tool/cohortroles/tests/api_test.php @@ -60,9 +60,6 @@ class tool_cohortroles_api_testcase extends advanced_testcase { cohort_add_member($this->cohort->id, $this->userassignover->id); } - /** - * @expectedException required_capability_exception - */ public function test_create_cohort_role_assignment_without_permission() { $this->setUser($this->userassignto); $params = (object) array( @@ -70,12 +67,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase { 'roleid' => $this->roleid, 'cohortid' => $this->cohort->id ); + $this->expectException(required_capability_exception::class); api::create_cohort_role_assignment($params); } - /** - * @expectedException core_competency\invalid_persistent_exception - */ public function test_create_cohort_role_assignment_with_invalid_data() { $this->setAdminUser(); $params = (object) array( @@ -83,6 +78,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase { 'roleid' => -8, 'cohortid' => $this->cohort->id ); + $this->expectException(\core_competency\invalid_persistent_exception::class); api::create_cohort_role_assignment($params); } @@ -100,9 +96,6 @@ class tool_cohortroles_api_testcase extends advanced_testcase { $this->assertEquals($result->get('cohortid'), $this->cohort->id); } - /** - * @expectedException required_capability_exception - */ public function test_delete_cohort_role_assignment_without_permission() { $this->setAdminUser(); $params = (object) array( @@ -112,12 +105,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase { ); $result = api::create_cohort_role_assignment($params); $this->setUser($this->userassignto); + $this->expectException(required_capability_exception::class); api::delete_cohort_role_assignment($result->get('id')); } - /** - * @expectedException dml_missing_record_exception - */ public function test_delete_cohort_role_assignment_with_invalid_data() { $this->setAdminUser(); $params = (object) array( @@ -126,6 +117,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase { 'cohortid' => $this->cohort->id ); $result = api::create_cohort_role_assignment($params); + $this->expectException(dml_missing_record_exception::class); api::delete_cohort_role_assignment($result->get('id') + 1); } diff --git a/admin/tool/langimport/tests/events_test.php b/admin/tool/langimport/tests/events_test.php index 0633984a8fb..84a948838de 100644 --- a/admin/tool/langimport/tests/events_test.php +++ b/admin/tool/langimport/tests/events_test.php @@ -56,12 +56,10 @@ class tool_langimport_events_testcase extends advanced_testcase { $this->assertEquals(context_system::instance(), $event->get_context()); } - /** - * @expectedException coding_exception - * @expectedExceptionMessage The 'langcode' value must be set to a valid language code - */ public function test_langpack_updated_validation() { + $this->expectException('coding_exception'); + $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code"); \tool_langimport\event\langpack_updated::event_with_langcode('broken langcode'); } @@ -78,12 +76,10 @@ class tool_langimport_events_testcase extends advanced_testcase { $this->assertEquals(context_system::instance(), $event->get_context()); } - /** - * @expectedException coding_exception - * @expectedExceptionMessage The 'langcode' value must be set to a valid language code - */ public function test_langpack_installed_validation() { + $this->expectException('coding_exception'); + $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code"); \tool_langimport\event\langpack_imported::event_with_langcode('broken langcode'); } @@ -100,12 +96,10 @@ class tool_langimport_events_testcase extends advanced_testcase { $this->assertEquals(context_system::instance(), $event->get_context()); } - /** - * @expectedException coding_exception - * @expectedExceptionMessage The 'langcode' value must be set to a valid language code - */ public function test_langpack_removed_validation() { + $this->expectException('coding_exception'); + $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code"); \tool_langimport\event\langpack_removed::event_with_langcode('broken langcode'); } } diff --git a/admin/tool/monitor/tests/subscription_test.php b/admin/tool/monitor/tests/subscription_test.php index cb18815ad12..364b1c43849 100644 --- a/admin/tool/monitor/tests/subscription_test.php +++ b/admin/tool/monitor/tests/subscription_test.php @@ -59,11 +59,10 @@ class tool_monitor_subscription_testcase extends advanced_testcase { /** * Test for the magic __get method. - * - * @expectedException coding_exception */ public function test_magic_get() { $this->assertEquals(20, $this->subscription->courseid); + $this->expectException(coding_exception::class); $this->subscription->ruleid; } } diff --git a/admin/tool/uploadcourse/tests/course_test.php b/admin/tool/uploadcourse/tests/course_test.php index 9bd1f4eecdc..8843f60da89 100644 --- a/admin/tool/uploadcourse/tests/course_test.php +++ b/admin/tool/uploadcourse/tests/course_test.php @@ -35,21 +35,16 @@ global $CFG; */ class tool_uploadcourse_course_testcase extends advanced_testcase { - /** - * @expectedException coding_exception - */ public function test_proceed_without_prepare() { $this->resetAfterTest(true); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING; $data = array(); $co = new tool_uploadcourse_course($mode, $updatemode, $data); + $this->expectException(coding_exception::class); $co->proceed(); } - /** - * @expectedException moodle_exception - */ public function test_proceed_when_prepare_failed() { $this->resetAfterTest(true); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; @@ -57,6 +52,7 @@ class tool_uploadcourse_course_testcase extends advanced_testcase { $data = array(); $co = new tool_uploadcourse_course($mode, $updatemode, $data); $this->assertFalse($co->prepare()); + $this->expectException(moodle_exception::class); $co->proceed(); } @@ -1504,4 +1500,4 @@ class tool_uploadcourse_course_testcase extends advanced_testcase { 'configdata' => $configdata, ]); } -} \ No newline at end of file +} diff --git a/admin/tool/uploadcourse/tests/processor_test.php b/admin/tool/uploadcourse/tests/processor_test.php index 109c2434c23..b23c035a3aa 100644 --- a/admin/tool/uploadcourse/tests/processor_test.php +++ b/admin/tool/uploadcourse/tests/processor_test.php @@ -160,9 +160,6 @@ class tool_uploadcourse_processor_testcase extends advanced_testcase { $this->assertEquals('ID123: Course 1', $c->shortname); } - /** - * @expectedException moodle_exception - */ public function test_empty_csv() { $this->resetAfterTest(true); @@ -174,12 +171,10 @@ class tool_uploadcourse_processor_testcase extends advanced_testcase { $cir->init(); $options = array('mode' => tool_uploadcourse_processor::MODE_CREATE_NEW); + $this->expectException(moodle_exception::class); $p = new tool_uploadcourse_processor($cir, $options, array()); } - /** - * @expectedException moodle_exception - */ public function test_not_enough_columns() { $this->resetAfterTest(true); @@ -194,6 +189,7 @@ class tool_uploadcourse_processor_testcase extends advanced_testcase { $cir->init(); $options = array('mode' => tool_uploadcourse_processor::MODE_CREATE_NEW); + $this->expectException(moodle_exception::class); $p = new tool_uploadcourse_processor($cir, $options, array()); } diff --git a/analytics/tests/indicator_test.php b/analytics/tests/indicator_test.php index add3f3d4914..ff7ff0c3b36 100644 --- a/analytics/tests/indicator_test.php +++ b/analytics/tests/indicator_test.php @@ -70,7 +70,6 @@ class analytics_indicator_testcase extends advanced_testcase { * @param string $indicatorclass * @param string $willreturn * @dataProvider validate_calculated_value_exceptions - * @expectedException \coding_exception * @return null */ public function test_validate_calculated_value_exceptions($indicatorclass, $willreturn) { @@ -80,6 +79,7 @@ class analytics_indicator_testcase extends advanced_testcase { ->setMethods(['calculate_sample']) ->getMock(); $indicatormock->method('calculate_sample')->willReturn($willreturn); + $this->expectException(coding_exception::class); list($values, $unused) = $indicatormock->calculate([1], 'notrelevanthere'); } diff --git a/backup/converter/moodle1/tests/moodle1_converter_test.php b/backup/converter/moodle1/tests/moodle1_converter_test.php index 7065286efdb..d8ece4bcbac 100644 --- a/backup/converter/moodle1/tests/moodle1_converter_test.php +++ b/backup/converter/moodle1/tests/moodle1_converter_test.php @@ -92,17 +92,12 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { $this->assertInstanceOf('moodle1_converter', $converter); } - /** - * @expectedException moodle1_convert_storage_exception - */ public function test_stash_storage_not_created() { $converter = convert_factory::get_converter('moodle1', $this->tempdir); + $this->expectException(moodle1_convert_storage_exception::class); $converter->set_stash('tempinfo', 12); } - /** - * @expectedException moodle1_convert_empty_storage_exception - */ public function test_stash_requiring_empty_stash() { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); @@ -113,6 +108,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { } catch (moodle1_convert_empty_storage_exception $e) { // we must drop the storage here so we are able to re-create it in the next test + $this->expectException(moodle1_convert_empty_storage_exception::class); $converter->drop_stash_storage(); throw new moodle1_convert_empty_storage_exception('rethrowing'); } @@ -440,9 +436,6 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { $this->assertSame(null, $data['nothing']); } - /** - * @expectedException convert_path_exception - */ public function test_grouped_data_on_nongrouped_convert_path() { // prepare some grouped data $data = array( @@ -468,12 +461,10 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { $path = new convert_path('beer_style', '/ROOT/BEER_STYLES/BEER_STYLE'); // an attempt to apply recipes throws exception because we do not expect grouped data + $this->expectException(convert_path_exception::class); $data = $path->apply_recipes($data); } - /** - * @expectedException convert_path_exception - */ public function test_grouped_convert_path_with_recipes() { // prepare some grouped data $data = array( @@ -501,6 +492,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase { $this->assertEquals('Heineken', $data['beers'][1]['beer']['name']); // an attempt to provide explicit recipes on grouped elements throws exception + $this->expectException(convert_path_exception::class); $path = new convert_path( 'beer_style', '/ROOT/BEER_STYLES/BEER_STYLE', array( diff --git a/calendar/tests/externallib_test.php b/calendar/tests/externallib_test.php index d39596d9e83..53e2a3a04e1 100644 --- a/calendar/tests/externallib_test.php +++ b/calendar/tests/externallib_test.php @@ -157,8 +157,6 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { /** * Test delete_calendar_events - * - * @expectedException moodle_exception */ public function test_delete_calendar_events() { global $DB, $USER; @@ -282,6 +280,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { array('eventid' => $userevent->id, 'repeat' => 0), array('eventid' => $groupevent->id, 'repeat' => 0) ); + $this->expectException(moodle_exception::class); core_calendar_external::delete_calendar_events($events); } diff --git a/cohort/tests/cohortlib_test.php b/cohort/tests/cohortlib_test.php index e48fdf5f825..05bcd0ef3de 100644 --- a/cohort/tests/cohortlib_test.php +++ b/cohort/tests/cohortlib_test.php @@ -65,10 +65,6 @@ class core_cohort_cohortlib_testcase extends advanced_testcase { $this->assertSame($newcohort->timecreated, $newcohort->timemodified); } - /** - * @expectedException coding_exception - * @expectedExceptionMessage Missing cohort name in cohort_add_cohort(). - */ public function test_cohort_add_cohort_missing_name() { $cohort = new stdClass(); $cohort->contextid = context_system::instance()->id; @@ -77,6 +73,8 @@ class core_cohort_cohortlib_testcase extends advanced_testcase { $cohort->description = 'test cohort desc'; $cohort->descriptionformat = FORMAT_HTML; + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Missing cohort name in cohort_add_cohort()'); cohort_add_cohort($cohort); } diff --git a/cohort/tests/externallib_test.php b/cohort/tests/externallib_test.php index f5cdd7987f2..a2ec653d8db 100644 --- a/cohort/tests/externallib_test.php +++ b/cohort/tests/externallib_test.php @@ -34,8 +34,6 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { /** * Test create_cohorts - * - * @expectedException required_capability_exception */ public function test_create_cohorts() { global $USER, $CFG, $DB; @@ -131,13 +129,12 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { // Call without required capability. $this->unassignUserCapability('moodle/cohort:manage', $contextid, $roleid); + $this->expectException(required_capability_exception::class); $createdcohorts = core_cohort_external::create_cohorts(array($cohort3)); } /** * Test delete_cohorts - * - * @expectedException required_capability_exception */ public function test_delete_cohorts() { global $USER, $CFG, $DB; @@ -164,6 +161,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { $cohort1 = self::getDataGenerator()->create_cohort(); $cohort2 = self::getDataGenerator()->create_cohort(); $this->unassignUserCapability('moodle/cohort:manage', $contextid, $roleid); + $this->expectException(required_capability_exception::class); core_cohort_external::delete_cohorts(array($cohort1->id, $cohort2->id)); } @@ -232,8 +230,6 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { /** * Test update_cohorts - * - * @expectedException required_capability_exception */ public function test_update_cohorts() { global $USER, $CFG, $DB; @@ -291,6 +287,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { // Call without required capability. $this->unassignUserCapability('moodle/cohort:manage', $context->id, $roleid); + $this->expectException(required_capability_exception::class); core_cohort_external::update_cohorts(array($cohort1)); } @@ -326,8 +323,6 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { /** * Test update_cohorts without permission on the dest category. - * - * @expectedException required_capability_exception */ public function test_update_cohorts_missing_dest() { global $USER, $CFG, $DB; @@ -363,13 +358,12 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { // Call the external function. // Should fail because we don't have permission on the dest category + $this->expectException(required_capability_exception::class); core_cohort_external::update_cohorts(array($cohortupdate)); } /** * Test update_cohorts without permission on the src category. - * - * @expectedException required_capability_exception */ public function test_update_cohorts_missing_src() { global $USER, $CFG, $DB; @@ -405,13 +399,12 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { // Call the external function. // Should fail because we don't have permission on the src category + $this->expectException(required_capability_exception::class); core_cohort_external::update_cohorts(array($cohortupdate)); } /** * Test add_cohort_members - * - * @expectedException required_capability_exception */ public function test_add_cohort_members() { global $DB; @@ -457,13 +450,12 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { 'usertype' => array('type' => 'id', 'value' => '2') ); $this->unassignUserCapability('moodle/cohort:assign', $contextid, $roleid); + $this->expectException(required_capability_exception::class); $addcohortmembers = core_cohort_external::add_cohort_members(array($cohort2)); } /** * Test delete_cohort_members - * - * @expectedException required_capability_exception */ public function test_delete_cohort_members() { global $DB; @@ -515,6 +507,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase { // Call without required capability. $this->unassignUserCapability('moodle/cohort:assign', $context->id, $roleid); + $this->expectException(required_capability_exception::class); core_cohort_external::delete_cohort_members(array($cohortdel1, $cohortdel2)); } diff --git a/competency/tests/api_test.php b/competency/tests/api_test.php index ffe15e344a2..37d85e78fd5 100644 --- a/competency/tests/api_test.php +++ b/competency/tests/api_test.php @@ -166,8 +166,6 @@ class core_competency_api_testcase extends advanced_testcase { /** * Test updating a template. - * - * @expectedException coding_exception */ public function test_update_template() { $cat = $this->getDataGenerator()->create_category(); @@ -186,6 +184,7 @@ class core_competency_api_testcase extends advanced_testcase { $this->assertEquals('success', $template->get('shortname')); // Trying to change the context. + $this->expectException(coding_exception::class); api::update_template((object) array('id' => $template->get('id'), 'contextid' => context_coursecat::instance($cat->id))); } @@ -511,9 +510,6 @@ class core_competency_api_testcase extends advanced_testcase { } } - /** - * @expectedException coding_exception - */ public function test_create_plan_from_template() { $this->resetAfterTest(true); $this->setAdminUser(); @@ -536,6 +532,7 @@ class core_competency_api_testcase extends advanced_testcase { // Check that api::create_plan cannot be used. unset($record->id); + $this->expectException(coding_exception::class); $plan = api::create_plan($record); } @@ -756,8 +753,6 @@ class core_competency_api_testcase extends advanced_testcase { /** * Test that the method to complete a plan. - * - * @expectedException coding_exception */ public function test_complete_plan() { global $DB; @@ -838,6 +833,7 @@ class core_competency_api_testcase extends advanced_testcase { } // Completing a plan that is completed throws an exception. + $this->expectException(coding_exception::class); api::complete_plan($plan); } @@ -4513,9 +4509,6 @@ class core_competency_api_testcase extends advanced_testcase { $this->assertTrue(evidence::record_exists($ev2->get('id'))); } - /** - * @expectedException required_capability_exception - */ public function test_delete_evidence_without_permissions() { $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -4529,6 +4522,7 @@ class core_competency_api_testcase extends advanced_testcase { $this->setUser($u1); + $this->expectException(required_capability_exception::class); api::delete_evidence($ev1); } diff --git a/competency/tests/event_test.php b/competency/tests/event_test.php index 134c86b110f..384be5f97c0 100644 --- a/competency/tests/event_test.php +++ b/competency/tests/event_test.php @@ -1360,9 +1360,6 @@ class core_competency_event_testcase extends advanced_testcase { /** * Test evidence_created event by linking an invalid user competency to an evidence. - * - * @expectedException coding_exception - * @expectedExceptionMessage The user competency linked with this evidence is invalid. */ public function test_evidence_created_with_invalid_user_competency() { $this->resetAfterTest(true); @@ -1388,6 +1385,8 @@ class core_competency_event_testcase extends advanced_testcase { 'commentincontext', 'core', null, $recommend, null, 1); // We expect this to fail and throw a coding exception. + $this->expectException('coding_exception'); + $this->expectExceptionMessage('The user competency linked with this evidence is invalid.'); \core\event\competency_evidence_created::create_from_evidence($evidence, $otheruc, $recommend)->trigger(); } diff --git a/competency/tests/external_test.php b/competency/tests/external_test.php index c2ddd7af698..e2e8af7cf5d 100644 --- a/competency/tests/external_test.php +++ b/competency/tests/external_test.php @@ -299,22 +299,20 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we can't create a competency framework with only read permissions. - * - * @expectedException required_capability_exception */ public function test_create_competency_frameworks_with_read_permissions() { $this->setUser($this->user); + $this->expectException(required_capability_exception::class); $result = $this->create_competency_framework(1, true); } /** * Test we can't create a competency framework with only read permissions. - * - * @expectedException required_capability_exception */ public function test_create_competency_frameworks_with_read_permissions_in_category() { $this->setUser($this->catuser); + $this->expectException(required_capability_exception::class); $result = $this->create_competency_framework(1, false); } @@ -365,8 +363,6 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we cannot create a competency framework with nasty data. - * - * @expectedException invalid_parameter_exception */ public function test_create_competency_frameworks_with_nasty_data() { $this->setUser($this->creator); @@ -380,6 +376,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase { 'visible' => true, 'contextid' => context_system::instance()->id ); + $this->expectException(invalid_parameter_exception::class); $result = external::create_competency_framework($framework); } @@ -542,8 +539,6 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we can delete a competency framework with read permissions. - * - * @expectedException required_capability_exception */ public function test_delete_competency_frameworks_with_read_permissions() { $this->setUser($this->creator); @@ -552,6 +547,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase { $id = $result->id; // Switch users to someone with less permissions. $this->setUser($this->user); + $this->expectException(required_capability_exception::class); $result = external::delete_competency_framework($id); } @@ -624,14 +620,13 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we can update a competency framework with read permissions. - * - * @expectedException required_capability_exception */ public function test_update_competency_frameworks_with_read_permissions() { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); $this->setUser($this->user); + $this->expectException(required_capability_exception::class); $result = $this->update_competency_framework($result->id, 2, true); } @@ -758,12 +753,11 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we can't create a competency with only read permissions. - * - * @expectedException required_capability_exception */ public function test_create_competency_with_read_permissions() { $framework = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_framework(); $this->setUser($this->user); + $this->expectException(required_capability_exception::class); $competency = $this->create_competency(1, $framework->get('id')); } @@ -820,8 +814,6 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we cannot create a competency with nasty data. - * - * @expectedException invalid_parameter_exception */ public function test_create_competency_with_nasty_data() { $this->setUser($this->creator); @@ -834,6 +826,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase { 'competencyframeworkid' => $framework->id, 'sortorder' => 0 ); + // TODO: MDL-69700 - Analyse if the throw exception is happening + // in the correct place and decide what happens with the trailing + // code that is never executed. + $this->expectException(invalid_parameter_exception::class); $result = external::create_competency($competency); $result = (object) external_api::clean_returnvalue(external::create_competency_returns(), $result); } @@ -998,8 +994,6 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we can delete a competency with read permissions. - * - * @expectedException required_capability_exception */ public function test_delete_competency_with_read_permissions() { $this->setUser($this->creator); @@ -1009,6 +1003,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase { $id = $result->id; // Switch users to someone with less permissions. $this->setUser($this->user); + $this->expectException(required_capability_exception::class); $result = external::delete_competency($id); } @@ -1052,8 +1047,6 @@ class core_competency_external_testcase extends externallib_advanced_testcase { /** * Test we can update a competency with read permissions. - * - * @expectedException required_capability_exception */ public function test_update_competency_with_read_permissions() { $this->setUser($this->creator); @@ -1061,6 +1054,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase { $result = $this->create_competency(1, $framework->id); $this->setUser($this->user); + $this->expectException(required_capability_exception::class); $result = $this->update_competency($result->id, 2); } diff --git a/competency/tests/plan_test.php b/competency/tests/plan_test.php index c942d9ff1a9..191a0b041aa 100644 --- a/competency/tests/plan_test.php +++ b/competency/tests/plan_test.php @@ -526,10 +526,6 @@ class core_competency_plan_testcase extends advanced_testcase { $this->assertCount(0, $plans); } - /** - * @expectedException coding_exception - * @expectedExceptionMessage The competency does not belong to this template: - */ public function test_get_competency() { $this->resetAfterTest(); $this->setAdminUser(); @@ -571,6 +567,8 @@ class core_competency_plan_testcase extends advanced_testcase { $this->assertEquals($c4->to_record(), $p4->get_competency($c4->get('id'))->to_record()); // Getting the competency 4 from the non-completed plan based on a template p4, will throw an exception. + $this->expectException('coding_exception'); + $this->expectExceptionMessage('The competency does not belong to this template:'); $p3->get_competency($c4->get('id')); } } diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index 648463db376..e061802d21e 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -596,7 +596,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase { $course['categoryid'] = $this->getDataGenerator()->create_category()->id; $this->expectException(moodle_exception::class); - $this->expectExceptionMessageRegExp("/{$expectedemptyfield}/"); + $this->expectExceptionMessageMatches("/{$expectedemptyfield}/"); core_course_external::create_courses([$course]); } diff --git a/enrol/tests/externallib_test.php b/enrol/tests/externallib_test.php index 3a1b1de3b85..09a01ad2599 100644 --- a/enrol/tests/externallib_test.php +++ b/enrol/tests/externallib_test.php @@ -767,8 +767,6 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase { /** * Test get_enrolled_users from core_enrol_external with capability to * viewparticipants removed. - * - * @expectedException moodle_exception */ public function test_get_enrolled_users_without_capability() { $capability = 'moodle/course:viewparticipants'; @@ -776,6 +774,7 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase { // Call without required capability. $this->unassignUserCapability($capability, $data->context->id, $data->roleid); + $this->expectException(moodle_exception::class); $categories = core_enrol_external::get_enrolled_users($data->course->id); } diff --git a/grade/grading/tests/grading_manager_test.php b/grade/grading/tests/grading_manager_test.php index b4907241312..6aa0444642a 100644 --- a/grade/grading/tests/grading_manager_test.php +++ b/grade/grading/tests/grading_manager_test.php @@ -67,8 +67,6 @@ class core_grade_grading_manager_testcase extends advanced_testcase { /** * Unit test to set and get grading areas - * - * @expectedException moodle_exception */ public function test_set_and_get_grading_area() { global $DB; @@ -105,6 +103,7 @@ class core_grade_grading_manager_testcase extends advanced_testcase { $this->assertEquals('rubric', $gradingman->get_active_method()); // attempting to set an invalid method + $this->expectException(moodle_exception::class); $gradingman->set_active_method('no_one_should_ever_try_to_implement_a_method_with_this_silly_name'); } diff --git a/lib/filestorage/tests/file_storage_test.php b/lib/filestorage/tests/file_storage_test.php index 20db7b7d015..62c19f30e13 100644 --- a/lib/filestorage/tests/file_storage_test.php +++ b/lib/filestorage/tests/file_storage_test.php @@ -1291,7 +1291,6 @@ class core_files_file_storage_testcase extends advanced_testcase { } /** - * @expectedException file_exception * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_file_invalid() { @@ -1302,12 +1301,11 @@ class core_files_file_storage_testcase extends advanced_testcase { $fs = get_file_storage(); // Create a file from a file id which doesn't exist. + $this->expectException(file_exception::class); $fs->create_file_from_storedfile($filerecord, 9999); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid contextid * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_contextid_invalid() { @@ -1322,12 +1320,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->contextid = 'invalid'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid contextid'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid component * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_component_invalid() { @@ -1342,12 +1340,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->component = 'bad/component'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid component'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid filearea * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_filearea_invalid() { @@ -1362,12 +1360,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->filearea = 'bad-filearea'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid filearea'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid itemid * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_itemid_invalid() { @@ -1382,12 +1380,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->itemid = 'bad-itemid'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid itemid'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file path * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_filepath_invalid() { @@ -1402,12 +1400,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->filepath = 'a-/bad/-filepath'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file path'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file name * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_filename_invalid() { @@ -1421,12 +1419,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = ''; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file name'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file timecreated * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_timecreated_invalid() { @@ -1441,12 +1439,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->timecreated = 'today'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file timecreated'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file timemodified * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_timemodified_invalid() { @@ -1461,12 +1459,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = 'invalid.txt'; $filerecord->timemodified = 'today'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file timemodified'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } /** - * @expectedException stored_file_creation_exception - * @expectedExceptionMessage Can not create file "1/core/phpunit/0/testfile.txt" * @covers ::create_file_from_storedfile */ public function test_create_file_from_storedfile_duplicate() { @@ -1479,6 +1477,8 @@ class core_files_file_storage_testcase extends advanced_testcase { $this->assertInstanceOf('stored_file', $file1); // Creating a file validating unique constraint. + $this->expectException(stored_file_creation_exception::class); + $this->expectExceptionMessage('Can not create file "1/core/phpunit/0/testfile.txt"'); $fs->create_file_from_storedfile($filerecord, $file1->get_id()); } @@ -1522,8 +1522,6 @@ class core_files_file_storage_testcase extends advanced_testcase { } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid contextid * @covers ::create_file_from_string */ public function test_create_file_from_string_contextid_invalid() { @@ -1534,12 +1532,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->contextid = 'invalid'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid contextid'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid component * @covers ::create_file_from_string */ public function test_create_file_from_string_component_invalid() { @@ -1550,12 +1548,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->component = 'bad/component'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid component'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid filearea * @covers ::create_file_from_string */ public function test_create_file_from_string_filearea_invalid() { @@ -1566,12 +1564,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filearea = 'bad-filearea'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid filearea'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid itemid * @covers ::create_file_from_string */ public function test_create_file_from_string_itemid_invalid() { @@ -1582,12 +1580,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->itemid = 'bad-itemid'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid itemid'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file path * @covers ::create_file_from_string */ public function test_create_file_from_string_filepath_invalid() { @@ -1598,12 +1596,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filepath = 'a-/bad/-filepath'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file path'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file name * @covers ::create_file_from_string */ public function test_create_file_from_string_filename_invalid() { @@ -1614,12 +1612,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = ''; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file name'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file timecreated * @covers ::create_file_from_string */ public function test_create_file_from_string_timecreated_invalid() { @@ -1636,8 +1634,6 @@ class core_files_file_storage_testcase extends advanced_testcase { } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file timemodified * @covers ::create_file_from_string */ public function test_create_file_from_string_timemodified_invalid() { @@ -1648,6 +1644,8 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->timemodified = 'today'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file timemodified'); $file1 = $fs->create_file_from_string($filerecord, 'text contents'); } @@ -1669,8 +1667,6 @@ class core_files_file_storage_testcase extends advanced_testcase { } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid contextid * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_contextid_invalid() { @@ -1684,12 +1680,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->contextid = 'invalid'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid contextid'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid component * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_component_invalid() { @@ -1703,12 +1699,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->component = 'bad/component'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid component'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid filearea * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_filearea_invalid() { @@ -1722,12 +1718,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filearea = 'bad-filearea'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid filearea'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid itemid * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_itemid_invalid() { @@ -1741,12 +1737,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->itemid = 'bad-itemid'; - $file1 = $fs->create_file_from_pathname($filerecord, $path); + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid itemid'); + $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file path * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_filepath_invalid() { @@ -1760,12 +1756,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filepath = 'a-/bad/-filepath'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file path'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file name * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_filename_invalid() { @@ -1779,12 +1775,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->filename = ''; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file name'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file timecreated * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_timecreated_invalid() { @@ -1798,12 +1794,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->timecreated = 'today'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file timecreated'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException file_exception - * @expectedExceptionMessage Invalid file timemodified * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_timemodified_invalid() { @@ -1817,12 +1813,12 @@ class core_files_file_storage_testcase extends advanced_testcase { $filerecord->timemodified = 'today'; + $this->expectException(file_exception::class); + $this->expectExceptionMessage('Invalid file timemodified'); $file1 = $fs->create_file_from_pathname($filerecord, $path); } /** - * @expectedException stored_file_creation_exception - * @expectedExceptionMessage Can not create file "1/core/phpunit/0/testfile.txt" * @covers ::create_file_from_pathname */ public function test_create_file_from_pathname_duplicate_file() { @@ -1838,6 +1834,8 @@ class core_files_file_storage_testcase extends advanced_testcase { $this->assertInstanceOf('stored_file', $file1); // Creating a file validating unique constraint. + $this->expectException(stored_file_creation_exception::class); + $this->expectExceptionMessage('Can not create file "1/core/phpunit/0/testfile.txt"'); $file2 = $fs->create_file_from_pathname($filerecord, $path); } diff --git a/lib/filestorage/tests/file_system_filedir_test.php b/lib/filestorage/tests/file_system_filedir_test.php index 24653715fb6..3896770cc59 100644 --- a/lib/filestorage/tests/file_system_filedir_test.php +++ b/lib/filestorage/tests/file_system_filedir_test.php @@ -153,7 +153,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { // This should generate an exception. $this->expectException('file_exception'); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/Can not create local file pool directories, please verify permissions in dataroot./'); new file_system_filedir(); @@ -177,7 +177,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { // This should generate an exception. $this->expectException('file_exception'); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/Can not create local file pool directories, please verify permissions in dataroot./'); new file_system_filedir(); @@ -735,7 +735,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { $vfileroot = $this->setup_vfile_root(); $this->expectException('file_exception'); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/Cannot read file\. Either the file does not exist or there is a permission problem\./'); $fs = new file_system_filedir(); @@ -834,7 +834,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { ->chown(\org\bovigo\vfs\vfsStream::OWNER_USER_2); $this->expectException('file_exception'); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( "/Can not create local file pool directories, please verify permissions in dataroot./"); // Attempt to add the file to the file pool. @@ -892,7 +892,7 @@ class core_files_file_system_filedir_testcase extends advanced_testcase { ->chown(\org\bovigo\vfs\vfsStream::OWNER_USER_2); $this->expectException('file_exception'); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( "/Can not create local file pool directories, please verify permissions in dataroot./"); // Attempt to add the file to the file pool. diff --git a/lib/form/tests/duration_test.php b/lib/form/tests/duration_test.php index 629ac4d8d14..cd0c9bcdd89 100644 --- a/lib/form/tests/duration_test.php +++ b/lib/form/tests/duration_test.php @@ -69,7 +69,7 @@ class core_form_duration_testcase extends basic_testcase { public function test_constructor_rejects_invalid_unit(): void { // Test trying to create with an invalid unit. $mform = $this->get_test_form(); - $this->expectException('coding_exception'); + $this->expectException(coding_exception::class); $mform->addElement('duration', 'testel', null, ['defaultunit' => 123, 'optional' => false]); } diff --git a/lib/testing/tests/generator_test.php b/lib/testing/tests/generator_test.php index 2d9990fae25..2fd59265b40 100644 --- a/lib/testing/tests/generator_test.php +++ b/lib/testing/tests/generator_test.php @@ -49,11 +49,10 @@ class core_test_generator_testcase extends advanced_testcase { /** * Test plugin generator, with no component directory. - * - * @expectedException coding_exception - * @expectedExceptionMessage Component core_completion does not support generators yet. Missing tests/generator/lib.php. */ public function test_get_plugin_generator_no_component_dir() { + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Component core_completion does not support generators yet. Missing tests/generator/lib.php.'); $generator = $this->getDataGenerator()->get_plugin_generator('core_completion'); } diff --git a/lib/tests/admintree_test.php b/lib/tests/admintree_test.php index cadd817046c..245abb6c331 100644 --- a/lib/tests/admintree_test.php +++ b/lib/tests/admintree_test.php @@ -95,19 +95,15 @@ class core_admintree_testcase extends advanced_testcase { $this->assertEquals(array('zero', 'one', 'two', 'three', 'four', 'five', 'six'), $map); } - /** - * @expectedException coding_exception - */ public function test_add_nodes_before_invalid1() { $tree = new admin_root(true); + $this->expectException(coding_exception::class); $tree->add('root', new admin_externalpage('foo', 'Foo', 'http://foo.bar'), array('moodle:site/config')); } - /** - * @expectedException coding_exception - */ public function test_add_nodes_before_invalid2() { $tree = new admin_root(true); + $this->expectException(coding_exception::class); $tree->add('root', new admin_category('bar', 'Bar'), ''); } diff --git a/lib/tests/blocklib_test.php b/lib/tests/blocklib_test.php index 4fbd0a64416..c68ca54d59c 100644 --- a/lib/tests/blocklib_test.php +++ b/lib/tests/blocklib_test.php @@ -109,13 +109,11 @@ class core_blocklib_testcase extends advanced_testcase { $this->assertEquals(array('a-region-name', 'another-region'), $this->blockmanager->get_regions(), '', 0, 10, true); } - /** - * @expectedException coding_exception - */ public function test_cannot_add_region_after_loaded() { // Set up fixture. $this->blockmanager->mark_loaded(); // Exercise SUT. + $this->expectException(coding_exception::class); $this->blockmanager->add_region('too-late', false); } @@ -167,12 +165,12 @@ class core_blocklib_testcase extends advanced_testcase { /** * Test to ensure that we cannot add a region after the blocks have been loaded. - * @expectedException coding_exception */ public function test_cannot_add_custom_region_after_loaded() { // Set up fixture. $this->blockmanager->mark_loaded(); // Exercise SUT. + $this->expectException(coding_exception::class); $this->blockmanager->add_region('too-late'); } @@ -185,21 +183,17 @@ class core_blocklib_testcase extends advanced_testcase { $this->assertEquals('a-region-name', $this->blockmanager->get_default_region()); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_unknown_region_as_default() { // Exercise SUT. + $this->expectException(coding_exception::class); $this->blockmanager->set_default_region('a-region-name'); } - /** - * @expectedException coding_exception - */ public function test_cannot_change_default_region_after_loaded() { // Set up fixture. $this->blockmanager->mark_loaded(); // Exercise SUT. + $this->expectException(coding_exception::class); $this->blockmanager->set_default_region('too-late'); } diff --git a/lib/tests/event_test.php b/lib/tests/event_test.php index 9e71470e1dc..4bca28e55e4 100644 --- a/lib/tests/event_test.php +++ b/lib/tests/event_test.php @@ -849,10 +849,15 @@ class core_event_testcase extends advanced_testcase { $this->assertSame($event->get_data(), $data); } - /** - * @expectedException PHPUnit\Framework\Error\Notice - */ public function test_context_not_used() { + // TODO: MDL-69688 - This test is far away from my understanding. It throws a + // "Trying to get property 'instanceid' of non-object" notice, so + // it's not clear for me what the test is doing. This was detected + // when preparing tests for PHPUnit 8 (MDL-67673) and, at the end + // all that was done is to move the annotation (deprecated) to + // explicit expectation. Still try commenting it out and you'll see + // the notice. + $this->expectException(\PHPUnit\Framework\Error\Notice::class); $event = \core_tests\event\context_used_in_event::create(array('other' => array('sample' => 1, 'xx' => 10))); $this->assertEventContextNotUsed($event); diff --git a/lib/tests/exporter_test.php b/lib/tests/exporter_test.php index 7b227577920..80b19a2e46a 100644 --- a/lib/tests/exporter_test.php +++ b/lib/tests/exporter_test.php @@ -98,22 +98,21 @@ class core_exporter_testcase extends advanced_testcase { $this->assertArrayNotHasKey('otherstrings', $structure->keys); } - /** - * @expectedException coding_exception - */ public function test_invalid_data() { global $PAGE; $exporter = new core_testable_exporter($this->invaliddata, $this->validrelated); $output = $PAGE->get_renderer('core'); + $this->expectException(coding_exception::class); $result = $exporter->export($output); } - /** - * @expectedException coding_exception - */ public function test_invalid_related() { global $PAGE; + // TODO: MDL-69700 - Analyse if the throw exception is happening + // in the correct place and decide what happens with the trailing + // code that is never executed. + $this->expectException(coding_exception::class); $exporter = new core_testable_exporter($this->validdata, $this->invalidrelated); $output = $PAGE->get_renderer('core'); diff --git a/lib/tests/filterlib_test.php b/lib/tests/filterlib_test.php index 90fcb652f1f..a2119642db9 100644 --- a/lib/tests/filterlib_test.php +++ b/lib/tests/filterlib_test.php @@ -91,11 +91,9 @@ class core_filterlib_testcase extends advanced_testcase { $this->assert_only_one_filter_globally('name', TEXTFILTER_DISABLED); } - /** - * @expectedException coding_exception - */ public function test_global_config_exception_on_invalid_state() { $this->resetAfterTest(); + $this->expectException(coding_exception::class); filter_set_global_state('name', 0); } @@ -248,21 +246,17 @@ class core_filterlib_testcase extends advanced_testcase { $this->assert_no_local_setting(); } - /** - * @expectedException coding_exception - */ public function test_local_invalid_state_throws_exception() { $this->resetAfterTest(); // Exercise SUT. + $this->expectException(coding_exception::class); filter_set_local_state('name', 123, -9999); } - /** - * @expectedException coding_exception - */ public function test_throws_exception_when_setting_global() { $this->resetAfterTest(); // Exercise SUT. + $this->expectException(coding_exception::class); filter_set_local_state('name', context_system::instance()->id, TEXTFILTER_INHERIT); } @@ -543,15 +537,13 @@ class core_filterlib_testcase extends advanced_testcase { $this->assertEquals(array(), $filters); } - /** - * @expectedException coding_exception - */ public function test_available_in_context_exception_with_syscontext() { $this->resetAfterTest(); [ 'syscontext' => $syscontext ] = $this->setup_available_in_context_tests(); // Exercise SUT. + $this->expectException(coding_exception::class); filter_get_available_in_context($syscontext); } diff --git a/lib/tests/moodle_page_test.php b/lib/tests/moodle_page_test.php index 0159a6c5bec..fac043cef9f 100644 --- a/lib/tests/moodle_page_test.php +++ b/lib/tests/moodle_page_test.php @@ -83,32 +83,25 @@ class core_moodle_page_testcase extends advanced_testcase { $this->assertSame($originalcourse, $COURSE); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_course_once_theme_set() { // Setup fixture. $this->testpage->force_theme(theme_config::DEFAULT_THEME); $course = $this->getDataGenerator()->create_course(); // Exercise SUT. + $this->expectException(coding_exception::class); $this->testpage->set_course($course); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_category_once_theme_set() { // Setup fixture. $this->testpage->force_theme(theme_config::DEFAULT_THEME); // Exercise SUT. + $this->expectException(coding_exception::class); $this->testpage->set_category_by_id(123); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_category_once_course_set() { // Setup fixture. $course = $this->getDataGenerator()->create_course(); @@ -116,6 +109,7 @@ class core_moodle_page_testcase extends advanced_testcase { $this->testpage->set_course($course); // Exercise SUT. + $this->expectException(coding_exception::class); $this->testpage->set_category_by_id(123); } @@ -145,11 +139,9 @@ class core_moodle_page_testcase extends advanced_testcase { $this->assertEquals(moodle_page::STATE_DONE, $this->testpage->state); } - /** - * @expectedException coding_exception - */ public function test_set_state_cannot_skip_one() { // Exercise SUT. + $this->expectException(coding_exception::class); $this->testpage->set_state(moodle_page::STATE_IN_BODY); } @@ -396,15 +388,13 @@ class core_moodle_page_testcase extends advanced_testcase { $this->assertEquals($cm->id, $this->testpage->cm->id); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_activity_record_before_cm() { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); $cm = get_coursemodule_from_id('forum', $forum->cmid); // Exercise SUT. + $this->expectException(coding_exception::class); $this->testpage->set_activity_record($forum); } @@ -444,9 +434,6 @@ class core_moodle_page_testcase extends advanced_testcase { $this->assertEquals($forum, $this->testpage->activityrecord); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_inconsistent_activity_record_course() { // Setup fixture. $course = $this->getDataGenerator()->create_course(); @@ -455,12 +442,10 @@ class core_moodle_page_testcase extends advanced_testcase { $this->testpage->set_cm($cm); // Exercise SUT. $forum->course = 13; + $this->expectException(coding_exception::class); $this->testpage->set_activity_record($forum); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_inconsistent_activity_record_instance() { // Setup fixture. $course = $this->getDataGenerator()->create_course(); @@ -469,6 +454,7 @@ class core_moodle_page_testcase extends advanced_testcase { $this->testpage->set_cm($cm); // Exercise SUT. $forum->id = 13; + $this->expectException(coding_exception::class); $this->testpage->set_activity_record($forum); } @@ -498,9 +484,6 @@ class core_moodle_page_testcase extends advanced_testcase { $this->assertEquals($forum, $this->testpage->activityrecord); } - /** - * @expectedException coding_exception - */ public function test_cannot_set_cm_with_inconsistent_course() { // Setup fixture. $course = $this->getDataGenerator()->create_course(); @@ -508,6 +491,7 @@ class core_moodle_page_testcase extends advanced_testcase { $cm = get_coursemodule_from_id('forum', $forum->cmid); // Exercise SUT. $cm->course = 13; + $this->expectException(coding_exception::class); $this->testpage->set_cm($cm, $course); } diff --git a/lib/tests/moodle_url_test.php b/lib/tests/moodle_url_test.php index c5a9be4d0d7..a501c8bb2e0 100644 --- a/lib/tests/moodle_url_test.php +++ b/lib/tests/moodle_url_test.php @@ -121,11 +121,10 @@ class core_moodle_url_testcase extends advanced_testcase { /** * Test set bad scheme on Moodle URL objects. - * - * @expectedException coding_exception */ public function test_moodle_url_set_bad_scheme() { $url = new moodle_url('http://moodle.org/foo/bar'); + $this->expectException(coding_exception::class); $url->set_scheme('not a valid $ scheme'); } @@ -200,36 +199,30 @@ class core_moodle_url_testcase extends advanced_testcase { $this->assertSame('/', $url3->out_as_local_url()); } - /** - * @expectedException coding_exception - * @return void - */ public function test_out_as_local_url_error() { $url2 = new moodle_url('http://www.google.com/lib/tests/weblib_test.php'); + $this->expectException(coding_exception::class); $url2->out_as_local_url(); } /** * You should get error with modified url - * - * @expectedException coding_exception - * @return void */ public function test_modified_url_out_as_local_url_error() { global $CFG; $modifiedurl = $CFG->wwwroot.'1'; $url3 = new moodle_url($modifiedurl.'/login/profile.php'); + $this->expectException(coding_exception::class); $url3->out_as_local_url(); } /** * Try get local url from external https url and you should get error - * - * @expectedException coding_exception */ public function test_https_out_as_local_url_error() { $url4 = new moodle_url('https://www.google.com/lib/tests/weblib_test.php'); + $this->expectException(coding_exception::class); $url4->out_as_local_url(); } diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 20366f624b8..d8a629908a9 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -2225,12 +2225,10 @@ class core_moodlelib_testcase extends advanced_testcase { $COURSE->lang = $originallang; } - /** - * @expectedException PHPUnit\Framework\Error\Warning - */ public function test_get_string_limitation() { // This is one of the limitations to the lang_string class. It can't be // used as a key. + $this->expectException(\PHPUnit\Framework\Error\Warning::class); $array = array(get_string('yes', null, null, true) => 'yes'); } diff --git a/lib/tests/mustache_template_finder_test.php b/lib/tests/mustache_template_finder_test.php index 0f1fceb5a79..4c5fadf2f14 100644 --- a/lib/tests/mustache_template_finder_test.php +++ b/lib/tests/mustache_template_finder_test.php @@ -102,11 +102,10 @@ class core_output_mustache_template_finder_testcase extends advanced_testcase { /** * Tests for get_template_directories_for_component when dealing with an invalid component. - * - * @expectedException coding_exception */ public function test_invalid_component_get_template_directories_for_component() { // Test something invalid. + $this->expectException(coding_exception::class); mustache_template_finder::get_template_directories_for_component('octopus', 'classic'); } @@ -191,10 +190,9 @@ class core_output_mustache_template_finder_testcase extends advanced_testcase { /** * Tests for get_template_filepath when dealing with an invalid component. - * - * @expectedException moodle_exception */ public function test_invalid_component_get_template_filepath() { + $this->expectException(moodle_exception::class); mustache_template_finder::get_template_filepath('core/octopus', 'classic'); } } diff --git a/lib/tests/persistent_test.php b/lib/tests/persistent_test.php index 711903e1c98..dbddd3d03c4 100644 --- a/lib/tests/persistent_test.php +++ b/lib/tests/persistent_test.php @@ -174,15 +174,13 @@ class core_persistent_testcase extends advanced_testcase { $this->assertEquals($data, $p->to_record()); } - /** - * @expectedException coding_exception - */ public function test_from_record_invalid_param() { $p = new core_testable_persistent(); $data = (object) array( 'invalidparam' => 'abc' ); + $this->expectException(coding_exception::class); $p->from_record($data); } @@ -439,11 +437,9 @@ class core_persistent_testcase extends advanced_testcase { $this->assertEquals($expected, core_testable_persistent::get_sql_fields('c', 'prefix_')); } - /** - * @expectedException coding_exception - * @expectedExceptionMessageRegExp /The alias .+ exceeds 30 characters/ - */ public function test_get_sql_fields_too_long() { + $this->expectException(coding_exception::class); + $this->expectExceptionMessageMatches('/The alias .+ exceeds 30 characters/'); core_testable_persistent::get_sql_fields('c'); } } diff --git a/lib/tests/plugin_manager_test.php b/lib/tests/plugin_manager_test.php index d118b447025..1801a6127ae 100644 --- a/lib/tests/plugin_manager_test.php +++ b/lib/tests/plugin_manager_test.php @@ -370,11 +370,10 @@ class core_plugin_manager_testcase extends advanced_testcase { /** * The combination of ANY_VERSION + $exactmatch is illegal. - * - * @expectedException moodle_exception */ public function test_get_remote_plugin_info_exception() { $pluginman = testable_core_plugin_manager::instance(); + $this->expectException(moodle_exception::class); $pluginman->get_remote_plugin_info('any_thing', ANY_VERSION, true); } diff --git a/lib/tests/update_checker_test.php b/lib/tests/update_checker_test.php index 102a699f8ec..53b34b605af 100644 --- a/lib/tests/update_checker_test.php +++ b/lib/tests/update_checker_test.php @@ -55,13 +55,12 @@ class core_update_checker_testcase extends advanced_testcase { /** * If there are no fetched data yet, the first cron should fetch them. - * - * @expectedException \core\update\testable_checker_cron_executed */ public function test_cron_initial_fetch() { $provider = testable_checker::instance(); $provider->fakerecentfetch = null; $provider->fakecurrenttimestamp = -1; + $this->expectException(\core\update\testable_checker_cron_executed::class); $provider->cron(); } @@ -78,13 +77,12 @@ class core_update_checker_testcase extends advanced_testcase { /** * If there is an outdated fetch, the cron execution is expected. - * - * @expectedException \core\update\testable_checker_cron_executed */ public function test_cron_has_outdated_fetch() { $provider = testable_checker::instance(); $provider->fakerecentfetch = time() - 49 * HOURSECS; // Fetched 49 hours ago. $provider->fakecurrenttimestamp = -1; + $this->expectException(\core\update\testable_checker_cron_executed::class); $provider->cron(); } @@ -259,14 +257,12 @@ class core_update_checker_testcase extends advanced_testcase { $this->assertEquals(2011010102, $cmp['mod_foo'][0]['version']); } - /** - * @expectedException \core\update\checker_exception - */ public function test_compare_responses_invalid_format() { $provider = testable_checker::instance(); $broken = array( 'status' => 'ERROR' // No 'updates' key here. ); + $this->expectException(\core\update\checker_exception::class); $cmp = $provider->compare_responses($broken, $broken); } diff --git a/lib/tests/update_code_manager_test.php b/lib/tests/update_code_manager_test.php index 872057f9675..b2972217ae3 100644 --- a/lib/tests/update_code_manager_test.php +++ b/lib/tests/update_code_manager_test.php @@ -111,14 +111,12 @@ class core_update_code_manager_testcase extends advanced_testcase { $files = $codeman->unzip_plugin_file($zipfilepath, $targetdir, 'bar'); } - /** - * @expectedException moodle_exception - */ public function test_unzip_plugin_file_multidir() { $codeman = new \core\update\testable_code_manager(); $zipfilepath = __DIR__.'/fixtures/update_validator/zips/multidir.zip'; $targetdir = make_request_directory(); // Attempting to rename the root folder if there are multiple ones should lead to exception. + $this->expectException(moodle_exception::class); $files = $codeman->unzip_plugin_file($zipfilepath, $targetdir, 'foo'); } diff --git a/lib/tests/user_test.php b/lib/tests/user_test.php index ecfd86be462..7bd02a392a1 100644 --- a/lib/tests/user_test.php +++ b/lib/tests/user_test.php @@ -675,10 +675,6 @@ class core_user_testcase extends advanced_testcase { /** * Test get_property_default(). - * - * - * @expectedException coding_exception - * @expectedExceptionMessage Invalid property requested, or the property does not has a default value. */ public function test_get_property_default() { global $CFG; @@ -706,6 +702,8 @@ class core_user_testcase extends advanced_testcase { $timezone = core_user::get_property_default('timezone'); $this->assertEquals('Pacific/Auckland', $timezone); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Invalid property requested, or the property does not has a default value.'); core_user::get_property_default('firstname'); } diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php index c21c311fdc8..3eda2747d00 100644 --- a/message/tests/externallib_test.php +++ b/message/tests/externallib_test.php @@ -1188,7 +1188,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase { /** * Test search_contacts. - * @expectedException moodle_exception */ public function test_search_contacts() { global $DB; @@ -1250,6 +1249,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase { $this->assertEquals($user5->id, $result['id']); // Empty query, will throw an exception. + $this->expectException(moodle_exception::class); $results = core_message_external::search_contacts(''); } diff --git a/mod/assign/tests/externallib_test.php b/mod/assign/tests/externallib_test.php index 2bd40007a2c..4d734a8d1ff 100644 --- a/mod/assign/tests/externallib_test.php +++ b/mod/assign/tests/externallib_test.php @@ -630,8 +630,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * Test lock_submissions - * - * @expectedException moodle_exception */ public function test_lock_submissions() { global $DB, $USER; @@ -691,6 +689,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { 'text'=>'Submission text', 'format'=>FORMAT_MOODLE); $notices = array(); + $this->expectException(moodle_exception::class); $assign->save_submission($data, $notices); } @@ -895,8 +894,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * Test reveal_identities - * - * @expectedException required_capability_exception */ public function test_reveal_identities() { global $DB, $USER; @@ -930,6 +927,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $studentrole->id); $this->setUser($student1); + $this->expectException(required_capability_exception::class); $result = mod_assign_external::reveal_identities($instance->id); $result = external_api::clean_returnvalue(mod_assign_external::reveal_identities_returns(), $result); $this->assertEquals(1, count($result)); @@ -1344,8 +1342,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * Test save grades for a team submission - * - * @expectedException invalid_parameter_exception */ public function test_save_grades_with_group_submission() { global $DB, $USER, $CFG; @@ -1439,6 +1435,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $grades1[] = $student2gradeinfo; // Expect an exception since 2 grades have been submitted for the same team. + $this->expectException(invalid_parameter_exception::class); $result = mod_assign_external::save_grades($instance->id, true, $grades1); $result = external_api::clean_returnvalue(mod_assign_external::save_grades_returns(), $result); @@ -1649,8 +1646,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * Test view_grading_table - * - * @expectedException dml_missing_record_exception */ public function test_view_grading_table_invalid_instance() { global $DB; @@ -1664,13 +1659,12 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $cm = get_coursemodule_from_instance('assign', $assign->id); // Test invalid instance id. + $this->expectException(dml_missing_record_exception::class); mod_assign_external::view_grading_table(0); } /** * Test view_grading_table - * - * @expectedException require_login_exception */ public function test_view_grading_table_not_enrolled() { global $DB; @@ -1687,6 +1681,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $user = self::getDataGenerator()->create_user(); $this->setUser($user); + $this->expectException(require_login_exception::class); mod_assign_external::view_grading_table($assign->id); } @@ -1731,9 +1726,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * Test view_grading_table - * - * @expectedException require_login_exception - * @expectedExceptionMessage Course or activity not accessible. (Activity is hidden) */ public function test_view_grading_table_without_capability() { global $DB; @@ -1759,6 +1751,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { accesslib_clear_all_caches_for_unit_testing(); course_modinfo::clear_instance_cache(); + $this->expectException(require_login_exception::class); + $this->expectExceptionMessage('Course or activity not accessible. (Activity is hidden)'); mod_assign_external::view_grading_table($assign->id); } @@ -2204,8 +2198,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * Test access control for get_submission_status. - * - * @expectedException required_capability_exception */ public function test_get_submission_status_access_control() { $this->resetAfterTest(true); @@ -2215,6 +2207,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $this->setUser($student2); // Access control test. + $this->expectException(required_capability_exception::class); mod_assign_external::get_submission_status($assign->get_instance()->id, $student1->id); } @@ -2338,19 +2331,16 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { /** * get_participant should throw an excaption if the requested assignment doesn't exist. - * - * @expectedException moodle_exception */ public function test_get_participant_no_assignment() { $this->resetAfterTest(true); + $this->expectException(moodle_exception::class); mod_assign_external::get_participant('-1', '-1', false); } /** * get_participant should throw a require_login_exception if the user doesn't have access * to view assignments. - * - * @expectedException require_login_exception */ public function test_get_participant_no_view_capability() { global $DB; @@ -2366,14 +2356,13 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $this->setUser($student); assign_capability('mod/assign:view', CAP_PROHIBIT, $studentrole->id, $context->id, true); + $this->expectException(require_login_exception::class); mod_assign_external::get_participant($assign->id, $student->id, false); } /** * get_participant should throw a required_capability_exception if the user doesn't have access * to view assignment grades. - * - * @expectedException required_capability_exception */ public function test_get_participant_no_grade_capability() { global $DB; @@ -2392,13 +2381,12 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { assign_capability('mod/assign:grade', CAP_PROHIBIT, $teacherrole->id, $context->id, true); accesslib_clear_all_caches_for_unit_testing(); + $this->expectException(required_capability_exception::class); mod_assign_external::get_participant($assign->id, $student->id, false); } /** * get_participant should throw an exception if the user isn't enrolled in the course. - * - * @expectedException moodle_exception */ public function test_get_participant_no_participant() { global $DB; @@ -2411,6 +2399,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $this->setUser($teacher); + $this->expectException(moodle_exception::class); $result = mod_assign_external::get_participant($assign->id, $student->id, false); $result = external_api::clean_returnvalue(mod_assign_external::get_participant_returns(), $result); } diff --git a/mod/choice/tests/events_test.php b/mod/choice/tests/events_test.php index c12258208b4..da42a2a1b78 100644 --- a/mod/choice/tests/events_test.php +++ b/mod/choice/tests/events_test.php @@ -168,8 +168,6 @@ class mod_choice_events_testcase extends advanced_testcase { /** * Test custom validations. - * - * @expectedException coding_exception */ public function test_answer_created_other_exception() { // Generate user data. @@ -183,6 +181,7 @@ class mod_choice_events_testcase extends advanced_testcase { $eventdata['other'] = array(); // Make sure content identifier is always set. + $this->expectException(coding_exception::class); $event = \mod_choice\event\answer_created::create($eventdata); $event->trigger(); $this->assertEventContextNotUsed($event); diff --git a/mod/choice/tests/lib_test.php b/mod/choice/tests/lib_test.php index ff4b5ba8b22..49ab210c1c2 100644 --- a/mod/choice/tests/lib_test.php +++ b/mod/choice/tests/lib_test.php @@ -138,9 +138,6 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase { } - /** - * @expectedException moodle_exception - */ public function test_choice_user_submit_response_validation() { global $USER; @@ -159,6 +156,7 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase { $optionids2 = array_keys($choicewithoptions2->option); // Make sure we cannot submit options from a different choice instance. + $this->expectException(moodle_exception::class); choice_user_submit_response($optionids2[0], $choice1, $USER->id, $course, $cm); } diff --git a/mod/forum/tests/events_test.php b/mod/forum/tests/events_test.php index 01b203ae8e7..4177d19878f 100644 --- a/mod/forum/tests/events_test.php +++ b/mod/forum/tests/events_test.php @@ -54,9 +54,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure course_searched event validates that searchterm is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'searchterm' value must be set in other. */ public function test_course_searched_searchterm_validation() { $course = $this->getDataGenerator()->create_course(); @@ -65,14 +62,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'context' => $coursectx, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'searchterm' value must be set in other."); \mod_forum\event\course_searched::create($params); } /** * Ensure course_searched event validates that context is the correct level. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_COURSE. */ public function test_course_searched_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -83,6 +79,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('searchterm' => 'testing'), ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_COURSE.'); \mod_forum\event\course_searched::create($params); } @@ -123,9 +121,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure discussion_created event validates that forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_discussion_created_forumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -136,14 +131,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'context' => $context, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\discussion_created::create($params); } /** * Ensure discussion_created event validates that the context is the correct level. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_created_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -154,6 +148,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('forumid' => $forum->id), ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_created::create($params); } @@ -204,9 +200,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure discussion_updated event validates that forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_discussion_updated_forumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -217,14 +210,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'context' => $context, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\discussion_updated::create($params); } /** * Ensure discussion_created event validates that the context is the correct level. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_updated_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -235,6 +227,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('forumid' => $forum->id), ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_updated::create($params); } @@ -283,9 +277,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure discussion_deleted event validates that forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_discussion_deleted_forumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -296,14 +287,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'context' => $context, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\discussion_deleted::create($params); } /** * Ensure discussion_deleted event validates that context is of the correct level. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_deleted_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -314,6 +304,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('forumid' => $forum->id), ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_deleted::create($params); } @@ -363,9 +355,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure discussion_moved event validates that fromforumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'fromforumid' value must be set in other. */ public function test_discussion_moved_fromforumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -378,14 +367,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('toforumid' => $toforum->id) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'fromforumid' value must be set in other."); \mod_forum\event\discussion_moved::create($params); } /** * Ensure discussion_moved event validates that toforumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'toforumid' value must be set in other. */ public function test_discussion_moved_toforumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -398,14 +386,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('fromforumid' => $fromforum->id) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'toforumid' value must be set in other."); \mod_forum\event\discussion_moved::create($params); } /** * Ensure discussion_moved event validates that the context level is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_moved_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -426,6 +413,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('fromforumid' => $fromforum->id, 'toforumid' => $toforum->id) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_moved::create($params); } @@ -477,9 +466,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure discussion_viewed event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_viewed_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -498,6 +484,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'objectid' => $discussion->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_viewed::create($params); } @@ -546,9 +534,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure course_module_viewed event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_course_module_viewed_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -559,6 +544,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'objectid' => $forum->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\course_module_viewed::create($params); } @@ -600,9 +587,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure subscription_created event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_subscription_created_forumid_validation() { $user = $this->getDataGenerator()->create_user(); @@ -614,14 +598,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\subscription_created::create($params); } /** * Ensure subscription_created event validates that the relateduserid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_subscription_created_relateduserid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -632,14 +615,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'objectid' => $forum->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\subscription_created::create($params); } /** * Ensure subscription_created event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_subscription_created_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); @@ -652,6 +634,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\subscription_created::create($params); } @@ -703,9 +687,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure subscription_deleted event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_subscription_deleted_forumid_validation() { $user = $this->getDataGenerator()->create_user(); @@ -717,14 +698,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\subscription_deleted::create($params); } /** * Ensure subscription_deleted event validates that the relateduserid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_subscription_deleted_relateduserid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -735,14 +715,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'objectid' => $forum->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\subscription_deleted::create($params); } /** * Ensure subscription_deleted event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_subscription_deleted_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); @@ -755,6 +734,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\subscription_deleted::create($params); } @@ -806,9 +787,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure readtracking_enabled event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_readtracking_enabled_forumid_validation() { $user = $this->getDataGenerator()->create_user(); @@ -820,14 +798,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\readtracking_enabled::create($params); } /** * Ensure readtracking_enabled event validates that the relateduserid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_readtracking_enabled_relateduserid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -838,14 +815,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'objectid' => $forum->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\readtracking_enabled::create($params); } /** * Ensure readtracking_enabled event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_readtracking_enabled_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); @@ -858,6 +834,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\readtracking_enabled::create($params); } @@ -900,9 +878,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure readtracking_disabled event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_readtracking_disabled_forumid_validation() { $user = $this->getDataGenerator()->create_user(); @@ -914,14 +889,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\readtracking_disabled::create($params); } /** * Ensure readtracking_disabled event validates that the relateduserid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_readtracking_disabled_relateduserid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -932,14 +906,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'objectid' => $forum->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\readtracking_disabled::create($params); } /** * Ensure readtracking_disabled event validates that the contextlevel is correct - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_readtracking_disabled_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); @@ -952,6 +925,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\readtracking_disabled::create($params); } @@ -994,9 +969,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure subscribers_viewed event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_subscribers_viewed_forumid_validation() { $user = $this->getDataGenerator()->create_user(); @@ -1008,14 +980,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\subscribers_viewed::create($params); } /** * Ensure subscribers_viewed event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_subscribers_viewed_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); @@ -1028,6 +999,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\subscribers_viewed::create($params); } @@ -1066,9 +1039,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure user_report_viewed event validates that the reportmode is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'reportmode' value must be set in other. */ public function test_user_report_viewed_reportmode_validation() { $user = $this->getDataGenerator()->create_user(); @@ -1079,14 +1049,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'reportmode' value must be set in other."); \mod_forum\event\user_report_viewed::create($params); } /** * Ensure user_report_viewed event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER. */ public function test_user_report_viewed_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); @@ -1099,14 +1068,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'relateduserid' => $user->id, ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER.'); \mod_forum\event\user_report_viewed::create($params); } /** * Ensure user_report_viewed event validates that the relateduserid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_user_report_viewed_relateduserid_validation() { @@ -1115,6 +1083,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('reportmode' => 'posts'), ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\user_report_viewed::create($params); } @@ -1178,9 +1148,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure post_created event validates that the discussionid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'discussionid' value must be set in other. */ public function test_post_created_discussionid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1206,14 +1173,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'discussionid' value must be set in other."); \mod_forum\event\post_created::create($params); } /** * Ensure post_created event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_post_created_forumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1239,14 +1205,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\post_created::create($params); } /** * Ensure post_created event validates that the forumtype is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumtype' value must be set in other. */ public function test_post_created_forumtype_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1272,14 +1237,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumtype' value must be set in other."); \mod_forum\event\post_created::create($params); } /** * Ensure post_created event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_post_created_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1305,6 +1269,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\post_created::create($params); } @@ -1439,9 +1405,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure post_deleted event validates that the discussionid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'discussionid' value must be set in other. */ public function test_post_deleted_discussionid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1467,14 +1430,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'discussionid' value must be set in other."); \mod_forum\event\post_deleted::create($params); } /** * Ensure post_deleted event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_post_deleted_forumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1500,14 +1462,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\post_deleted::create($params); } /** * Ensure post_deleted event validates that the forumtype is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumtype' value must be set in other. */ public function test_post_deleted_forumtype_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1533,14 +1494,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumtype' value must be set in other."); \mod_forum\event\post_deleted::create($params); } /** * Ensure post_deleted event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_post_deleted_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1566,6 +1526,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\post_deleted::create($params); } @@ -1711,9 +1673,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Ensure post_updated event validates that the discussionid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'discussionid' value must be set in other. */ public function test_post_updated_discussionid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1739,14 +1698,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'discussionid' value must be set in other."); \mod_forum\event\post_updated::create($params); } /** * Ensure post_updated event validates that the forumid is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_post_updated_forumid_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1772,14 +1730,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\post_updated::create($params); } /** * Ensure post_updated event validates that the forumtype is set. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumtype' value must be set in other. */ public function test_post_updated_forumtype_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1805,14 +1762,13 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumtype' value must be set in other."); \mod_forum\event\post_updated::create($params); } /** * Ensure post_updated event validates that the contextlevel is correct. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_post_updated_context_validation() { $course = $this->getDataGenerator()->create_course(); @@ -1838,6 +1794,8 @@ class mod_forum_events_testcase extends advanced_testcase { 'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\post_updated::create($params); } @@ -1988,7 +1946,6 @@ class mod_forum_events_testcase extends advanced_testcase { // Checking that the event contains the expected values. $this->assertInstanceOf('\mod_forum\event\discussion_subscription_created', $event); - $cm = get_coursemodule_from_instance('forum', $discussion->forum); $context = \context_module::instance($cm->id); $this->assertEquals($context, $event->get_context()); @@ -2064,9 +2021,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Test contextlevel validation of discussion_subscription_created event. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_subscription_created_validation_contextlevel() { global $CFG, $DB; @@ -2115,14 +2069,13 @@ class mod_forum_events_testcase extends advanced_testcase { ); // Without an invalid context. + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_subscription_created::create($params); } /** * Test discussion validation of discussion_subscription_created event. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'discussion' value must be set in other. */ public function test_discussion_subscription_created_validation_discussion() { global $CFG, $DB; @@ -2168,14 +2121,13 @@ class mod_forum_events_testcase extends advanced_testcase { ) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'discussion' value must be set in other."); \mod_forum\event\discussion_subscription_created::create($params); } /** * Test forumid validation of discussion_subscription_created event. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_discussion_subscription_created_validation_forumid() { global $CFG, $DB; @@ -2221,14 +2173,13 @@ class mod_forum_events_testcase extends advanced_testcase { ) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\discussion_subscription_created::create($params); } /** * Test relateduserid validation of discussion_subscription_created event. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_discussion_subscription_created_validation_relateduserid() { global $CFG, $DB; @@ -2276,6 +2227,8 @@ class mod_forum_events_testcase extends advanced_testcase { ) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\discussion_subscription_created::create($params); } @@ -2320,7 +2273,6 @@ class mod_forum_events_testcase extends advanced_testcase { // Checking that the event contains the expected values. $this->assertInstanceOf('\mod_forum\event\discussion_subscription_deleted', $event); - $cm = get_coursemodule_from_instance('forum', $discussion->forum); $context = \context_module::instance($cm->id); $this->assertEquals($context, $event->get_context()); @@ -2420,9 +2372,6 @@ class mod_forum_events_testcase extends advanced_testcase { /** * Test contextlevel validation of discussion_subscription_deleted event. - * - * @expectedException coding_exception - * @expectedExceptionMessage Context level must be CONTEXT_MODULE. */ public function test_discussion_subscription_deleted_validation_contextlevel() { global $CFG, $DB; @@ -2471,14 +2420,13 @@ class mod_forum_events_testcase extends advanced_testcase { ); // Without an invalid context. + $this->expectException(coding_exception::class); + $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.'); \mod_forum\event\discussion_subscription_deleted::create($params); } /** * Test discussion validation of discussion_subscription_deleted event. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'discussion' value must be set in other. */ public function test_discussion_subscription_deleted_validation_discussion() { global $CFG, $DB; @@ -2524,14 +2472,13 @@ class mod_forum_events_testcase extends advanced_testcase { ) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'discussion' value must be set in other."); \mod_forum\event\discussion_subscription_deleted::create($params); } /** * Test forumid validation of discussion_subscription_deleted event. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'forumid' value must be set in other. */ public function test_discussion_subscription_deleted_validation_forumid() { global $CFG, $DB; @@ -2577,14 +2524,13 @@ class mod_forum_events_testcase extends advanced_testcase { ) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'forumid' value must be set in other."); \mod_forum\event\discussion_subscription_deleted::create($params); } /** * Test relateduserid validation of discussion_subscription_deleted event. - * - * @expectedException coding_exception - * @expectedExceptionMessage The 'relateduserid' must be set. */ public function test_discussion_subscription_deleted_validation_relateduserid() { global $CFG, $DB; @@ -2632,6 +2578,8 @@ class mod_forum_events_testcase extends advanced_testcase { ) ); + $this->expectException(coding_exception::class); + $this->expectExceptionMessage("The 'relateduserid' must be set."); \mod_forum\event\discussion_subscription_deleted::create($params); } diff --git a/mod/glossary/tests/external_test.php b/mod/glossary/tests/external_test.php index 4f6a849f7cd..38bb28e76c3 100644 --- a/mod/glossary/tests/external_test.php +++ b/mod/glossary/tests/external_test.php @@ -112,10 +112,6 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase { $sink->close(); } - /** - * @expectedException require_login_exception - * @expectedExceptionMessage Activity is hidden - */ public function test_view_glossary_without_permission() { $this->resetAfterTest(true); @@ -134,13 +130,11 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase { // Assertion. $this->setUser($u1); + $this->expectException(require_login_exception::class); + $this->expectExceptionMessage('Activity is hidden'); mod_glossary_external::view_glossary($g1->id, 'letter'); } - /** - * @expectedException require_login_exception - * @expectedExceptionMessage Activity is hidden - */ public function test_view_entry() { $this->resetAfterTest(true); @@ -188,6 +182,8 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase { } // Test non-readable entry. + $this->expectException(require_login_exception::class); + $this->expectExceptionMessage('Activity is hidden'); mod_glossary_external::view_entry($e4->id); } diff --git a/mod/quiz/accessrule/seb/tests/link_generator_test.php b/mod/quiz/accessrule/seb/tests/link_generator_test.php index 6d61979a706..1cb608ce7b4 100644 --- a/mod/quiz/accessrule/seb/tests/link_generator_test.php +++ b/mod/quiz/accessrule/seb/tests/link_generator_test.php @@ -96,7 +96,7 @@ class quizaccess_seb_link_generator_testcase extends advanced_testcase { */ public function test_course_module_does_not_exist() { $this->expectException(dml_exception::class); - $this->expectExceptionMessageRegExp("/^Can't find data record in database.*/"); + $this->expectExceptionMessageMatches("/^Can't find data record in database.*/"); $generator = link_generator::get_link(123456, false); } } diff --git a/mod/quiz/tests/structure_test.php b/mod/quiz/tests/structure_test.php index 5388b9883a7..eb4fe103038 100644 --- a/mod/quiz/tests/structure_test.php +++ b/mod/quiz/tests/structure_test.php @@ -259,9 +259,6 @@ class mod_quiz_structure_testcase extends advanced_testcase { ), $structure); } - /** - * @expectedException coding_exception - */ public function test_cannot_remove_first_section() { $quizobj = $this->create_test_quiz(array( 'Heading 1', @@ -272,6 +269,7 @@ class mod_quiz_structure_testcase extends advanced_testcase { $sections = $structure->get_sections(); $section = reset($sections); + $this->expectException(coding_exception::class); $structure->remove_section_heading($section->id); } @@ -436,9 +434,6 @@ class mod_quiz_structure_testcase extends advanced_testcase { ), $structure); } - /** - * @expectedException coding_exception - */ public function test_move_slot_too_small_page_number_detected() { $quizobj = $this->create_test_quiz(array( array('TF1', 1, 'truefalse'), @@ -449,12 +444,10 @@ class mod_quiz_structure_testcase extends advanced_testcase { $idtomove = $structure->get_question_in_slot(3)->slotid; $idmoveafter = $structure->get_question_in_slot(2)->slotid; + $this->expectException(coding_exception::class); $structure->move_slot($idtomove, $idmoveafter, '1'); } - /** - * @expectedException coding_exception - */ public function test_move_slot_too_large_page_number_detected() { $quizobj = $this->create_test_quiz(array( array('TF1', 1, 'truefalse'), @@ -465,6 +458,7 @@ class mod_quiz_structure_testcase extends advanced_testcase { $idtomove = $structure->get_question_in_slot(1)->slotid; $idmoveafter = $structure->get_question_in_slot(2)->slotid; + $this->expectException(coding_exception::class); $structure->move_slot($idtomove, $idmoveafter, '4'); } @@ -722,8 +716,6 @@ class mod_quiz_structure_testcase extends advanced_testcase { /** * Unit test to make sue it is not possible to remove all slots in a section at once. - * - * @expectedException coding_exception */ public function test_cannot_remove_all_slots_in_a_section() { $quizobj = $this->create_test_quiz(array( @@ -735,12 +727,10 @@ class mod_quiz_structure_testcase extends advanced_testcase { $structure = \mod_quiz\structure::create_for_quiz($quizobj); $structure->remove_slot(1); + $this->expectException(coding_exception::class); $structure->remove_slot(2); } - /** - * @expectedException coding_exception - */ public function test_cannot_remove_last_slot_in_a_section() { $quizobj = $this->create_test_quiz(array( array('TF1', 1, 'truefalse'), @@ -750,6 +740,7 @@ class mod_quiz_structure_testcase extends advanced_testcase { )); $structure = \mod_quiz\structure::create_for_quiz($quizobj); + $this->expectException(coding_exception::class); $structure->remove_slot(3); } diff --git a/mod/scorm/tests/events_test.php b/mod/scorm/tests/events_test.php index 24e41b295a6..b7562792266 100644 --- a/mod/scorm/tests/events_test.php +++ b/mod/scorm/tests/events_test.php @@ -59,8 +59,6 @@ class mod_scorm_event_testcase extends advanced_testcase { /** * Tests for attempt deleted event - * - * @expectedException coding_exception */ public function test_attempt_deleted_event() { @@ -87,11 +85,11 @@ class mod_scorm_event_testcase extends advanced_testcase { $this->assertEventContextNotUsed($event); // Test event validations. + $this->expectException(coding_exception::class); \mod_scorm\event\attempt_deleted::create(array( 'contextid' => 5, 'relateduserid' => 2 )); - $this->fail('event \\mod_scorm\\event\\attempt_deleted is not validating events properly'); } /** @@ -231,8 +229,6 @@ class mod_scorm_event_testcase extends advanced_testcase { /** Tests for sco launched event. * * There is no api involved so the best we can do is test legacy data and validations by triggering event manually. - * - * @expectedException coding_exception */ public function test_sco_launched_event() { $this->resetAfterTest(); @@ -256,12 +252,12 @@ class mod_scorm_event_testcase extends advanced_testcase { $this->assertEventContextNotUsed($event); // Test validations. + $this->expectException(coding_exception::class); \mod_scorm\event\sco_launched::create(array( 'objectid' => $this->eventscorm->id, 'context' => context_module::instance($this->eventcm->id), 'courseid' => $this->eventcourse->id, )); - $this->fail('Event \\mod_scorm\\event\\sco_launched is not validating "loadedcontent" properly'); } /** diff --git a/mod/scorm/tests/externallib_test.php b/mod/scorm/tests/externallib_test.php index 79d8f529753..fe8a801ff07 100644 --- a/mod/scorm/tests/externallib_test.php +++ b/mod/scorm/tests/externallib_test.php @@ -174,9 +174,6 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { $this->assertEquals(1, $result['attemptscount']); } - /** - * @expectedException required_capability_exception - */ public function test_mod_scorm_get_scorm_attempt_count_others_as_student() { // Create a second student. $student2 = self::getDataGenerator()->create_user(); @@ -186,27 +183,24 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { self::setUser($student2); // I should not be able to view the attempts of another student. + $this->expectException(required_capability_exception::class); mod_scorm_external::get_scorm_attempt_count($this->scorm->id, $this->student->id); } - /** - * @expectedException moodle_exception - */ public function test_mod_scorm_get_scorm_attempt_count_invalid_instanceid() { // As student. self::setUser($this->student); // Test invalid instance id. + $this->expectException(moodle_exception::class); mod_scorm_external::get_scorm_attempt_count(0, $this->student->id); } - /** - * @expectedException moodle_exception - */ public function test_mod_scorm_get_scorm_attempt_count_invalid_userid() { // As student. self::setUser($this->student); + $this->expectException(moodle_exception::class); mod_scorm_external::get_scorm_attempt_count($this->scorm->id, -1); } diff --git a/mod/wiki/tests/externallib_test.php b/mod/wiki/tests/externallib_test.php index 6d543154ffa..c91fd936c04 100644 --- a/mod/wiki/tests/externallib_test.php +++ b/mod/wiki/tests/externallib_test.php @@ -459,30 +459,26 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { /** * Test get_subwiki_pages using an invalid wiki instance. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_invalid_instance() { + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages(0); } /** * Test get_subwiki_pages using a user not enrolled in the course. - * - * @expectedException require_login_exception */ public function test_get_subwiki_pages_unenrolled_user() { // Create and use the user. $usernotenrolled = self::getDataGenerator()->create_user(); $this->setUser($usernotenrolled); + $this->expectException(require_login_exception::class); mod_wiki_external::get_subwiki_pages($this->wiki->id); } /** * Test get_subwiki_pages using a hidden wiki as student. - * - * @expectedException require_login_exception */ public function test_get_subwiki_pages_hidden_wiki_as_student() { // Create a hidden wiki and try to get the list of pages. @@ -490,13 +486,12 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { array('course' => $this->course->id, 'visible' => false)); $this->setUser($this->student); + $this->expectException(require_login_exception::class); mod_wiki_external::get_subwiki_pages($hiddenwiki->id); } /** * Test get_subwiki_pages without the viewpage capability. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_without_viewpage_capability() { // Prohibit capability = mod/wiki:viewpage on the course for students. @@ -505,38 +500,35 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { accesslib_clear_all_caches_for_unit_testing(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($this->wiki->id); } /** * Test get_subwiki_pages using an invalid userid. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_invalid_userid() { // Create an individual wiki. $indwiki = $this->getDataGenerator()->create_module('wiki', array('course' => $this->course->id, 'wikimode' => 'individual')); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($indwiki->id, 0, -10); } /** * Test get_subwiki_pages using an invalid groupid. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_invalid_groupid() { // Create testing data. $this->create_collaborative_wikis_with_groups(); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($this->wikisep->id, -111); } /** * Test get_subwiki_pages, check that a student can't see another user pages in an individual wiki without groups. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_individual_student_see_other_user() { // Create an individual wiki. @@ -544,62 +536,59 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { array('course' => $this->course->id, 'wikimode' => 'individual')); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($indwiki->id, 0, $this->teacher->id); } /** * Test get_subwiki_pages, check that a student can't get the pages from another group in * a collaborative wiki using separate groups. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_collaborative_separate_groups_student_see_other_group() { // Create testing data. $this->create_collaborative_wikis_with_groups(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($this->wikisep->id, $this->group2->id); } /** * Test get_subwiki_pages, check that a student can't get the pages from another group in * an individual wiki using separate groups. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_individual_separate_groups_student_see_other_group() { // Create testing data. $this->create_individual_wikis_with_groups(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($this->wikisepind->id, $this->group2->id, $this->teacher->id); } /** * Test get_subwiki_pages, check that a student can't get the pages from all participants in * a collaborative wiki using separate groups. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_collaborative_separate_groups_student_see_all_participants() { // Create testing data. $this->create_collaborative_wikis_with_groups(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($this->wikisep->id, 0); } /** * Test get_subwiki_pages, check that a student can't get the pages from all participants in * an individual wiki using separate groups. - * - * @expectedException moodle_exception */ public function test_get_subwiki_pages_individual_separate_groups_student_see_all_participants() { // Create testing data. $this->create_individual_wikis_with_groups(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_pages($this->wikisepind->id, 0, $this->teacher->id); } @@ -921,30 +910,26 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { /** * Test get_page_contents using an invalid pageid. - * - * @expectedException moodle_exception */ public function test_get_page_contents_invalid_pageid() { + $this->expectException(moodle_exception::class); mod_wiki_external::get_page_contents(0); } /** * Test get_page_contents using a user not enrolled in the course. - * - * @expectedException require_login_exception */ public function test_get_page_contents_unenrolled_user() { // Create and use the user. $usernotenrolled = self::getDataGenerator()->create_user(); $this->setUser($usernotenrolled); + $this->expectException(require_login_exception::class); mod_wiki_external::get_page_contents($this->firstpage->id); } /** * Test get_page_contents using a hidden wiki as student. - * - * @expectedException require_login_exception */ public function test_get_page_contents_hidden_wiki_as_student() { // Create a hidden wiki and try to get a page contents. @@ -953,13 +938,12 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { $hiddenpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_page($hiddenwiki); $this->setUser($this->student); + $this->expectException(require_login_exception::class); mod_wiki_external::get_page_contents($hiddenpage->id); } /** * Test get_page_contents without the viewpage capability. - * - * @expectedException moodle_exception */ public function test_get_page_contents_without_viewpage_capability() { // Prohibit capability = mod/wiki:viewpage on the course for students. @@ -968,20 +952,20 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { accesslib_clear_all_caches_for_unit_testing(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_page_contents($this->firstpage->id); } /** * Test get_page_contents, check that a student can't get a page from another group when * using separate groups. - * - * @expectedException moodle_exception */ public function test_get_page_contents_separate_groups_student_see_other_group() { // Create testing data. $this->create_individual_wikis_with_groups(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_page_contents($this->fpsepg2indt->id); } @@ -1079,14 +1063,13 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { /** * Test get_subwiki_files, check that a student can't get files from another group's subwiki when * using separate groups. - * - * @expectedException moodle_exception */ public function test_get_subwiki_files_separate_groups_student_see_other_group() { // Create testing data. $this->create_collaborative_wikis_with_groups(); $this->setUser($this->student); + $this->expectException(moodle_exception::class); mod_wiki_external::get_subwiki_files($this->wikisep->id, $this->group2->id); } diff --git a/mod/workshop/allocation/random/tests/allocator_test.php b/mod/workshop/allocation/random/tests/allocator_test.php index f04fc98580e..ebbb2e58391 100644 --- a/mod/workshop/allocation/random/tests/allocator_test.php +++ b/mod/workshop/allocation/random/tests/allocator_test.php @@ -114,9 +114,6 @@ class workshopallocation_random_testcase extends advanced_testcase { ), $submissions); } - /** - * @expectedException moodle_exception - */ public function test_index_submissions_by_authors_duplicate_author() { // fixture setup $submissions = array( @@ -124,6 +121,7 @@ class workshopallocation_random_testcase extends advanced_testcase { 87 => (object)array('id' => 121, 'authorid' => 3), ); // exercise SUT + $this->expectException(moodle_exception::class); $submissions = $this->allocator->index_submissions_by_authors($submissions); } diff --git a/mod/workshop/form/accumulative/tests/lib_test.php b/mod/workshop/form/accumulative/tests/lib_test.php index 42b23e13852..c5bd1748482 100644 --- a/mod/workshop/form/accumulative/tests/lib_test.php +++ b/mod/workshop/form/accumulative/tests/lib_test.php @@ -78,14 +78,12 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase { $this->assertEquals(grade_floatval(5/20 * 100), $suggested); } - /** - * @expectedException coding_exception - */ public function test_calculate_peer_grade_negative_weight() { // fixture set-up $this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '-1'); $grades[] = (object)array('dimensionid' => 1003, 'grade' => '20'); // exercise SUT + $this->expectException(coding_exception::class); $suggested = $this->strategy->calculate_peer_grade($grades); } @@ -178,9 +176,6 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase { $this->assertEquals(grade_floatval((1/2*2 + 4/6*3)/5 * 100), $suggested); } - /** - * @expectedException coding_exception - */ public function test_calculate_peer_grade_scale_exception() { $this->resetAfterTest(true); // fixture set-up @@ -189,6 +184,7 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase { $grades[] = (object)array('dimensionid' => 1012, 'grade' => '4.00000'); // exceeds the number of scale items // Exercise SUT. + $this->expectException(coding_exception::class); $suggested = $this->strategy->calculate_peer_grade($grades); } } diff --git a/mod/workshop/tests/locallib_test.php b/mod/workshop/tests/locallib_test.php index 0e12a86c73e..bc53127eddb 100644 --- a/mod/workshop/tests/locallib_test.php +++ b/mod/workshop/tests/locallib_test.php @@ -320,9 +320,6 @@ class mod_workshop_internal_api_testcase extends advanced_testcase { $this->assertEquals($part, $total * $percent / 100); } - /** - * @expectedException coding_exception - */ public function test_percent_to_value_negative() { $this->resetAfterTest(true); // fixture setup @@ -330,12 +327,10 @@ class mod_workshop_internal_api_testcase extends advanced_testcase { $percent = -7.098; // exercise SUT + $this->expectException(coding_exception::class); $part = workshop::percent_to_value($percent, $total); } - /** - * @expectedException coding_exception - */ public function test_percent_to_value_over_hundred() { $this->resetAfterTest(true); // fixture setup @@ -343,6 +338,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase { $percent = 121.08; // exercise SUT + $this->expectException(coding_exception::class); $part = workshop::percent_to_value($percent, $total); } diff --git a/question/behaviour/missing/tests/missingbehaviour_test.php b/question/behaviour/missing/tests/missingbehaviour_test.php index 243bd1c8ab9..bdfb6786d19 100644 --- a/question/behaviour/missing/tests/missingbehaviour_test.php +++ b/question/behaviour/missing/tests/missingbehaviour_test.php @@ -40,39 +40,31 @@ require_once(__DIR__ . '/../behaviour.php'); */ class qbehaviour_missing_test extends advanced_testcase { - /** - * @expectedException moodle_exception - */ public function test_missing_cannot_start() { $qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0); $behaviour = new qbehaviour_missing($qa, 'deferredfeedback'); + $this->expectException(moodle_exception::class); $behaviour->init_first_step(new question_attempt_step(array()), 1); } - /** - * @expectedException moodle_exception - */ public function test_missing_cannot_process() { $qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0); $behaviour = new qbehaviour_missing($qa, 'deferredfeedback'); + $this->expectException(moodle_exception::class); $behaviour->process_action(new question_attempt_pending_step(array())); } - /** - * @expectedException moodle_exception - */ public function test_missing_cannot_get_min_fraction() { $qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0); $behaviour = new qbehaviour_missing($qa, 'deferredfeedback'); + $this->expectException(moodle_exception::class); $behaviour->get_min_fraction(); } - /** - * @expectedException moodle_exception - */ public function test_missing_cannot_get_max_fraction() { $qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0); $behaviour = new qbehaviour_missing($qa, 'deferredfeedback'); + $this->expectException(moodle_exception::class); $behaviour->get_max_fraction(); } diff --git a/question/engine/tests/questionattempt_with_steps_test.php b/question/engine/tests/questionattempt_with_steps_test.php index 7849943591f..9627758baa5 100644 --- a/question/engine/tests/questionattempt_with_steps_test.php +++ b/question/engine/tests/questionattempt_with_steps_test.php @@ -57,10 +57,8 @@ class question_attempt_with_steps_test extends advanced_testcase { $this->qa = null; } - /** - * @expectedException moodle_exception - */ public function test_get_step_before_start() { + $this->expectException(moodle_exception::class); $step = $this->qa->get_step(-1); } @@ -74,10 +72,8 @@ class question_attempt_with_steps_test extends advanced_testcase { $this->assertEquals(2, $step->get_qt_var('i')); } - /** - * @expectedException moodle_exception - */ public function test_get_step_past_end() { + $this->expectException(moodle_exception::class); $step = $this->qa->get_step(3); } diff --git a/question/engine/tests/questionattemptiterator_test.php b/question/engine/tests/questionattemptiterator_test.php index 5453567e3b1..d4ea62b9252 100644 --- a/question/engine/tests/questionattemptiterator_test.php +++ b/question/engine/tests/questionattemptiterator_test.php @@ -87,10 +87,8 @@ class question_attempt_iterator_test extends advanced_testcase { $this->assertFalse(isset($this->iterator[3])); } - /** - * @expectedException moodle_exception - */ public function test_offsetGet_before_start() { + $this->expectException(moodle_exception::class); $step = $this->iterator[0]; } @@ -102,24 +100,18 @@ class question_attempt_iterator_test extends advanced_testcase { $this->assertSame($this->qas[2], $this->iterator[2]); } - /** - * @expectedException moodle_exception - */ public function test_offsetGet_past_end() { + $this->expectException(moodle_exception::class); $step = $this->iterator[3]; } - /** - * @expectedException moodle_exception - */ public function test_cannot_set() { + $this->expectException(moodle_exception::class); $this->iterator[0] = null; } - /** - * @expectedException moodle_exception - */ public function test_cannot_unset() { + $this->expectException(moodle_exception::class); unset($this->iterator[2]); } } diff --git a/question/engine/tests/questionattemptstepiterator_test.php b/question/engine/tests/questionattemptstepiterator_test.php index 543282c6db3..03f84d4442e 100644 --- a/question/engine/tests/questionattemptstepiterator_test.php +++ b/question/engine/tests/questionattemptstepiterator_test.php @@ -104,10 +104,8 @@ class question_attempt_step_iterator_test extends advanced_testcase { $this->assertFalse(isset($this->iterator[3])); } - /** - * @expectedException moodle_exception - */ public function test_offsetGet_before_start() { + $this->expectException(moodle_exception::class); $step = $this->iterator[-1]; } @@ -121,24 +119,18 @@ class question_attempt_step_iterator_test extends advanced_testcase { $this->assertEquals(2, $step->get_qt_var('i')); } - /** - * @expectedException moodle_exception - */ public function test_offsetGet_past_end() { + $this->expectException(moodle_exception::class); $step = $this->iterator[3]; } - /** - * @expectedException moodle_exception - */ public function test_cannot_set() { + $this->expectException(moodle_exception::class); $this->iterator[0] = null; } - /** - * @expectedException moodle_exception - */ public function test_cannot_unset() { + $this->expectException(moodle_exception::class); unset($this->iterator[2]); } } diff --git a/question/engine/tests/questionengine_test.php b/question/engine/tests/questionengine_test.php index db1f72e2521..d313f8571d4 100644 --- a/question/engine/tests/questionengine_test.php +++ b/question/engine/tests/questionengine_test.php @@ -45,11 +45,9 @@ class question_engine_test extends advanced_testcase { $this->assertTrue(class_exists('qbehaviour_deferredfeedback')); } - /** - * @expectedException moodle_exception - */ public function test_load_behaviour_class_missing() { // Exercise SUT + $this->expectException(moodle_exception::class); question_engine::load_behaviour_class('nonexistantbehaviour'); } diff --git a/question/engine/tests/questionutils_test.php b/question/engine/tests/questionutils_test.php index e60960164f4..be65ddc73dd 100644 --- a/question/engine/tests/questionutils_test.php +++ b/question/engine/tests/questionutils_test.php @@ -206,24 +206,18 @@ class question_utils_test extends advanced_testcase { $this->assertEquals('Z', question_utils::int_to_letter(26)); } - /** - * @expectedException moodle_exception - */ public function test_int_to_roman_too_small() { + $this->expectException(moodle_exception::class); question_utils::int_to_roman(0); } - /** - * @expectedException moodle_exception - */ public function test_int_to_roman_too_big() { + $this->expectException(moodle_exception::class); question_utils::int_to_roman(4000); } - /** - * @expectedException moodle_exception - */ public function test_int_to_roman_not_int() { + $this->expectException(moodle_exception::class); question_utils::int_to_roman(1.5); } diff --git a/question/type/calculated/tests/variablesubstituter_test.php b/question/type/calculated/tests/variablesubstituter_test.php index a42d4268080..aff4ca7aaeb 100644 --- a/question/type/calculated/tests/variablesubstituter_test.php +++ b/question/type/calculated/tests/variablesubstituter_test.php @@ -48,32 +48,23 @@ class qtype_calculated_variable_substituter_test extends advanced_testcase { $this->assertEquals(1, $vs->calculate('{a}-{b}')); } - /** - * @expectedException moodle_exception - */ public function test_cannot_use_nonnumbers() { + $this->expectException(moodle_exception::class); $vs = new qtype_calculated_variable_substituter(array('a' => 'frog', 'b' => -2), '.'); } - /** - * @expectedException moodle_exception - */ public function test_invalid_expression() { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); + $this->expectException(moodle_exception::class); $vs->calculate('{a} + {b}?'); } - /** - * @expectedException moodle_exception - */ public function test_tricky_invalid_expression() { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); + $this->expectException(moodle_exception::class); $vs->calculate('{a}{b}'); // Have to make sure this does not just evaluate to 12. } - /** - * @expectedException moodle_exception - */ public function test_division_by_zero_expression() { if (intval(PHP_VERSION) < 7) { @@ -81,6 +72,7 @@ class qtype_calculated_variable_substituter_test extends advanced_testcase { } $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 0), '.'); + $this->expectException(moodle_exception::class); $vs->calculate('{a} / {b}'); } diff --git a/question/type/missingtype/tests/missingtype_test.php b/question/type/missingtype/tests/missingtype_test.php index 600dad278c6..026ab403ca2 100644 --- a/question/type/missingtype/tests/missingtype_test.php +++ b/question/type/missingtype/tests/missingtype_test.php @@ -67,18 +67,14 @@ class qtype_missing_test extends question_testcase { return $questiondata; } - /** - * @expectedException moodle_exception - */ public function test_cannot_grade() { $q = new qtype_missingtype_question(); + $this->expectException(moodle_exception::class); $q->grade_response(array()); } - /** - * @expectedException moodle_exception - */ public function test_load_qtype_strict() { + $this->expectException(moodle_exception::class); $qtype = question_bank::get_qtype('strange_unknown'); } diff --git a/user/tests/myprofile_test.php b/user/tests/myprofile_test.php index 6d94bc7a19a..5315c3e21cd 100644 --- a/user/tests/myprofile_test.php +++ b/user/tests/myprofile_test.php @@ -88,9 +88,6 @@ class core_user_myprofile_testcase extends advanced_testcase { $this->assertSame('class1 class2', $category->classes); } - /** - * @expectedException coding_exception - */ public function test_validate_after_order1() { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); @@ -103,13 +100,11 @@ class core_user_myprofile_testcase extends advanced_testcase { $category->add_node($node2); $category->add_node($node1); + $this->expectException(coding_exception::class); $category->validate_after_order(); } - /** - * @expectedException coding_exception - */ public function test_validate_after_order2() { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); @@ -122,6 +117,7 @@ class core_user_myprofile_testcase extends advanced_testcase { $category->add_node($node2); $category->add_node($node1); + $this->expectException(coding_exception::class); $category->validate_after_order(); } @@ -171,8 +167,6 @@ class core_user_myprofile_testcase extends advanced_testcase { /** * Test category::sort_nodes(). - * - * @expectedException coding_exception */ public function test_sort_nodes1() { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); @@ -219,6 +213,7 @@ class core_user_myprofile_testcase extends advanced_testcase { // Add a node with invalid 'after' and make sure an exception is thrown. $node7 = new \core_user\output\myprofile\node('category', 'node7', 'nodetitle', 'noderandom'); $category->add_node($node7); + $this->expectException(coding_exception::class); $category->sort_nodes(); } @@ -264,8 +259,6 @@ class core_user_myprofile_testcase extends advanced_testcase { /** * Test tree::add_node(). - * - * @expectedException coding_exception */ public function test_tree_add_node() { $tree = new \phpunit_fixture_myprofile_tree(); @@ -276,13 +269,12 @@ class core_user_myprofile_testcase extends advanced_testcase { $this->assertEquals($node1, $node); // Can't add node with same name. + $this->expectException(coding_exception::class); $tree->add_node($node1); } /** * Test tree::add_category(). - * - * @expectedException coding_exception */ public function test_tree_add_category() { $tree = new \phpunit_fixture_myprofile_tree(); @@ -293,6 +285,7 @@ class core_user_myprofile_testcase extends advanced_testcase { $this->assertEquals($category1, $category); // Can't add node with same name. + $this->expectException(coding_exception::class); $tree->add_category($category1); } @@ -341,8 +334,6 @@ class core_user_myprofile_testcase extends advanced_testcase { /** * Test tree::sort_categories(). - * - * @expectedException coding_exception */ public function test_sort_categories() { $tree = new \phpunit_fixture_myprofile_tree('category', 'title', null); @@ -381,6 +372,7 @@ class core_user_myprofile_testcase extends advanced_testcase { $this->assertEquals($category6, $category); // Can't add category with same name. + $this->expectException(coding_exception::class); $tree->add_category($category1); } } From a293b3aea802500c2c9d0c6e7ffc4c9935c7fbec Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 1 Sep 2020 00:07:51 +0200 Subject: [PATCH 07/15] MDL-67673 phpunit: Remove deprecated non-public attribute assertions With PHPUnit 8 a good number of assertions, all them related with operations on non-public attributes have been deprecated. And will be removed with PHPUnit 9. The main point is that unit tests shouldn't be testing non-public APIs (good practice) and those assertions were an error originally. See https://github.com/sebastianbergmann/phpunit/issues/3338 for the complete list and other details. When possible (the attributes being checked are public), the change is simple, just switching to normal assertions. When the attributes are not public we need to find a workaround to be able to test the same using public APIs, or use Reflection, or remove the tests. For the records, this is the regexp used to find all the cases: ag '>(assertAttribute|attribute\(|readAttributte|getStaticAttribute| \ getObjectAttribute)' -G "test.php" --- badges/tests/badgeslib_test.php | 6 +++--- message/tests/api_test.php | 12 ++++++------ .../calculatedsimple/tests/questiontype_test.php | 6 +++--- .../type/description/tests/questiontype_test.php | 2 +- question/type/match/tests/questiontype_test.php | 6 +++--- .../type/multianswer/tests/questiontype_test.php | 12 ++++++------ .../type/multichoice/tests/questiontype_test.php | 8 ++++---- question/type/numerical/tests/questiontype_test.php | 6 +++--- .../type/shortanswer/tests/questiontype_test.php | 6 +++--- question/type/truefalse/tests/questiontype_test.php | 6 +++--- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/badges/tests/badgeslib_test.php b/badges/tests/badgeslib_test.php index 4c5c05930a4..fc80b9b4ff2 100644 --- a/badges/tests/badgeslib_test.php +++ b/badges/tests/badgeslib_test.php @@ -199,15 +199,15 @@ class core_badges_badgeslib_testcase extends advanced_testcase { $badge = new badge($this->badgeid); $old_status = $badge->status; $badge->set_status(BADGE_STATUS_ACTIVE); - $this->assertAttributeNotEquals($old_status, 'status', $badge); - $this->assertAttributeEquals(BADGE_STATUS_ACTIVE, 'status', $badge); + $this->assertNotEquals($old_status, $badge->status); + $this->assertEquals(BADGE_STATUS_ACTIVE, $badge->status); } public function test_delete_badge() { $badge = new badge($this->badgeid); $badge->delete(); // We don't actually delete badges. We archive them. - $this->assertAttributeEquals(BADGE_STATUS_ARCHIVED, 'status', $badge); + $this->assertEquals(BADGE_STATUS_ARCHIVED, $badge->status); } /** diff --git a/message/tests/api_test.php b/message/tests/api_test.php index 917ab4e3c0c..abcacd8f89d 100644 --- a/message/tests/api_test.php +++ b/message/tests/api_test.php @@ -5572,8 +5572,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { // Verify the message returned. $this->assertInstanceOf(\stdClass::class, $message1); $this->assertObjectHasAttribute('id', $message1); - $this->assertAttributeEquals($user1->id, 'useridfrom', $message1); - $this->assertAttributeEquals('this is a message', 'text', $message1); + $this->assertEquals($user1->id, $message1->useridfrom); + $this->assertEquals('this is a message', $message1->text); $this->assertObjectHasAttribute('timecreated', $message1); // Verify events. Note: the event is a message read event because of an if (PHPUNIT) conditional within message_send(), @@ -5614,8 +5614,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { // Verify the message returned. $this->assertInstanceOf(\stdClass::class, $message1); $this->assertObjectHasAttribute('id', $message1); - $this->assertAttributeEquals($user1->id, 'useridfrom', $message1); - $this->assertAttributeEquals('message to the group', 'text', $message1); + $this->assertEquals($user1->id, $message1->useridfrom); + $this->assertEquals('message to the group', $message1->text); $this->assertObjectHasAttribute('timecreated', $message1); // Test customdata. $customdata = json_decode($messages[0]->customdata); @@ -5683,8 +5683,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { // Verify the message returned. $this->assertInstanceOf(\stdClass::class, $message1); $this->assertObjectHasAttribute('id', $message1); - $this->assertAttributeEquals($user1->id, 'useridfrom', $message1); - $this->assertAttributeEquals('message to the group', 'text', $message1); + $this->assertEquals($user1->id, $message1->useridfrom); + $this->assertEquals('message to the group', $message1->text); $this->assertObjectHasAttribute('timecreated', $message1); // Test customdata. $customdata = json_decode($messages[0]->customdata); diff --git a/question/type/calculatedsimple/tests/questiontype_test.php b/question/type/calculatedsimple/tests/questiontype_test.php index 35483c6732a..d18bd3f35f2 100644 --- a/question/type/calculatedsimple/tests/questiontype_test.php +++ b/question/type/calculatedsimple/tests/questiontype_test.php @@ -90,13 +90,13 @@ class qtype_calculatedsimple_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if ($optionname != 'answers') { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -104,7 +104,7 @@ class qtype_calculatedsimple_test extends advanced_testcase { $actualanswer = array_shift($actualquestiondata->options->answers); foreach ($answer as $ansproperty => $ansvalue) { if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) { - $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer); + $this->assertEquals($ansvalue, $actualanswer->$ansproperty); } } } diff --git a/question/type/description/tests/questiontype_test.php b/question/type/description/tests/questiontype_test.php index b2444800cee..7e0dd575be9 100644 --- a/question/type/description/tests/questiontype_test.php +++ b/question/type/description/tests/questiontype_test.php @@ -95,7 +95,7 @@ class qtype_description_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } } diff --git a/question/type/match/tests/questiontype_test.php b/question/type/match/tests/questiontype_test.php index 0da8cacb219..dd9ee1c806e 100644 --- a/question/type/match/tests/questiontype_test.php +++ b/question/type/match/tests/questiontype_test.php @@ -185,13 +185,13 @@ class qtype_match_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options', 'stamp'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if ($optionname != 'subquestions') { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -202,7 +202,7 @@ class qtype_match_test extends advanced_testcase { $actualsubq = array_shift($actualquestiondata->options->subquestions); foreach ($subq as $subqproperty => $subqvalue) { if (!in_array($subqproperty, $subqpropstoignore)) { - $this->assertAttributeEquals($subqvalue, $subqproperty, $actualsubq); + $this->assertEquals($subqvalue, $actualsubq->$subqproperty); } } } diff --git a/question/type/multianswer/tests/questiontype_test.php b/question/type/multianswer/tests/questiontype_test.php index eb8e6071d4b..defb2bda1da 100644 --- a/question/type/multianswer/tests/questiontype_test.php +++ b/question/type/multianswer/tests/questiontype_test.php @@ -251,13 +251,13 @@ class qtype_multianswer_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options', 'hints', 'stamp'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if ($optionname != 'questions') { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -265,7 +265,7 @@ class qtype_multianswer_test extends advanced_testcase { $actualhint = array_shift($actualquestiondata->hints); foreach ($hint as $property => $value) { if (!in_array($property, array('id', 'questionid', 'options'))) { - $this->assertAttributeEquals($value, $property, $actualhint); + $this->assertEquals($value, $actualhint->$property); } } } @@ -279,12 +279,12 @@ class qtype_multianswer_test extends advanced_testcase { $actualsubq = $actualquestiondata->options->questions[$subqno]; foreach ($subq as $subqproperty => $subqvalue) { if (!in_array($subqproperty, $subqpropstoignore)) { - $this->assertAttributeEquals($subqvalue, $subqproperty, $actualsubq); + $this->assertEquals($subqvalue, $actualsubq->$subqproperty); } } foreach ($subq->options as $optionname => $value) { if (!in_array($optionname, array('answers'))) { - $this->assertAttributeEquals($value, $optionname, $actualsubq->options); + $this->assertEquals($value, $actualsubq->options->$optionname); } } foreach ($subq->options->answers as $answer) { @@ -292,7 +292,7 @@ class qtype_multianswer_test extends advanced_testcase { foreach ($answer as $ansproperty => $ansvalue) { // These questions do not use 'answerformat', will ignore it. if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) { - $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer); + $this->assertEquals($ansvalue, $actualanswer->$ansproperty); } } } diff --git a/question/type/multichoice/tests/questiontype_test.php b/question/type/multichoice/tests/questiontype_test.php index c18ead0627c..7068cab481b 100644 --- a/question/type/multichoice/tests/questiontype_test.php +++ b/question/type/multichoice/tests/questiontype_test.php @@ -134,13 +134,13 @@ class qtype_multichoice_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options', 'hints', 'stamp'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if ($optionname != 'answers') { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -148,7 +148,7 @@ class qtype_multichoice_test extends advanced_testcase { $actualhint = array_shift($actualquestiondata->hints); foreach ($hint as $property => $value) { if (!in_array($property, array('id', 'questionid', 'options'))) { - $this->assertAttributeEquals($value, $property, $actualhint); + $this->assertEquals($value, $actualhint->$property); } } } @@ -158,7 +158,7 @@ class qtype_multichoice_test extends advanced_testcase { foreach ($answer as $ansproperty => $ansvalue) { // This question does not use 'answerformat', will ignore it. if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) { - $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer); + $this->assertEquals($ansvalue, $actualanswer->$ansproperty); } } } diff --git a/question/type/numerical/tests/questiontype_test.php b/question/type/numerical/tests/questiontype_test.php index 9a39cde39f4..fef820cc586 100644 --- a/question/type/numerical/tests/questiontype_test.php +++ b/question/type/numerical/tests/questiontype_test.php @@ -149,13 +149,13 @@ class qtype_numerical_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('options'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if (!in_array($optionname, array('answers'))) { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -164,7 +164,7 @@ class qtype_numerical_test extends advanced_testcase { foreach ($answer as $ansproperty => $ansvalue) { // This question does not use 'answerformat', will ignore it. if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) { - $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer); + $this->assertEquals($ansvalue, $actualanswer->$ansproperty); } } } diff --git a/question/type/shortanswer/tests/questiontype_test.php b/question/type/shortanswer/tests/questiontype_test.php index 71ec1fe72fb..5a1ca8397c5 100644 --- a/question/type/shortanswer/tests/questiontype_test.php +++ b/question/type/shortanswer/tests/questiontype_test.php @@ -121,13 +121,13 @@ class qtype_shortanswer_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if ($optionname != 'answers') { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -136,7 +136,7 @@ class qtype_shortanswer_test extends advanced_testcase { foreach ($answer as $ansproperty => $ansvalue) { // This question does not use 'answerformat', will ignore it. if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) { - $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer); + $this->assertEquals($ansvalue, $actualanswer->$ansproperty); } } } diff --git a/question/type/truefalse/tests/questiontype_test.php b/question/type/truefalse/tests/questiontype_test.php index 1408a443cc6..6bae0bcdc27 100644 --- a/question/type/truefalse/tests/questiontype_test.php +++ b/question/type/truefalse/tests/questiontype_test.php @@ -161,13 +161,13 @@ class qtype_truefalse_test extends advanced_testcase { foreach ($questiondata as $property => $value) { if (!in_array($property, array('options'))) { - $this->assertAttributeEquals($value, $property, $actualquestiondata); + $this->assertEquals($value, $actualquestiondata->$property); } } foreach ($questiondata->options as $optionname => $value) { if (!in_array($optionname, array('trueanswer', 'falseanswer', 'answers'))) { - $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options); + $this->assertEquals($value, $actualquestiondata->options->$optionname); } } @@ -177,7 +177,7 @@ class qtype_truefalse_test extends advanced_testcase { foreach ($answer as $ansproperty => $ansvalue) { // This question does not use 'answerformat', will ignore it. if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) { - $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer); + $this->assertEquals($ansvalue, $actualanswer->$ansproperty); } } $answerindexes[$answer->answer] = $ansindex; From 40de097e6522091bd5918ae7ba4c84721d453b19 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 1 Sep 2020 00:44:13 +0200 Subject: [PATCH 08/15] MDL-67673 phpunit: Remove deprecated assertContains() uses on strings Both assertContains() and assertNotContains() are deprecated in PHPUnit 8 for operations on strings. Also the optional case parameter is. All uses must be changed to one of: - assertStringContainsString() - assertStringContainsStringIgnoringCase() - assertStringNotContainsString() - assertStringNotContainsStringIgnoringCase() More info: https://github.com/sebastianbergmann/phpunit/issues/3422 Regexp to find all uses: ag 'assert(Not)?Contains\(' --- admin/tool/behat/tests/manager_util_test.php | 28 ++--- admin/tool/dataprivacy/tests/api_test.php | 4 +- .../tests/privacy_provider_test.php | 4 +- .../httpsreplace/tests/httpsreplace_test.php | 24 ++-- admin/tool/mobile/tests/api_test.php | 6 +- admin/tool/mobile/tests/externallib_test.php | 6 +- .../monitor/tests/eventobservers_test.php | 20 ++-- .../tests/externallib_test.php | 2 +- admin/tool/uploadcourse/tests/course_test.php | 2 +- .../usertours/tests/privacy_provider_test.php | 2 +- analytics/tests/dataset_manager_test.php | 18 +-- auth/oauth2/tests/auth_test.php | 4 +- .../completion/tests/condition_test.php | 8 +- .../condition/date/tests/condition_test.php | 8 +- .../condition/grade/tests/condition_test.php | 8 +- .../condition/group/tests/condition_test.php | 2 +- .../grouping/tests/condition_test.php | 8 +- .../profile/tests/condition_test.php | 18 +-- availability/tests/info_test.php | 4 +- availability/tests/tree_test.php | 28 ++--- blocks/rss_client/tests/cron_test.php | 4 +- blog/tests/events_test.php | 10 +- cache/tests/cache_test.php | 2 +- calendar/tests/events_test.php | 18 +-- calendar/tests/externallib_test.php | 2 +- cohort/tests/externallib_test.php | 4 +- competency/tests/event_test.php | 10 +- competency/tests/external_test.php | 2 +- competency/tests/lib_test.php | 2 +- .../h5p/tests/contenttype_h5p_test.php | 6 +- contentbank/tests/contentbank_test.php | 2 +- contentbank/tests/contenttype_test.php | 4 +- course/tests/courselib_test.php | 16 +-- course/tests/externallib_test.php | 12 +- enrol/lti/tests/helper_test.php | 12 +- enrol/lti/tests/sync_members_test.php | 8 +- enrol/lti/tests/tool_provider_test.php | 10 +- enrol/manual/tests/lib_test.php | 48 ++++---- enrol/self/tests/self_test.php | 50 ++++----- filter/mediaplugin/tests/filter_test.php | 2 +- grade/tests/importlib_test.php | 2 +- grade/tests/report_graderlib_test.php | 8 +- h5p/tests/h5p_file_storage_test.php | 2 +- h5p/tests/helper_test.php | 2 +- lib/dml/tests/pgsql_native_recordset_test.php | 2 +- lib/filestorage/tests/zip_packer_test.php | 2 +- lib/form/tests/course_test.php | 20 ++-- lib/form/tests/duration_test.php | 6 +- lib/form/tests/filetypes_util_test.php | 14 +-- lib/form/tests/privacy_provider_test.php | 2 +- lib/phpunit/tests/advanced_test.php | 6 +- lib/tests/antivirus_test.php | 4 +- lib/tests/authlib_test.php | 2 +- lib/tests/completionlib_test.php | 2 +- lib/tests/core_media_player_native.php | 10 +- .../core_renderer_template_exploit_test.php | 4 +- lib/tests/event_course_module_viewed.php | 4 +- lib/tests/externallib_test.php | 2 +- lib/tests/filelib_test.php | 2 +- lib/tests/filetypes_test.php | 36 +++--- lib/tests/grouplib_test.php | 16 +-- lib/tests/medialib_test.php | 84 +++++++------- lib/tests/messagelib_test.php | 2 +- lib/tests/minify_test.php | 2 +- lib/tests/modinfolib_test.php | 4 +- lib/tests/moodlelib_test.php | 28 ++--- lib/tests/outputcomponents_test.php | 8 +- lib/tests/outputrequirementslib_test.php | 6 +- lib/tests/progress_display_test.php | 12 +- lib/tests/qrcode_test.php | 4 +- lib/tests/requirejs_test.php | 4 +- lib/tests/scheduled_task_test.php | 2 +- lib/tests/session_redis_test.php | 6 +- lib/tests/setuplib_test.php | 4 +- lib/tests/tablelib_test.php | 10 +- media/player/videojs/tests/player_test.php | 24 ++-- media/player/youtube/tests/player_test.php | 34 +++--- .../email/tests/send_email_task_test.php | 4 +- message/tests/api_test.php | 54 ++++----- message/tests/externallib_test.php | 22 ++-- .../feedback/comments/tests/privacy_test.php | 4 +- .../feedback/editpdf/tests/editpdf_test.php | 4 +- .../comments/tests/privacy_test.php | 4 +- mod/assign/tests/externallib_test.php | 2 +- mod/assign/tests/locallib_test.php | 106 +++++++++--------- mod/assign/tests/privacy_test.php | 10 +- mod/data/tests/lib_test.php | 62 +++++----- mod/feedback/tests/events_test.php | 8 +- mod/forum/tests/externallib_test.php | 6 +- mod/forum/tests/mail_test.php | 6 +- mod/forum/tests/maildigest_test.php | 8 +- mod/glossary/tests/external_test.php | 4 +- .../seb/tests/quiz_settings_test.php | 70 ++++++------ mod/quiz/accessrule/seb/tests/rule_test.php | 68 +++++------ .../report/overview/tests/report_test.php | 8 +- .../tests/quiz_question_bank_view_test.php | 2 +- mod/wiki/tests/wikiparser_test.php | 2 +- .../manual/tests/privacy_provider_test.php | 2 +- mod/workshop/tests/cron_task_test.php | 2 +- notes/tests/generator_test.php | 4 +- .../deferredcbm/tests/behaviourtype_test.php | 24 ++-- question/engine/tests/helpers.php | 4 +- .../format/aiken/tests/aikenformat_test.php | 12 +- .../tests/multianswerformat_test.php | 24 ++-- .../tests/qformat_xml_import_export_test.php | 12 +- question/tests/bank_view_test.php | 4 +- question/tests/question_bank_column_test.php | 8 +- .../type/essay/tests/walkthrough_test.php | 2 +- search/engine/solr/tests/engine_test.php | 6 +- search/tests/external_test.php | 2 +- search/tests/manager_test.php | 58 +++++----- user/tests/externallib_test.php | 8 +- user/tests/userroleseditable_test.php | 4 +- 113 files changed, 720 insertions(+), 720 deletions(-) diff --git a/admin/tool/behat/tests/manager_util_test.php b/admin/tool/behat/tests/manager_util_test.php index 71629550155..71b4b94575a 100644 --- a/admin/tool/behat/tests/manager_util_test.php +++ b/admin/tool/behat/tests/manager_util_test.php @@ -165,7 +165,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -219,7 +219,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -264,7 +264,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -295,7 +295,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -324,7 +324,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -368,7 +368,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -399,7 +399,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -428,7 +428,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -532,7 +532,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -611,7 +611,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -646,7 +646,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -662,7 +662,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -678,7 +678,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -693,7 +693,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } } diff --git a/admin/tool/dataprivacy/tests/api_test.php b/admin/tool/dataprivacy/tests/api_test.php index 7bf94cc9420..4cb34501382 100644 --- a/admin/tool/dataprivacy/tests/api_test.php +++ b/admin/tool/dataprivacy/tests/api_test.php @@ -997,8 +997,8 @@ class tool_dataprivacy_api_testcase extends advanced_testcase { $this->assertEquals($subject, $message->subject); $this->assertEquals('tool_dataprivacy', $message->component); $this->assertEquals('contactdataprotectionofficer', $message->eventtype); - $this->assertContains(fullname($dpo), $message->fullmessage); - $this->assertContains(fullname($user1), $message->fullmessage); + $this->assertStringContainsString(fullname($dpo), $message->fullmessage); + $this->assertStringContainsString(fullname($user1), $message->fullmessage); } /** diff --git a/admin/tool/dataprivacy/tests/privacy_provider_test.php b/admin/tool/dataprivacy/tests/privacy_provider_test.php index e671fa73796..cfbaac3ce24 100644 --- a/admin/tool/dataprivacy/tests/privacy_provider_test.php +++ b/admin/tool/dataprivacy/tests/privacy_provider_test.php @@ -142,7 +142,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { $this->assertEquals($strs->statusrejected, $data[1]->status); $this->assertEquals($strs->creationmanual, $data[1]->creationmethod); $this->assertEmpty($data[1]->comments); - $this->assertContains('Nope', $data[1]->dpocomment); + $this->assertStringContainsString('Nope', $data[1]->dpocomment); $this->assertNotEmpty($data[1]->timecreated); } @@ -184,4 +184,4 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { $this->assertEquals(6, $preferences[helper::PREF_REQUEST_PERPAGE]->value); } -} \ No newline at end of file +} diff --git a/admin/tool/httpsreplace/tests/httpsreplace_test.php b/admin/tool/httpsreplace/tests/httpsreplace_test.php index e3599c63cb9..fb60090e7e1 100644 --- a/admin/tool/httpsreplace/tests/httpsreplace_test.php +++ b/admin/tool/httpsreplace/tests/httpsreplace_test.php @@ -155,7 +155,7 @@ class httpsreplace_test extends \advanced_testcase { $finder->upgrade_http_links(); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains($expectedcontent, $summary); + $this->assertStringContainsString($expectedcontent, $summary); } /** @@ -253,10 +253,10 @@ class httpsreplace_test extends \advanced_testcase { $this->assertCount(0, $results); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains('http://intentionally.unavailable/page.php', $summary); - $this->assertContains('http://other.unavailable/page.php', $summary); - $this->assertNotContains('https://intentionally.unavailable', $summary); - $this->assertNotContains('https://other.unavailable', $summary); + $this->assertStringContainsString('http://intentionally.unavailable/page.php', $summary); + $this->assertStringContainsString('http://other.unavailable/page.php', $summary); + $this->assertStringNotContainsString('https://intentionally.unavailable', $summary); + $this->assertStringNotContainsString('https://other.unavailable', $summary); } /** @@ -281,7 +281,7 @@ class httpsreplace_test extends \advanced_testcase { $finder->upgrade_http_links(); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains($CFG->wwwroot, $summary); + $this->assertStringContainsString($CFG->wwwroot, $summary); } /** @@ -298,10 +298,10 @@ class httpsreplace_test extends \advanced_testcase { $output = ob_get_contents(); ob_end_clean(); $this->assertTrue($results); - $this->assertNotContains('https://somesite', $output); + $this->assertStringNotContainsString('https://somesite', $output); $testconf = get_config('core', 'test_upgrade_http_links'); - $this->assertContains('http://somesite', $testconf); - $this->assertNotContains('https://somesite', $testconf); + $this->assertStringContainsString('http://somesite', $testconf); + $this->assertStringNotContainsString('https://somesite', $testconf); } /** @@ -331,8 +331,8 @@ class httpsreplace_test extends \advanced_testcase { $finder->upgrade_http_links(); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains('https://secure.example.com', $summary); - $this->assertNotContains('http://example.com', $summary); + $this->assertStringContainsString('https://secure.example.com', $summary); + $this->assertStringNotContainsString('http://example.com', $summary); $this->assertEquals('