Skip to content

Instantly share code, notes, and snippets.

@jorgejavierleon
Created August 19, 2016 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgejavierleon/96fd4bebf30324608c8a85aa15ef85a1 to your computer and use it in GitHub Desktop.
Save jorgejavierleon/96fd4bebf30324608c8a85aa15ef85a1 to your computer and use it in GitHub Desktop.
<?php
trait NotifiersHelpers
{
/**
* @param bool|false $negate
* @return $this
*/
public function seeNotification($negate = false)
{
$session = $this->app['session.store'];
if($negate){
$message = 'It has a notifier';
$this->assertNull($session->get('notifier'), $message);
return $this;
}
$message = 'It does not have a notifier';
$this->assertNotNull($session->get('notifier'), $message);
return $this;
}
/**
* @return NotifiersHelpers
*/
public function dontSeeNotification()
{
return $this->seeNotification(true);
}
/**
* @param $notificacionBody
* @param bool $negate
* @return $this
*/
public function seeNotificationBody($notificacionBody, $negate = false)
{
$session = $this->app['session.store'];
$sessionBody = $session->get('notifier.text');
if($negate){
$message = "It has a notifier with body '$notificacionBody'";
$this->assertNotEquals($notificacionBody, $sessionBody, $message);
return $this;
}
$this->seeNotification();
$message = "It does not have a notifier with body '$notificacionBody'";
$this->assertEquals($notificacionBody, $sessionBody, $message);
return $this;
}
/**
* @param $notificacionBody
* @return NotifiersHelpers
*/
public function dontSeeNotificationBody($notificacionBody)
{
return $this->seeNotificationBody($notificacionBody, true);
}
/**
* @param $notificacionTitle
* @param bool $negate
* @return $this
*/
public function seeNotificationTitle($notificacionTitle, $negate = false)
{
$session = $this->app['session.store'];
$sessionTitle = $session->get('notifier.title');
if($negate){
$message = "It has a notifier with title '$notificacionTitle'";
$this->assertNotEquals($notificacionTitle, $sessionTitle, $message);
return $this;
}
$this->seeNotification();
$message = "It does not have a notifier with title '$notificacionTitle'";
$this->assertEquals($notificacionTitle, $sessionTitle, $message);
return $this;
}
/**
* @param $notificacionTitle
* @return NotifiersHelpers
*/
public function dontSeeNotificationTitle($notificacionTitle)
{
return $this->seeNotificationTitle($notificacionTitle, true);
}
/**
* @param $notificacionType
* @param bool $negate
* @return $this
*/
public function seeNotificationType($notificacionType, $negate = false)
{
$session = $this->app['session.store'];
$sessionType = $session->get('notifier.type');
if($negate){
$message = "It has a notifier with type '$notificacionType'";
$this->assertNotEquals($notificacionType, $sessionType, $message);
return $this;
}
$this->seeNotification();
$message = "It does not have a notifier with type '$notificacionType'";
$this->assertEquals($notificacionType, $sessionType, $message);
return $this;
}
/**
* @param $notificacionType
* @return NotifiersHelpers
*/
public function dontSeeNotificationType($notificacionType)
{
return $this->seeNotificationType($notificacionType, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment