Files
ECShopX/tests/TestBusTest.php
wanghai 713413c9dc 4.12.0
2026-08-10 08:01:45 +08:00

36 lines
911 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use EspierBundle\Services\Bus\TestBus;
class TestBusTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
TestBus::reset();
}
/**
* T0连续两次 post 后 getPostCount()===2reset() 后归零。
* #given TestBus 已 reset
* #when 连续两次 post 后 reset
* #then getPostCount 先为 2 后归零
*/
public function testPostHistoryCountAndReset(): void
{
$bus = new TestBus();
$bus->post('/uri1', ['a' => 1]);
$bus->post('/uri2', ['b' => 2]);
$this->assertSame(2, TestBus::getPostCount());
$this->assertSame([['a' => 1], ['b' => 2]], TestBus::getPostHistory());
TestBus::reset();
$this->assertSame(0, TestBus::getPostCount());
$this->assertSame([], TestBus::getPostHistory());
$this->assertNull(TestBus::getLastPostData());
}
}