承接 ormin/phpspec-ddd-project-extension 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ormin/phpspec-ddd-project-extension

最新稳定版本:1.0.1

Composer 安装命令:

composer require ormin/phpspec-ddd-project-extension

包简介

PHPSpec helper classes for utilizing DDD and commonly used patterns around it

README 文档

README

Extension to help you speccing your domain objects.

Includes a matcher and token for value objects, which will make it possible to compare objects by their values and not internal identities within tests.

To install it, use Composer:

$ composer require --dev ormin/phpspec-ddd-project-extension:dev-master

Then in a phpspec.yml file of your project, add the following:

extensions:
    - Ormin\DDDProjectExtension\DDDProjectExtension

You can use the matcher like this ( in example I used an imagined UserId object, but you might use whatever Value Object you want ):


function it_will_return_the_correct_user_id() {

    $userId = new UserId(682);

    // $domainObject->returnMeSomeCoolUserId() will return a UserId value object, which we want to match against the above. ReturnValue will fail due to non-matching identity.
    $domainObject->returnMeSomeCoolUserId()->shouldReturnValue($userId);


}

You can use the token like this:


function it_will_call_funny_method() {

    $userId = new UserId(682);

    $domainObject->doSeriousStuff(new ExactValueObjectToken($userId))->shouldBeCalled();

    // $domainObject->doSomeFunnyStuff() should call doSeriousStuff(UserId $userId) with an UserId value object which is created inside the method, which we want to match against the above value object. Normal ExactValueToken will fail due to non-matching identity.
    $domainObject->doSomeFunnyStuff();


}

Warning: Do not abuse it for objects which are not explicitly value objects and are compared by identity! Every time you do it, a kitten dies, so please spare the kittens and write clean code :)

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-23