定制 eventsauce/pest-utilities 二次开发

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

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

eventsauce/pest-utilities

最新稳定版本:3.4.1

Composer 安装命令:

composer require eventsauce/pest-utilities

包简介

Test utilities for EventSauce.

README 文档

README

composer require --dev eventsauce/pest-utilities

Usage

First, create a base test case, as described in the regular PHPUnit setup.

Next, use the base test case in your Pest tests:

use function EventSauce\EventSourcing\PestTooling\expectToFail;
use function EventSauce\EventSourcing\PestTooling\given;
use function EventSauce\EventSourcing\PestTooling\nothingShouldHaveHappened;
use function EventSauce\EventSourcing\PestTooling\when;

uses(YourBaseTestCase::class);

it('you can use the object-oriented interface', function () {
    $this->given(
        new ShoppingCartInitiated(),
    )->when(function (ShoppingCart $cart): void {
        $cart->addProduct(new ProductId('garlic sauce'), 250);
    })->then(
        new ProductAddedToCart(new ProductId('garlic sauce'), 250)
    );
});

it('or the function based interface', function () {
    given(new ShoppingCartInitiated());
    when(function (ShoppingCart $cart): void {
        $cart->checkout();
    });
    expectToFail(SorryCantCheckout::becauseThereAreNoProductsInCart());
    nothingShouldHaveHappened();
});

it('or mix it all', function () {
    given(new ShoppingCartInitiated())
        ->when(function (ShoppingCart $cart): void {
            $cart->checkout();
        });
    expectToFail(SorryCantCheckout::becauseThereAreNoProductsInCart())
        ->nothingShouldHaveHappened();
});

it('can be used in a compact manner')
    ->given(new ShoppingCartInitiated())
    ->when(fn (ShoppingCart $cart) => $cart->add(new ProductId('garlic sauce'), 250))
    ->then(new ProductAddedToCart(new ProductId('garlic sauce'), 250))
    ->assertScenario(); // needed for a Pest bug 

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-14