phpunit 3.7:@assert批注发生了什么? [英] phpunit 3.7: what happened to the @assert annotation?

查看:74
本文介绍了phpunit 3.7:@assert批注发生了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有phpunit 3.7

官方公告提到了一些新的注释(以及对旧注释的重新介绍)先前已弃用),但未提及删除@assert. 在 3.7的更改日志中.,在页面上找不到@assert >

当我使用代码段在类上运行代码时

<?php
class MyMathClass
{
   /**
    * Add two given values together and return sum
    * @assert (1,2) == 3
    */
   public function addValues($a,$b)
   {
       return $a+$b;
   }
}

输出为

PHPUnit 3.7.1 by Sebastian Bergmann.



Time: 1 second, Memory: 4.25Mb

No tests executed!

使用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)

解决方案

进行一些研究后回答我自己的问题.并感谢评论员使我步入正轨.

注释消失了,因为它已移至可选 PHPUnit_SkeletonGenerator程序包.

这时,有两个令人困惑的问题:

  1. 从phpunit核心"中删除@assert注释
  2. 文档未正确更新

更改日志不准确.它说(错误):

删除了不推荐使用的--skeleton-class和--skeleton-test开关.这 功能现在由的phpunit- skel 命令提供 PHPUnit_SkeletonGenerator软件包.

更好的说法是:

删除了不推荐使用的--skeleton-class和--skeleton-test开关.这 功能现在由可选的phpunit- skelgen 提供 PHPUnit_SkeletonGenerator软件包的命令. 因此,@ assert批注已从phpunit核心中删除. 通过PEAR安装PHPUnit_SkeletonGenerator后可以使用它.

也许我会自己通过github更改它,并通知维护者.

I have phpunit 3.7

The 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)

解决方案

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:

  1. the removal of the @assert annotation from the phpunit "core"
  2. the documentation being not updated properly

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.

这篇关于phpunit 3.7:@assert批注发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆