I have phpunit 3.7
@assert
annotation, whereas @assert
annotationThe official announcement mentions some new annotations (and the re-introduction of an old one previously deprecated), but it does not mention the removal of @assert
.
In the changelog for 3.7., @assert
is not to be found on the page
When I run my code on a class using the code snippet
<?php
class MyMathClass
{
/**
* Add two given values together and return sum
* @assert (1,2) == 3
*/
public function addValues($a,$b)
{
return $a+$b;
}
}
the output is
PHPUnit 3.7.1 by Sebastian Bergmann.
Time: 1 second, Memory: 4.25Mb
No tests executed!
with php 3.6.2
phpunit MyMathClass.php
PHPUnit 3.6.12 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 2.75Mb
OK (1 test, 1 assertion)
Assertions — PHPUnit 9.5 Manual 1. Assertions ¶ This appendix lists the various assertion methods that are available. PHPUnit’s assertions are implemented in PHPUnit\Framework\Assert . PHPUnit\Framework\TestCase inherits from PHPUnit\Framework\Assert.
assertNotContains () is the inverse of this assertion and takes the same arguments. $ phpunit ContainsTest PHPUnit 9.5.0 by Sebastian Bergmann and contributors.
An annotation is a special form of syntactic metadata that can be added to the source code of some programming languages. While PHP has no dedicated language feature for annotating source code, the usage of tags such as @annotation arguments in a documentation block has been established in the PHP community to annotate source code.
Reports an error identified by $message if the two variables $expected and $actual are not equal. assertNotEquals () is the inverse of this assertion and takes the same arguments. $ phpunit EqualsTest PHPUnit 9.5.0 by Sebastian Bergmann and contributors.
Answering my own question after doing some research. And thanks to the commenters for putting me on track.
The annotation is gone because it has been moved to the optional PHPUnit_SkeletonGenerator package.
At this time, there are two confusing issues with this:
The changelog is imprecise. It says (wrongly):
Removed deprecated --skeleton-class and --skeleton-test switches. The functionality is now provided by the phpunit-skel command of the PHPUnit_SkeletonGenerator package.
A better way of saying this would sound more like this:
Removed deprecated --skeleton-class and --skeleton-test switches. The functionality is now provided by the optional phpunit-skelgen command of the PHPUnit_SkeletonGenerator package. Therefore, the @assert annotation has been removed from the phpunit core. It becomes available after installing PHPUnit_SkeletonGenerator via PEAR.
Maybe I'll change this myself via github and notify the maintainers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With