MDL-67673 phpunit: Remove deprecated non-public attribute assertions
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 31 Aug 2020 22:07:51 +0000 (00:07 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 21 Oct 2020 10:46:05 +0000 (12:46 +0200)
commit106c64ac24084842d4f4c887a3c18646d48ffb92
tree08e40bad934556e50970dfcb1953ac8673bcb821
parentddf72dd60d7ab37e85f91525ecfd9249328ca0a6
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
message/tests/api_test.php
question/type/calculatedsimple/tests/questiontype_test.php
question/type/description/tests/questiontype_test.php
question/type/match/tests/questiontype_test.php
question/type/multianswer/tests/questiontype_test.php
question/type/multichoice/tests/questiontype_test.php
question/type/numerical/tests/questiontype_test.php
question/type/shortanswer/tests/questiontype_test.php
question/type/truefalse/tests/questiontype_test.php