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
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-14