Record that a successful assertion occurred.

@param array<Event> $events The events.

@return EventCollection The result.
510729
public function createSuccess(array $events = []): EventCollection
    {
        $suiteClass = $this->suiteClass;
        $suiteClass::current()->assert($this->successConfig);

        return new EventSequence($events, $this->callVerifierFactory);
    }
89339
private function buildEventAggregateAsArray(array $events)
    {
        $returnArray = [];

        /** @var Event $event */
        foreach ($events as $event) {
            $returnArray[] = [
                'uuid' => (string) $event->uuid(),
                'version' => $event->version(),
                'payload' => $event->payload(),
                'type' => $event->type(),
                'body' => $event->body(),
                'occurred_on' => $event->occurredOn()->format('Y-m-d H:i:s.u')
            ];
        }

        return $returnArray;
    }
1005673
public static function checkInOrder(...$events): ?EventCollection
    {
        $container = self::$globals::$container;

        return $container->eventOrderVerifier->checkInOrder(...$events);
    }
285247
public function persist(array $events)
    {
        $factory = new EventFactory();
        $events = array_map(
            function ($event) use ($factory) {
                return is_array($event) ? $factory->create($event) : $event;
            },
            $events
        );
        $this->persister()->logEvents($events);
    }
142899
private function eventsShouldExistInStore(DomainEvent ...$events) {
        $expected = array_map(function (DomainEvent $event) {
            return $this->serializer->serialize($event);
        }, $events);

        $existing = $this->eventStore->getEvents()->map(function(DomainEvent $event) {
            return $this->serializer->serialize($event);
        })->toArray();

        $notFound = array_filter($expected, function($expectedEvent) use ($existing) {
            return ! in_array($expectedEvent, $existing);
        });

        if (empty($notFound)) return;

        throw new FailureException($this->missingEventExceptionMessage($notFound));
    }
1005960
public function checkIterated(): ?IterableVerifier
    {
        $cardinality = $this->resetCardinality();

        $calls = $this->spy->allCalls();
        $matchingEvents = [];
        $totalCount = count($calls);
        $matchCount = 0;

        foreach ($calls as $call) {
            if (!$call->responseEvent()) {
                continue;
            }

            list(, $returnValue) = $call->response();

            if ($returnValue instanceof Traversable || is_array($returnValue)) {
                $matchingEvents[] = $call;
                ++$matchCount;
            }
        }

        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccessFromEventCollection(
                $this->iterableVerifierFactory
                    ->create($this->spy, $matchingEvents)
            );
        }

        return null;
    }
875239
public static function runMany($events)
    {
        foreach ($events as $key => $value) {
            $name = '\Vinala\App\Events\\'.$key;

            $object = new $name();

            if (is_array($value)) {
                foreach ($value as $function) {
                    $function = self::$listners[$key.'.'.$function];

                    $object->$function();
                }
            } elseif (is_string($value)) {
                $function = self::$listners[$key.'.'.$value];

                $object->$function();
            }
        }

        return true;
    }
1296284
public function checkConsumed(): ?EventCollection
    {
        $cardinality = $this->resetCardinality();

        if ($this->subject instanceof Call) {
            $cardinality->assertSingular();
        }

        $matchingEvents = [];
        $matchCount = 0;

        foreach ($this->calls as $call) {
            if (!$endEvent = $call->endEvent()) {
                continue;
            }
            if (!$call->isIterable()) {
                continue;
            }

            ++$matchCount;
            $matchingEvents[] = $endEvent;
        }

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

        return null;
    }
769212
public function processAssertions(ArrayCollection $assertions) : ArrayCollection
    {
        $processed = new ArrayCollection();
        foreach ($assertions->getIterator() as $assertion) {
            $processed->add($this->process($assertion));
        }

        return $processed;
    }
1151188
public function attachEvents($events=array()) {
		if (\is_array($events)) {
			foreach ( $events as $action => $selector ) {
				$this->attachEvent($selector, $action);
			}
		}
		return $this;
	}
1111100
public function deferEvents($events)
    {
        $this->_events
            ->register('startTransaction', function() use ($events) {
                $events->cork();
            })
            ->register('commitTransaction', function() use ($events) {
                $events->uncork();
            })
            ->register('rollbackTransaction', function() use ($events) {
                $events->discard()->uncork();
            })
            ;
    }
46969
public function publish(array $events, CommandBus $commandBus, bool $qeueEvents = false): void
    {
        $eventStreamObjects = [];
        /**
         * @var EventInterface $event
         */
        foreach ($events as $event) {
            // Save the event to the event stream.
            $eventStreamObject = new EventStreamObject();
            $eventStreamObject->setUuid($event->getCommand()->getAggregateUuid());
            $eventStreamObject->setCommandUuid($event->getCommand()->getUuid());
            $eventStreamObject->setPayload($event->getCommand()->getPayload());
            $eventStreamObject->setMessage($event->getMessage());
            $eventStreamObject->setEvent(\get_class($event));
            $eventStreamObject->setAggregateClass($event->getCommand()->getAggregateClass());
            $eventStreamObject->setVersion($event->getCommand()->getOnVersion() + 1);
            $eventStreamObject->setUser($event->getCommand()->getUser());

            // Add to list of eventStreamObjects so we can later notify aggregateSubscribers.
            $eventStreamObjects[] = $eventStreamObject;

            // Add the events to the eventStore.
            if ($qeueEvents) {
                $eventQeueObject = new EventQeueObject($eventStreamObject);
                $this->eventStore->qeue($eventQeueObject);
                $message = 'Qeued event: '.$event->getMessage();
            } else {
                $this->eventStore->add($eventStreamObject);
                $message = 'Persisted event: '.$event->getMessage();
            }

            // Dispatch messages about the events.
            $this->messageBus->dispatch(new Message(
                $message,
                $event::getCode(),
                $event->getCommand()->getUuid(),
                $event->getCommand()->getAggregateUuid(),
                null,
                $event->getCommand()->getPayload()
            ));
        }

        try {
            $this->eventStore->save();

            // Listeners are called even if the events are just qeued!
            // They are not called again when the events are persisted to the event stream!
            $this->invokeListeners($events, $commandBus);

            // Notify subscribers.
            // Subscribers are notified AFTER the events listeners are processed.
            // Subscribers are NOT notified of qeued events.
            if (!$qeueEvents) {
                $this->sendAggregateUpdates($eventStreamObjects);
            }
        } catch (\Exception $e) {
            // Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                null,
                null,
                $e
            ));
        }
    }
914708
public function deleteEvents($events)
    {
        $data = array (
                'token'        => $this->apiToken,
                'content'      => 'event',
                'action'       => 'delete',
                'returnFormat' => 'json',
        );
        
        $data['events'] = $this->processEventsArgument($events, $required = true);
        
        $result = $this->connection->callWithArray($data);
        
        $this->processNonExportResult($result);
        
        return (integer) $result;
    }
41644
public function setEvents(array $events)
	{
		if ($events) {
			$this->ensureEvents();
			
			foreach ($events as $name => $handler) {
				$this->on($name, $handler);
			}
		}
	}
388314
private function getListenableEventList($events)
    {
        $eventList = array();

        foreach ($events as $item) {
            $event = is_array($item) ? key($item) : $item;

            $eventList[$event] = array(
                'event' => $event,
                'method' => 'resolveEventHandler',
            );
        }

        return $eventList;
    }
1156758
protected function eventCollection(): EventCollection
    {
        if ($this->eventCollection === null) {
            $this->eventCollection = new EventCollection($this->id(), Type::create($this));
        }

        return $this->eventCollection;
    }
250737
public function onSave(Event\Save $event)
    {
        $success = $event->getUser()->save();
        $event->setResult( (bool)$success );
        if( $event->getResult() === false )
        {
            $event->stopPropagation(true);
        }
        return $event;
    }