src/Verification/IterableVerifier.php
public function checkProduced(
        $keyOrValue = null,
        $value = null
    ): ?EventCollection {
        $cardinality = $this->resetCardinality();
        $argumentCount = func_num_args();

        if (0 === $argumentCount) {
            $checkKey = false;
            $checkValue = false;
        } elseif (1 === $argumentCount) {
            $checkKey = false;
            $checkValue = true;
            $value = $this->matcherFactory->adapt($keyOrValue);
        } else {
            $checkKey = true;
            $checkValue = true;
            $key = $this->matcherFactory->adapt($keyOrValue);
            $value = $this->matcherFactory->adapt($value);
        }

        $isCall = $this->subject instanceof Call;
        $matchingEvents = [];
        $matchCount = 0;
        $eventCount = 0;

        foreach ($this->calls as $call) {
            $isMatchingCall = false;

            foreach ($call->iterableEvents() as $event) {
                if ($event instanceof ProducedEvent) {
                    ++$eventCount;

                    if ($checkKey && !$key->matches($event->key())) {
                        continue;
                    }

                    if ($checkValue && !$value->matches($event->value())) {
                        continue;
                    }

                    $matchingEvents[] = $event;
                    $isMatchingCall = true;

                    if ($isCall) {
                        ++$matchCount;
                    }
                }
            }

            if (!$isCall && $isMatchingCall) {
                ++$matchCount;
            }
        }

        if ($isCall) {
            $totalCount = $eventCount;
        } else {
            $totalCount = $this->callCount;
        }

        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccess($matchingEvents);
        }

        return null;
    }
public function checkProduced(
        $keyOrValue = null,
        $value = null
    ): ?EventCollection {
        $cardinality = $this->resetCardinality();
        $argumentCount = func_num_args();

        if (0 === $argumentCount) {
            $checkKey = false;
            $checkValue = false;
        } elseif (1 === $argumentCount) {
            $checkKey = false;
            $checkValue = true;
            $value = $this->matcherFactory->adapt($keyOrValue);
        } else {
            $checkKey = true;
            $checkValue = true;
            $key = $this->matcherFactory->adapt($keyOrValue);
            $value = $this->matcherFactory->adapt($value);
        }

        $isCall = $this->subject instanceof Call;
        $matchingEvents = [];
        $matchCount = 0;
        $eventCount = 0;

        foreach ($this->calls as $call) {
            $isMatchingCall = false;

            foreach ($call->iterableEvents() as $event) {
                if ($event instanceof ProducedEvent) {
                    ++$eventCount;

                    if ($checkKey && !$key->matches($event->key())) {
                        continue;
                    }

                    if ($checkValue && !$value->matches($event->value())) {
                        continue;
                    }

                    $matchingEvents[] = $event;
                    $isMatchingCall = true;

                    if ($isCall) {
                        ++$matchCount;
                    }
                }
            }

            if (!$isCall && $isMatchingCall) {
                ++$matchCount;
            }
        }

        if ($isCall) {
            $totalCount = $eventCount;
        } else {
            $totalCount = $this->callCount;
        }

        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccess($matchingEvents);
        }

        return null;
    }
public function checkProduced ( $ keyOrValue = null , $ value = null ) : ? EventCollection { $ cardinality = $ this -> resetCardinality ( ) ; $ argumentCount = func_num_args ( ) ; if ( 0 === $ argumentCount ) { $ checkKey = false ; $ checkValue = false ; } elseif ( 1 === $ argumentCount ) { $ checkKey = false ; $ checkValue = true ; $ value = $ this -> matcherFactory -> adapt ( $ keyOrValue ) ; } else { $ checkKey = true ; $ checkValue = true ; $ key = $ this -> matcherFactory -> adapt ( $ keyOrValue ) ; $ value = $ this -> matcherFactory -> adapt ( $ value ) ; } $ isCall = $ this -> subject instanceof Call ; $ matchingEvents = [ ] ; $ matchCount = 0 ; $ eventCount = 0 ; foreach ( $ this -> calls as $ call ) { $ isMatchingCall = false ; foreach ( $ call -> iterableEvents ( ) as $ event ) { if ( $ event instanceof ProducedEvent ) { ++ $ eventCount ; if ( $ checkKey && ! $ key -> matches ( $ event -> key ( ) ) ) { continue ; } if ( $ checkValue && ! $ value -> matches ( $ event -> value ( ) ) ) { continue ; } $ matchingEvents [ ] = $ event ; $ isMatchingCall = true ; if ( $ isCall ) { ++ $ matchCount ; } } } if ( ! $ isCall && $ isMatchingCall ) { ++ $ matchCount ; } } if ( $ isCall ) { $ totalCount = $ eventCount ; } else { $ totalCount = $ this -> callCount ; } if ( $ cardinality -> matches ( $ matchCount , $ totalCount ) ) { return $ this -> assertionRecorder -> createSuccess ( $ matchingEvents ) ; } return null ; }
Checks if the subject produced the supplied values.

When called with no arguments, this method simply checks that the subject
produced any value.

With a single argument, it checks that a value matching the argument was
produced.

With two arguments, it checks that a key and value matching the
respective arguments were produced together.

@param mixed $keyOrValue The key or value.
@param mixed $value      The value.

@return EventCollection|null The result.
Checks if the subject produced the supplied values .