Kraken\Test\TModule::assertEvents PHP Метод

assertEvents() публичный Метод

public assertEvents ( Event[] $actualEvents = [], Event[] $expectedEvents = [], integer $flags = Simulation::EVENTS_COMPARE_IN_ORDER )
$actualEvents Kraken\Test\Simulation\Event[]
$expectedEvents Kraken\Test\Simulation\Event[]
$flags integer
    public function assertEvents($actualEvents = [], $expectedEvents = [], $flags = Simulation::EVENTS_COMPARE_IN_ORDER)
    {
        $count = max(count($actualEvents), count($expectedEvents));
        if ($flags === Simulation::EVENTS_COMPARE_RANDOMLY) {
            sort($actualEvents);
            sort($expectedEvents);
        }
        for ($i = 0; $i < $count; $i++) {
            if (!isset($actualEvents[$i])) {
                $this->fail(sprintf(self::MSG_EVENT_GET_ASSERTION_FAILED, $i, $expectedEvents[$i]->name(), 'null'));
            } else {
                if (!isset($expectedEvents[$i])) {
                    $this->fail(sprintf(self::MSG_EVENT_GET_ASSERTION_FAILED, $i, 'null', $actualEvents[$i]->name()));
                }
            }
            $actualEvent = $actualEvents[$i];
            $expectedEvent = $expectedEvents[$i];
            $this->assertSame($expectedEvent->name(), $actualEvent->name(), sprintf(self::MSG_EVENT_NAME_ASSERTION_FAILED, $i));
            $this->assertSame($expectedEvent->data(), $actualEvent->data(), sprintf(self::MSG_EVENT_DATA_ASSERTION_FAILED, $i));
        }
    }