Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Fix: Deprecate assertions #548

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Deprecated all data providers ([#526]), by [@localheinz]
- Dropped support for PHP 7.2 ([#530]), by [@localheinz]
- Dropped support for PHP 7.3 ([#540]), by [@localheinz]
- Deprecated all assertions ([#548]), by [@localheinz]

For a full diff see [`1.5.0...main`][1.5.0...main].

Expand Down Expand Up @@ -192,6 +193,7 @@ For a full diff see [`0.7.0...0.8.0`][0.7.0...0.8.0].
[#526]: https://github.com/ergebnis/test-util/pull/526
[#530]: https://github.com/ergebnis/test-util/pull/530
[#540]: https://github.com/ergebnis/test-util/pull/540
[#548]: https://github.com/ergebnis/test-util/pull/548

[@dependabot]: https://github.com/dependabot
[@ergebnis]: https://github.com/ergebnis
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ For reference, see [`fzaninotto/faker`](https://github.com/fzaninotto/Faker).

#### Additional Assertions

:exclamation: The assertions have been deprecated. Stop using them.

In addition to the assertions made available by extending from `PHPUnit\Framework\TestCase`, the `Helper` trait provides the following assertions:

* `assertClassesAreAbstractOrFinal(string $directory, array $excludeClassNames = [])`
Expand Down
171 changes: 171 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,15 @@ parameters:
count: 1
path: test/Unit/DataProvider/StringProviderTest.php

-
message:
"""
#^Call to deprecated method assertClassExtends\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\EmptyValuesTest\\:
Will be removed with the next major release\\.$#
"""
count: 1
path: test/Unit/Exception/EmptyValuesTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\EmptyValuesTest\\:\\:assertClassExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
Expand Down Expand Up @@ -1104,6 +1113,15 @@ parameters:
count: 1
path: test/Unit/Exception/EmptyValuesTest.php

-
message:
"""
#^Call to deprecated method assertClassExtends\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\InvalidExcludeClassNameTest\\:
Will be removed with the next major release\\.$#
"""
count: 1
path: test/Unit/Exception/InvalidExcludeClassNameTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\InvalidExcludeClassNameTest\\:\\:assertClassExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
Expand Down Expand Up @@ -1199,6 +1217,15 @@ parameters:
count: 1
path: test/Unit/Exception/InvalidExcludeClassNameTest.php

-
message:
"""
#^Call to deprecated method assertClassExtends\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\NonExistentDirectoryTest\\:
Will be removed with the next major release\\.$#
"""
count: 1
path: test/Unit/Exception/NonExistentDirectoryTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\NonExistentDirectoryTest\\:\\:assertClassExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
Expand Down Expand Up @@ -1294,6 +1321,15 @@ parameters:
count: 1
path: test/Unit/Exception/NonExistentDirectoryTest.php

-
message:
"""
#^Call to deprecated method assertClassExtends\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\NonExistentExcludeClassTest\\:
Will be removed with the next major release\\.$#
"""
count: 1
path: test/Unit/Exception/NonExistentExcludeClassTest.php

-
message: "#^Method Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\Exception\\\\NonExistentExcludeClassTest\\:\\:assertClassExists\\(\\) is protected, but since the containing class is final, it can be private\\.$#"
count: 1
Expand Down Expand Up @@ -1389,6 +1425,141 @@ parameters:
count: 1
path: test/Unit/Exception/NonExistentExcludeClassTest.php

-
message:
"""
#^Call to deprecated method assertClassExists\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 2
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassExtends\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassImplementsInterface\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassIsAbstract\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 3
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassIsFinal\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 3
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassSatisfiesSpecification\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassUsesTrait\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassesAreAbstractOrFinal\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 8
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassesHaveTests\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 9
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertClassyConstructsSatisfySpecification\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 8
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertInterfaceExists\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 2
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertInterfaceExtends\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertInterfaceSatisfiesSpecification\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertTraitExists\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 2
path: test/Unit/HelperTest.php

-
message:
"""
#^Call to deprecated method assertTraitSatisfiesSpecification\\(\\) of class Ergebnis\\\\Test\\\\Util\\\\Test\\\\Unit\\\\HelperTest\\:
Will be removed with the next major release\\.$#
"""
count: 4
path: test/Unit/HelperTest.php

-
message: "#^Generator expects key type string, int given\\.$#"
count: 1
Expand Down
51 changes: 51 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@
</MoreSpecificReturnType>
</file>
<file src="src/Helper.php">
<DeprecatedMethod occurrences="14">
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($parentClassName)</code>
<code>self::assertInterfaceExists($interfaceName)</code>
<code>self::assertInterfaceExists($interfaceName)</code>
<code>self::assertInterfaceExists($interfaceName)</code>
<code>self::assertInterfaceExists($parentInterfaceName)</code>
<code>self::assertTraitExists($traitName)</code>
<code>self::assertTraitExists($traitName)</code>
</DeprecatedMethod>
<MissingClosureParamType occurrences="2">
<code>$excludeClassyName</code>
<code>$excludeClassyName</code>
Expand Down Expand Up @@ -144,11 +159,29 @@
<code>StringProvider::withWhitespace()</code>
</DeprecatedClass>
</file>
<file src="test/Unit/Exception/EmptyValuesTest.php">
<DeprecatedMethod occurrences="1">
<code>self::assertClassExtends(\InvalidArgumentException::class, EmptyValues::class)</code>
</DeprecatedMethod>
</file>
<file src="test/Unit/Exception/InvalidExcludeClassNameTest.php">
<DeprecatedMethod occurrences="1">
<code>self::assertClassExtends(\InvalidArgumentException::class, InvalidExcludeClassName::class)</code>
</DeprecatedMethod>
<MixedInferredReturnType occurrences="1">
<code>\Generator&lt;array&lt;null|array|bool|float|int|resource|\stdClass&gt;&gt;</code>
</MixedInferredReturnType>
</file>
<file src="test/Unit/Exception/NonExistentDirectoryTest.php">
<DeprecatedMethod occurrences="1">
<code>self::assertClassExtends(\InvalidArgumentException::class, NonExistentDirectory::class)</code>
</DeprecatedMethod>
</file>
<file src="test/Unit/Exception/NonExistentExcludeClassTest.php">
<DeprecatedMethod occurrences="1">
<code>self::assertClassExtends(\InvalidArgumentException::class, NonExistentExcludeClass::class)</code>
</DeprecatedMethod>
</file>
<file src="test/Unit/HelperTest.php">
<ArgumentTypeCoercion occurrences="16">
<code>$className</code>
Expand All @@ -168,6 +201,24 @@
<code>$traitName</code>
<code>$traitName</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="65">
<code>self::assertClassExists($className)</code>
<code>self::assertClassExists($className)</code>
<code>self::assertClassIsAbstract($className)</code>
<code>self::assertClassIsAbstract($className)</code>
<code>self::assertClassIsAbstract($className)</code>
<code>self::assertClassIsFinal($className)</code>
<code>self::assertClassIsFinal($className)</code>
<code>self::assertClassIsFinal($className)</code>
<code>self::assertClassesAreAbstractOrFinal($directory)</code>
<code>self::assertClassesAreAbstractOrFinal($directory)</code>
<code>self::assertClassesAreAbstractOrFinal($directory)</code>
<code>self::assertClassesAreAbstractOrFinal($directory)</code>
<code>self::assertInterfaceExists($interfaceName)</code>
<code>self::assertInterfaceExists($interfaceName)</code>
<code>self::assertTraitExists($traitName)</code>
<code>self::assertTraitExists($traitName)</code>
</DeprecatedMethod>
<InvalidReturnType occurrences="1">
<code>\Generator&lt;string, array&lt;string&gt;&gt;</code>
</InvalidReturnType>
Expand Down
Loading