定制 ngyuki/phpower 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ngyuki/phpower

最新稳定版本:v0.0.3

Composer 安装命令:

composer require --dev ngyuki/phpower

包简介

Implement assertion like Power Assert in PHP.

README 文档

README

Latest Stable Version Latest Unstable Version License

Implement assertion like Power Assert in PHP.

Install

composer require --dev phpunit/phpunit ngyuki/phpower:dev-master

Example

Write test code with assert.

<?php namespace Test; use PHPUnit\Framework\TestCase; class SomeTest extends TestCase { public function test_01() { $a = 1; $b = 2; $c = 3; assert(($a + ($b + 3)) === ($c * 3)); } public function test_02() { $s = "x\ny\nz"; assert("a\nb\nc" === strrev($s)); } public function test_03() { $a = [1,2,3]; $b = [7,8,9]; assert($a == array_reverse($b)); } public function test_ok() { $a = [1,2,3]; $b = [3,2,1]; assert($a == array_reverse($b)); } public function test_04() { $a = [ 'name' => 'alice', 'uid' => 1000, 'gid' => 1000, ]; assert($a == [ 'name' => 'bob', 'uid' => 2000, 'gid' => 2000, ]); } }

Run the test.

vendor/bin/phpunit tests/example/

The following result is displayed.

PHPUnit 8.5.2 by Sebastian Bergmann and contributors. Runtime: PHP 7.4.2 Configuration: /path/to/phpower/phpunit.xml.dist FFF.F 5 / 5 (100%) Time: 261 ms, Memory: 4.00 MB There were 4 failures: 1) Test\SomeTest::test_01 Assertion failed ($a + ($b + 3)) === ($c * 3) -> false # $a -> 1 # $b -> 2 # $b + 3 -> 5 # $a + ($b + 3) -> 6 # $c -> 3 # $c * 3 -> 9 /path/to/phpower/tests/example/SomeTest.php:13 2) Test\SomeTest::test_02 Assertion failed "a\nb\nc" === strrev($s) -> false # $s -> "x\ny\nz" # strrev($s) -> "z\ny\nx" /path/to/phpower/tests/example/SomeTest.php:19 3) Test\SomeTest::test_03 Assertion failed $a == array_reverse($b) -> false # $a # -> [ # 1, # 2, # 3, # ] # # $b # -> [ # 7, # 8, # 9, # ] # # array_reverse($b) # -> [ # 9, # 8, # 7, # ] # /path/to/phpower/tests/example/SomeTest.php:26 4) Test\SomeTest::test_04 Assertion failed $a == ['name'=>'bob','uid'=>2000,'gid'=>2000,] -> false # $a # -> [ # "name" => "alice", # "uid" => 1000, # "gid" => 1000, # ] # /path/to/phpower/tests/example/SomeTest.php:46 FAILURES! Tests: 5, Assertions: 5, Failures: 4. 

Limitations

Only for phpunit installed locally in project with composer (phpunit.phar is not supported).

LICENCE

统计信息

  • 总下载量: 3.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固