Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin][Promotion] Fix removing taxon used in promotion rule #10365

Merged
merged 8 commits into from
May 13, 2019
Prev Previous commit
Next Next commit
[Behat] Add info type to notification checker
  • Loading branch information
GSadee committed May 10, 2019
commit fd1d220a2cb541d29d3d9316d55e7ab9bea7e377
32 changes: 10 additions & 22 deletions src/Sylius/Behat/NotificationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,32 @@ final class NotificationType
/** @var array */
private static $types = [];

/**
* @param string $value
*/
private function __construct($value)
private function __construct(string $value)
{
$this->value = $value;
}

/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->value;
}

/**
* @return NotificationType
*/
public static function failure()
public static function failure(): NotificationType
{
return static::getTyped('failure');
}

/**
* @return NotificationType
*/
public static function success()
public static function success(): NotificationType
{
return static::getTyped('success');
}

/**
* @param string $type
*
* @return NotificationType
*/
private static function getTyped($type)
public static function info(): NotificationType
{
return static::getTyped('info');
}

private static function getTyped(string $type): NotificationType
{
if (!isset(static::$types[$type])) {
static::$types[$type] = new self($type);
Expand Down
11 changes: 10 additions & 1 deletion src/Sylius/Behat/Service/NotificationChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,21 @@ public function checkNotification(string $message, NotificationType $type): void
foreach ($this->notificationAccessor->getMessageElements() as $messageElement) {
if (
false !== strpos($messageElement->getText(), $message) &&
$messageElement->hasClass($type->__toString() === 'success' ? 'positive' : 'negative')
$messageElement->hasClass($this->resolveClass($type))
) {
return;
}
}

throw new NotificationExpectationMismatchException($type, $message);
}

private function resolveClass(NotificationType $type): string
{
if ($type->__toString() === 'info') {
return 'info';
}

return $type->__toString() === 'success' ? 'positive' : 'negative';
GSadee marked this conversation as resolved.
Show resolved Hide resolved
}
}