pccomponentes/ddd-testing
Composer 安装命令:
composer require pccomponentes/ddd-testing
包简介
Added test utils to ddd mini framework
README 文档
README
Tools for helping in test development.
PcComponentes\Ddd\Testing\Util\PhpUnit\IterableMockTrait
Allows you to introduce mocks in tested method through an iterable mock object in an easy way.
Use
Example:
use PcComponentes\Ddd\Testing\Util\PhpUnit\IterableMockTrait; use PHPUnit\Framework\TestCase; final class Testing extends TestCase { use IterableMockTrait; public function testMethod() { $mockedItem1 = $this->createMock(\stdClass::class); // Assertions in mock $mockedItem2 = $this->createMock(\stdClass::class); // Assertions in mock $mockedIterator = $this->addIterableValuesToMock( $this->createMock(\Iterator::class), // Your iterable mock [ $mockedItem1, $mockedItem2, ], ); // ... } }
PcComponentes\Ddd\Testing\Util\PhpUnit\SerializableMockTrait
Allows you to simplify the serializable parametrization of a \JsonSerializable mock, making the code more semantic and easy to read.
Use
Example:
use PcComponentes\Ddd\Testing\Util\PhpUnit\SerializableMockTrait; use PHPUnit\Framework\TestCase; final class Testing extends TestCase { use SerializableMockTrait; public function testMethod() { $valueToReturnOnSerialize = 'some compatible with serialization method declared'; $serializableMock = $this->addJsonSerializationToMock( $this->createMock(\JsonSerializable::class), // Your mock which implements jsonSerialize method $this->once(), // Or other InvocationOrder $valueToReturnOnSerialize, ); // ... } }
统计信息
- 总下载量: 27.72k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-25