Skip to content

Commit 780eb2a

Browse files
committed
[docs] Migrate Writing PHPUnit tests
Signed-off-by: Daniel Ziegenberg <[email protected]>
1 parent d4af469 commit 780eb2a

File tree

7 files changed

+619
-6
lines changed

7 files changed

+619
-6
lines changed

data/migratedPages.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,9 @@ Web_services_API:
18031803
Web_services_files_handling:
18041804
- filePath: "/docs/apis/subsystems/external/files.md"
18051805
slug: "/docs/apis/subsystems/external/files"
1806+
Writing_PHPUnit_tests:
1807+
- filePath: "/general/development/tools/phpunit/write.md"
1808+
slug: "/general/development/tools/phpunit/write"
18061809
Writing_acceptance_tests:
18071810
- filePath: "/general/development/tools/behat/writing.md"
18081811
slug: "/general/development/tools/behat/writing"

general/development/policies/codingstyle/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1765,8 +1765,8 @@ This tag is valid and can be used optionally to indicate the method or function
17651765
There are some tags that are only allowed within some contexts and not globally. More precisely:
17661766

17671767
- `@Given`, `@When`, `@Then`, within the [behat steps definitions](../../tools/behat/writing.md#writing-new-acceptance-test-step-definitions).
1768-
- `@covers`, `@coversDefaultClass`, `@coversNothing`, `@uses` to better control coverage within [unit tests](https://docs.moodle.org/dev/Writing_PHPUnit_tests#Generators).
1769-
- `@dataProvider` and `@testWith`, to provide example data and expectations, within [unit tests](https://docs.moodle.org/dev/Writing_PHPUnit_tests#Generators).
1768+
- `@covers`, `@coversDefaultClass`, `@coversNothing`, `@uses` to better control coverage within [unit tests](/general/development/tools/phpunit/write#generators).
1769+
- `@dataProvider` and `@testWith`, to provide example data and expectations, within [unit tests](/general/development/tools/phpunit/write#generators).
17701770
- `@depends`, to express dependencies between tests, where each producer returned data in passed to consumers. See [`@depends` examples](https://docs.phpunit.de/en/9.6/writing-tests-for-phpunit.html#writing-tests-for-phpunit-examples-stacktest2-php) for more information.
17711771
- `@group`, for easier collecting unit tests together, following the guidelines in the [PHPUnit MoodleDocs](../../tools/phpunit.md#using-the-group-annotation).
17721772
- `@requires`, to specify unit test requirements and skip if not fulfilled. See [`@requires` usages](https://docs.phpunit.de/en/9.6/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests-requires-tables-api) for more information.

general/development/tools/behat/writing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ new behat step definitions for your plugin, and allows you to re-use data genera
304304

305305
Full documentation of this process and all available options can be found in the [PHPDoc for behat_generator_base](https://github.com/moodle/moodle/blob/1d4fdb0d1c60448104bc9eac79b5123863c67cbd/lib/behat/classes/behat_generator_base.php#L33). A core example of this can be found in [/mod/quiz/tests/generator](https://github.com/moodle/moodle/tree/main/mod/quiz/tests/generator) and [quiz_reset.feature](https://github.com/moodle/moodle/blob/1d4fdb0d1c60448104bc9eac79b5123863c67cbd/mod/quiz/tests/behat/quiz_reset.feature#L51). What follows is a simple example.
306306

307-
To begin, you need a [generator](https://docs.moodle.org/dev/Writing_PHPUnit_tests#Generators) in `/*your*/*plugin*/tests/generator/lib.php`. If you are generating a type of entity called "thing", your generator will need a method called create_thing, which accepts an object:
307+
To begin, you need a [generator](/general/development/tools/phpunit/write#generators) in `/*your*/*plugin*/tests/generator/lib.php`. If you are generating a type of entity called "thing", your generator will need a method called create_thing, which accepts an object:
308308

309309
```php
310310
class local_myplugin_generator extends component_generator_base {

general/development/tools/phpunit.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://localhost/moodle-exttests');
278278
## Writing new tests
279279

280280
- read [official PHPUnit online documentation](https://docs.phpunit.de/en/9.6/)
281-
- see [Writing PHPUnit tests](https://docs.moodle.org/dev/Writing_PHPUnit_tests)
281+
- see [Writing PHPUnit tests](/general/development/tools/phpunit/write)
282282

283283
## PHPUnit support in IDEs
284284

0 commit comments

Comments
 (0)