cekurte/tdd
Composer 安装命令:
composer require cekurte/tdd
包简介
PHPUnit TestCase
README 文档
README
- Just a simple extension to the PHPUnit library.
- Currently this package contains only support for one TestCase scenario ReflectionTestCase contribute with this project!
Installation
- The package is available on Packagist.
- The source files is PSR-2 compatible.
- Autoloading is PSR-4 compatible.
composer require cekurte/tdd
If you liked of this library, give me a star =).
Documentation
This library was created to permit that developers write php unit tests using a common base class, including initially the following tasks:
- Set a private, protected or public property value;
- Get a private, protected or public property value;
- Call a private, protected or public method.
Setting a property value
To set a property value (independently of your visibility) you can use the method ReflectionTestCase::propertySetValue like the following example:
<?php namespace Your\Namespace; use Cekurte\Tdd\ReflectionTestCase; class YourClassTest extends ReflectionTestCase { public function testAnything() { // Instance of a class that has one // private property named "yourPrivateProperty". $instance = new YourClass(); // Set the value "newValue" to the property // "yourPrivateProperty". $this->propertySetValue( $instance, 'yourPrivateProperty', 'newValue' ); // ... } }
Getting a property value
To get a property value (independently of your visibility) you can use the method ReflectionTestCase::propertyGetValue like the following example:
<?php namespace Your\Namespace; use Cekurte\Tdd\ReflectionTestCase; class YourClassTest extends ReflectionTestCase { public function testAnything() { // Instance of a class that has one // private property named "yourPrivateProperty". $instance = new YourClass(); // Get the value of the property // "yourPrivateProperty". $currentValue = $this->propertyGetValue( $instance, 'yourPrivateProperty' ); // ... } }
Calling a method
To call a method (independently of your visibility) you can use the method ReflectionTestCase::invokeMethod like the following example:
<?php namespace Your\Namespace; use Cekurte\Tdd\ReflectionTestCase; class YourClassTest extends ReflectionTestCase { public function testAnything() { // Instance of a class that has one // private property named "yourPrivateMethod". $instance = new YourClass(); // Call the method // "yourPrivateMethod". $valueReturned = $this->invokeMethod( $instance, 'yourPrivateMethod', ['param1', 'param2', 'paramN'] ); // ... } }
Contributing
- Give me a star =)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Make your changes
- Run the tests, adding new ones for your own code if necessary (
vendor/bin/phpunit) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
cekurte/tdd 适用场景与选型建议
cekurte/tdd 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 576 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cekurte/tdd 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cekurte/tdd 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 576
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 13
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-17