mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
Merge pull request #126 from php-flasher/test/envelope
test: add more envelope tests
This commit is contained in:
@@ -18,7 +18,7 @@ class FlasherContainerTest extends TestCase
|
||||
public function testInit()
|
||||
{
|
||||
$this->setProperty('Flasher\Prime\Container\FlasherContainer', 'instance', null);
|
||||
$container = $this->mock('Flasher\Prime\Container\ContainerInterface');
|
||||
$container = $this->getMockBuilder('Flasher\Prime\Container\ContainerInterface')->getMock();
|
||||
|
||||
FlasherContainer::init($container);
|
||||
|
||||
@@ -34,10 +34,10 @@ class FlasherContainerTest extends TestCase
|
||||
{
|
||||
$this->setProperty('Flasher\Prime\Container\FlasherContainer', 'instance', null);
|
||||
|
||||
$container = $this->mock('Flasher\Prime\Container\ContainerInterface');
|
||||
$container = $this->getMockBuilder('Flasher\Prime\Container\ContainerInterface')->getMock();
|
||||
$container
|
||||
->method('get')
|
||||
->willreturn($this->mock('Flasher\Prime\FlasherInterface'));
|
||||
->willreturn($this->getMockBuilder('Flasher\Prime\FlasherInterface')->getMock());
|
||||
|
||||
FlasherContainer::init($container);
|
||||
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Envelope;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class EnvelopeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = new Envelope($notification, array($stamp));
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp) => $stamp), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWith()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp1 = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
$stamp2 = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->with($stamp1, $stamp2);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp1) => $stamp1, \get_class($stamp2) => $stamp2), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWrap()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = Envelope::wrap($notification, array($stamp));
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp) => $stamp), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAll()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamps = array(
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
);
|
||||
|
||||
$envelope = new Envelope($notification, $stamps);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamps[0]) => $stamps[3]), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$notification = $this->getMockBuilder('\Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamps = array(
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
$this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(),
|
||||
);
|
||||
|
||||
$envelope = new Envelope($notification, $stamps);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
|
||||
$last = $envelope->get(\get_class($stamps[0]));
|
||||
|
||||
$this->assertEquals($stamps[2], $last);
|
||||
$this->assertEquals($last, $envelope->get(\get_class($stamps[0])));
|
||||
|
||||
$this->assertNull($envelope->get('NotFoundStamp')); // @phpstan-ignore-line
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the PHPFlasher package.
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Notification;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use Flasher\Prime\Notification\Notification;
|
||||
use Flasher\Prime\Stamp\HandlerStamp;
|
||||
use Flasher\Prime\Stamp\HopsStamp;
|
||||
use Flasher\Prime\Stamp\PresetStamp;
|
||||
use Flasher\Tests\Prime\TestCase;
|
||||
|
||||
final class EnvelopeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = new Envelope($notification, array($stamp));
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp) => $stamp), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWrap()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = Envelope::wrap($notification, array($stamp));
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp) => $stamp), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWith()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp1 = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
$stamp2 = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->with($stamp1, $stamp2);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp1) => $stamp1, \get_class($stamp2) => $stamp2), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWithStamp()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->withStamp($stamp);
|
||||
|
||||
$this->assertContains($stamp, $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWithout()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp1 = new HopsStamp(2);
|
||||
$stamp2 = new HandlerStamp('flasher');
|
||||
$stamp3 = new PresetStamp('entity_saved');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->with($stamp1, $stamp2, $stamp3);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp1) => $stamp1, \get_class($stamp2) => $stamp2, \get_class($stamp3) => $stamp3), $envelope->all());
|
||||
|
||||
$envelope->without($stamp1, $stamp3);
|
||||
|
||||
$this->assertEquals(array(\get_class($stamp2) => $stamp2), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testWithoutStamp()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamp1 = new HopsStamp(2);
|
||||
$stamp2 = new HandlerStamp('flasher');
|
||||
$stamp3 = new PresetStamp('entity_saved');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->with($stamp1, $stamp2, $stamp3);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamp1) => $stamp1, \get_class($stamp2) => $stamp2, \get_class($stamp3) => $stamp3), $envelope->all());
|
||||
|
||||
$envelope->withoutStamp($stamp1);
|
||||
|
||||
$this->assertEquals(array(\get_class($stamp2) => $stamp2, \get_class($stamp3) => $stamp3), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$notification = $this->getMockBuilder('\Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamps = array(
|
||||
new HopsStamp(2),
|
||||
new HandlerStamp('flasher'),
|
||||
new PresetStamp('entity_saved'),
|
||||
);
|
||||
|
||||
$envelope = new Envelope($notification, $stamps);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
|
||||
$last = $envelope->get(\get_class($stamps[0]));
|
||||
|
||||
$this->assertEquals($stamps[0], $last);
|
||||
$this->assertEquals($last, $envelope->get(\get_class($stamps[0])));
|
||||
|
||||
$this->assertNull($envelope->get('NotFoundStamp')); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAll()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$stamps = array(
|
||||
new HopsStamp(2),
|
||||
new HandlerStamp('flasher'),
|
||||
new PresetStamp('entity_saved'),
|
||||
);
|
||||
|
||||
$envelope = new Envelope($notification, $stamps);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
$this->assertEquals(array(\get_class($stamps[0]) => $stamps[0], \get_class($stamps[1]) => $stamps[1], \get_class($stamps[2]) => $stamps[2]), $envelope->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetNotification()
|
||||
{
|
||||
$notification = new Notification();
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals($notification, $envelope->getNotification());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetType()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('getType')->willReturn('success');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals('success', $envelope->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetType()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('setType');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->setType('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetMessage()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('getMessage')->willReturn('success message');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals('success message', $envelope->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetMessage()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('setMessage');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->setMessage('success message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetTitle()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('getTitle')->willReturn('success title');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals('success title', $envelope->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetTitle()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('setTitle');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->setTitle('success title');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetOptions()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('getOptions')->willReturn(array('timeout' => 2500));
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals(array('timeout' => 2500), $envelope->getOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetOptions()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('setOptions');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->setOptions(array('timeout' => 2500));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetOption()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('getOption')->willReturn(2500);
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals(2500, $envelope->getOption('timeout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetOption()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('setOption');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->setOption('timeout', 2500);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testUnsetOption()
|
||||
{
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('unsetOption');
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
$envelope->unsetOption('timeout');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testToArray()
|
||||
{
|
||||
$array = array(
|
||||
'title' => 'PHPFlasher',
|
||||
'message' => 'success message',
|
||||
'options' => array('timeout' => 2500),
|
||||
);
|
||||
|
||||
$notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock();
|
||||
$notification->expects($this->once())->method('toArray')->willReturn($array);
|
||||
|
||||
$envelope = new Envelope($notification);
|
||||
|
||||
$this->assertEquals(array('notification' => $array), $envelope->toArray());
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddSuccessMessage()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -41,7 +41,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddErrorMessage()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -58,7 +58,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddWarningMessage()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -75,7 +75,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddInfoMessage()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -92,7 +92,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddFlashMessage()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -109,7 +109,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testPushToStorage()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -359,7 +359,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddPreset()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -378,7 +378,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddOperation()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -397,7 +397,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddCreated()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -416,7 +416,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddUpdated()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -435,7 +435,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddSaved()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -454,7 +454,7 @@ class NotificationBuilderTest extends TestCase
|
||||
*/
|
||||
public function testAddDeleted()
|
||||
{
|
||||
$storageManager = $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
$storageManager->expects($this->once())->method('add');
|
||||
|
||||
$builder = $this->getNotificationBuilder($storageManager);
|
||||
@@ -588,7 +588,7 @@ class NotificationBuilderTest extends TestCase
|
||||
{
|
||||
$builder = $this->getNotificationBuilder();
|
||||
|
||||
$stamp = $this->mock('Flasher\Prime\Stamp\StampInterface');
|
||||
$stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock();
|
||||
$builder->withStamp($stamp);
|
||||
|
||||
$envelope = $builder->getEnvelope();
|
||||
@@ -655,7 +655,7 @@ class NotificationBuilderTest extends TestCase
|
||||
private function getNotificationBuilder(StorageManagerInterface $storageManager = null)
|
||||
{
|
||||
/** @var StorageManagerInterface $storageManager */
|
||||
$storageManager = $storageManager ?: $this->mock('Flasher\Prime\Storage\StorageManagerInterface');
|
||||
$storageManager = $storageManager ?: $this->getMockBuilder('Flasher\Prime\Storage\StorageManagerInterface')->getMock();
|
||||
|
||||
return new NotificationBuilder($storageManager, new Notification());
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Envelope\Stamp;
|
||||
namespace Flasher\Tests\Prime\Stamp;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use Flasher\Prime\Stamp\CreatedAtStamp;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Envelope\Stamp;
|
||||
namespace Flasher\Tests\Prime\Stamp;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use Flasher\Prime\Stamp\HandlerStamp;
|
||||
@@ -5,7 +5,7 @@
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Envelope\Stamp;
|
||||
namespace Flasher\Tests\Prime\Stamp;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use Flasher\Prime\Stamp\HopsStamp;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Envelope\Stamp;
|
||||
namespace Flasher\Tests\Prime\Stamp;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use Flasher\Prime\Stamp\HopsStamp;
|
||||
@@ -5,7 +5,7 @@
|
||||
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Flasher\Tests\Prime\Envelope\Stamp;
|
||||
namespace Flasher\Tests\Prime\Stamp;
|
||||
|
||||
use Flasher\Prime\Notification\Envelope;
|
||||
use Flasher\Prime\Stamp\UuidStamp;
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
namespace Flasher\Tests\Prime;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
@@ -101,14 +99,4 @@ class TestCase extends \PHPUnit\Framework\TestCase
|
||||
$object = is_string($object) ? null : $object;
|
||||
$property->setValue($object, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
*
|
||||
* @return MockObject
|
||||
*/
|
||||
protected function mock($className)
|
||||
{
|
||||
return $this->getMockBuilder($className)->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user