smt/open-popo
Composer 安装命令:
composer require smt/open-popo
包简介
Simple library for easy testing Plain Old PHP Objects (inspired by open-pojo)
README 文档
README
Small library for quick testing your Plain Old PHP Objects.
(inspired by open-pojo)
Installation
composer require smt/open-popo
Usage
Example
<?php
use Smt\OpenPopo\Reflection\PopoClass;
use Smt\OpenPopo\Validator\Validator;
use Smt\OpenPopo\Rule\Impl\GetterMustExist;
use Smt\OpenPopo\Rule\Impl\SetterMustExist;
use Smt\OpenPopo\Tester\Impl\GetterTester;
use Smt\OpenPopo\Tester\Impl\FluentSetterTester; // You can also remove "Fluent" prefix if you don't want to check
// this functional
class EntityTest extends PHPUnit_Framework_TestCase
{
public function testAll()
{
Validator::create()
->addRule(GetterMustExist::create())
->addRule(
SetterMustExist::create()
->skip('iWantThisPropertyToHaveNoSetter')
)
->addTester(GetterTester::create())
->addTester(FluentSetterTester::create())
->validate(PopoClass::fromClassName(Entity::class)
;
}
}
Notes (need to rewrite into documentation)
Available rules:
GetterMustExistSetterMustExist
Available testers:
GetSetTesterdeprecatedFluentGetSetTesterdeprecatedGetterTesterSetterTesterFluentSetterTester
Planned:
- Collection rules/testers (
add*/remove*)
Every rule and tester:
- has
skipmethod to specify properties to skip - can be instantiated directly (via
new) or via factory method (::create())
Validator can be instantiated directly (via new) or via factory method (::create())
License
This package is licensed under MIT license
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-10