/** * @param string $message * * @throws NotificationExpectationMismatchException */ public function checkSuccessNotificationMessage($message) { if ($this->notificationAccessor->hasSuccessMessage() && $this->notificationAccessor->hasMessage($message)) { return; } throw new NotificationExpectationMismatchException('success', $message, $this->notificationAccessor->getMessageType(), $this->notificationAccessor->getMessage()); }
function it_throws_notification_mismatch_exception_if_diffrent_message_type_has_been_found(NotificationAccessorInterface $notificationAccessor) { $notificationAccessor->hasSuccessMessage()->willReturn(false); $notificationAccessor->hasMessage('Some resource has been successfully created.')->willReturn(false); $notificationAccessor->getMessageType()->willReturn('failure'); $notificationAccessor->getMessage()->willReturn('Some resource has been successfully created.'); $this->shouldThrow(new NotificationExpectationMismatchException('success', 'Some resource has been successfully created.', 'failure', 'Some resource has been successfully created.'))->during('checkSuccessNotificationMessage', ['Some resource has been successfully created.']); }
function it_throws_notification_mismatch_exception_if_success_message_type_has_been_found_but_expect_failure(NotificationAccessorInterface $notificationAccessor) { $notificationAccessor->getType()->willReturn(NotificationType::success()); $notificationAccessor->getMessage()->willReturn('Something went wrong.'); $this->shouldThrow(new NotificationExpectationMismatchException(NotificationType::failure(), 'Something went wrong.', NotificationType::success(), 'Something went wrong.'))->during('checkNotification', ['Something went wrong.', NotificationType::failure()]); }
/** * @param string $message * * @return bool */ private function hasMessage($message) { return false !== strpos($this->notificationAccessor->getMessage(), $message); }