diff --git a/composer.json b/composer.json index aa57523e..8eac45f8 100644 --- a/composer.json +++ b/composer.json @@ -13,12 +13,18 @@ ], "require": { "php": ">=5.3", - "ext-json": "*" + "ext-json": "*", + "phpunit/phpunit": "^4.8" }, "autoload": { "psr-4": { "Flasher\\": "src/" } }, - "minimum-stability": "dev" + "minimum-stability": "dev", + "config": { + "platform": { + "php": "5.4" + } + } } diff --git a/src/Laravel/composer.json b/src/Laravel/composer.json index 9a48098d..cdd4a7b2 100644 --- a/src/Laravel/composer.json +++ b/src/Laravel/composer.json @@ -32,6 +32,9 @@ "illuminate/support": "^4.0|^5.0|^6.0|^7.0|^8.0", "php-flasher/flasher": "dev-main" }, + "require-dev": { + "orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0" + }, "autoload": { "psr-4": { "Flasher\\Laravel\\": "", diff --git a/src/Prime/Stamp/HopsStamp.php b/src/Prime/Stamp/HopsStamp.php index c9caea2d..e28c5319 100644 --- a/src/Prime/Stamp/HopsStamp.php +++ b/src/Prime/Stamp/HopsStamp.php @@ -2,7 +2,7 @@ namespace Flasher\Prime\Stamp; -final class HopsStamp implements StampInterface +final class HopsStamp implements StampInterface, \Flasher\Prime\Stamp\OrderableStampInterface { /** * @var int diff --git a/src/Prime/Tests/Config/ConfigTest.php b/src/Prime/Tests/Config/ConfigTest.php index 7c5088ea..a8073984 100644 --- a/src/Prime/Tests/Config/ConfigTest.php +++ b/src/Prime/Tests/Config/ConfigTest.php @@ -2,7 +2,7 @@ namespace Flasher\Prime\Tests\Config; -use Notify\Config\Config; +use Flasher\Prime\Config\Config; use PHPUnit\Framework\TestCase; final class ConfigTest extends TestCase @@ -11,9 +11,9 @@ final class ConfigTest extends TestCase { $config = new Config( array( - 'default' => 'notify', + 'default' => 'default_flasher', 'drivers' => array( - 'notify' => array( + 'toastr' => array( 'scripts' => array('script.js'), 'styles' => array('styles.css'), 'options' => array() @@ -22,14 +22,14 @@ final class ConfigTest extends TestCase ) ); - $this->assertEquals('notify', $config->get('default')); + $this->assertEquals('default_flasher', $config->get('default')); $this->assertEquals( array( 'scripts' => array('script.js'), 'styles' => array('styles.css'), 'options' => array() ), - $config->get('drivers.notify') + $config->get('drivers.toastr') ); $this->assertEquals(array('styles.css'), $config->get('drivers.flasher.styles')); $this->assertEquals(array(), $config->get('drivers.flasher.options')); diff --git a/src/Prime/Tests/Envelope/EnvelopeTest.php b/src/Prime/Tests/Envelope/EnvelopeTest.php index 426b3e5e..80910194 100644 --- a/src/Prime/Tests/Envelope/EnvelopeTest.php +++ b/src/Prime/Tests/Envelope/EnvelopeTest.php @@ -67,7 +67,7 @@ final class EnvelopeTest extends TestCase $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), ); - $envelope = new \Flasher\Prime\Envelope($notification, $stamps); + $envelope = new Envelope($notification, $stamps); $this->assertSame($notification, $envelope->getNotification()); diff --git a/src/Prime/Tests/Envelope/Stamp/CreatedAtStampTest.php b/src/Prime/Tests/Envelope/Stamp/CreatedAtStampTest.php index 4c340e65..e2d688a5 100644 --- a/src/Prime/Tests/Envelope/Stamp/CreatedAtStampTest.php +++ b/src/Prime/Tests/Envelope/Stamp/CreatedAtStampTest.php @@ -22,8 +22,8 @@ final class CreatedAtStampTest extends TestCase public function testCompare() { - $createdAt1 = new \Flasher\Prime\Stamp\CreatedAtStamp(new \DateTime('+2 h')); - $createdAt2 = new \Flasher\Prime\Stamp\CreatedAtStamp(new \DateTime('+1 h')); + $createdAt1 = new CreatedAtStamp(new \DateTime('+2 h')); + $createdAt2 = new CreatedAtStamp(new \DateTime('+1 h')); $this->assertFalse($createdAt1->compare($createdAt2)); $this->assertSame(0, $createdAt1->compare(new HopsStamp(1))); diff --git a/src/Prime/Tests/Envelope/Stamp/LifeStampTest.php b/src/Prime/Tests/Envelope/Stamp/HopsStampTest.php similarity index 82% rename from src/Prime/Tests/Envelope/Stamp/LifeStampTest.php rename to src/Prime/Tests/Envelope/Stamp/HopsStampTest.php index f39b55ac..86dcd6d8 100644 --- a/src/Prime/Tests/Envelope/Stamp/LifeStampTest.php +++ b/src/Prime/Tests/Envelope/Stamp/HopsStampTest.php @@ -3,14 +3,15 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; use Flasher\Prime\Envelope; +use Flasher\Prime\Stamp\HopsStamp; use PHPUnit\Framework\TestCase; -final class LifeStampTest extends TestCase +final class HopsStampTest extends TestCase { public function testConstruct() { $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); - $stamp = new \Flasher\Prime\Stamp\HopsStamp(5); + $stamp = new HopsStamp(5); $envelop = new Envelope($notification, array($stamp)); diff --git a/src/Prime/Tests/Envelope/Stamp/PriorityStampTest.php b/src/Prime/Tests/Envelope/Stamp/PriorityStampTest.php index 92ba7a7a..f6469b1a 100644 --- a/src/Prime/Tests/Envelope/Stamp/PriorityStampTest.php +++ b/src/Prime/Tests/Envelope/Stamp/PriorityStampTest.php @@ -3,6 +3,7 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; use Flasher\Prime\Envelope; +use Flasher\Prime\Stamp\HopsStamp; use Flasher\Prime\Stamp\PriorityStamp; use PHPUnit\Framework\TestCase; @@ -23,9 +24,9 @@ final class PriorityStampTest extends TestCase public function testCompare() { $stamp1 = new PriorityStamp(1); - $stamp2 = new \Flasher\Prime\Stamp\PriorityStamp(2); + $stamp2 = new PriorityStamp(2); $this->assertFalse($stamp1->compare($stamp2)); - $this->assertSame(0, $stamp1->compare(new \Flasher\Prime\Stamp\HopsStamp(1))); + $this->assertSame(0, $stamp1->compare(new HopsStamp(1))); } } diff --git a/src/Prime/Tests/Envelope/Stamp/RendererStampTest.php b/src/Prime/Tests/Envelope/Stamp/RendererStampTest.php index d5661546..5ca1ba5f 100644 --- a/src/Prime/Tests/Envelope/Stamp/RendererStampTest.php +++ b/src/Prime/Tests/Envelope/Stamp/RendererStampTest.php @@ -3,6 +3,7 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; use Flasher\Prime\Envelope; +use Flasher\Prime\Stamp\HandlerStamp; use PHPUnit\Framework\TestCase; final class RendererStampTest extends TestCase @@ -10,7 +11,7 @@ final class RendererStampTest extends TestCase public function testConstruct() { $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); - $stamp = new \Flasher\Prime\Stamp\HandlerStamp('toastr'); + $stamp = new HandlerStamp('toastr'); $envelop = new Envelope($notification, array($stamp)); diff --git a/src/Prime/Tests/Envelope/Stamp/UuidStampTest.php b/src/Prime/Tests/Envelope/Stamp/UuidStampTest.php index b1a2ef3c..92fb432d 100644 --- a/src/Prime/Tests/Envelope/Stamp/UuidStampTest.php +++ b/src/Prime/Tests/Envelope/Stamp/UuidStampTest.php @@ -3,6 +3,7 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; use Flasher\Prime\Envelope; +use Flasher\Prime\Stamp\UuidStamp; use PHPUnit\Framework\TestCase; final class UuidStampTest extends TestCase @@ -10,7 +11,7 @@ final class UuidStampTest extends TestCase public function testConstruct() { $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); - $stamp = new \Flasher\Prime\Stamp\UuidStamp(); + $stamp = new UuidStamp(); $envelop = new Envelope($notification, array($stamp)); diff --git a/src/Prime/Tests/Filter/CriteriaBuilderTest.php b/src/Prime/Tests/Filter/CriteriaBuilderTest.php index a661b648..ecd2d94b 100644 --- a/src/Prime/Tests/Filter/CriteriaBuilderTest.php +++ b/src/Prime/Tests/Filter/CriteriaBuilderTest.php @@ -10,14 +10,12 @@ final class CriteriaBuilderTest extends TestCase { public function testCriteria() { - $criteria = new CriteriaBuilder( - new FilterBuilder(), array( - 'priority' => 1, - 'life' => 2, - 'limit' => 2, - 'order_by' => 'Flasher\Prime\Stamp\HopsStamp', - ) - ); + $criteria = new CriteriaBuilder(new FilterBuilder(), array( + 'priority' => 1, + 'life' => 2, + 'limit' => 2, + 'order_by' => 'Flasher\Prime\Stamp\HopsStamp', + )); $this->assertInstanceOf('Flasher\Prime\Filter\FilterBuilder', $criteria->build()); $this->assertNotEmpty($criteria->build()->getSpecification()); diff --git a/src/Prime/Tests/Filter/DefaultFilterTest.php b/src/Prime/Tests/Filter/DefaultFilterTest.php index bbe974fd..feaec16e 100644 --- a/src/Prime/Tests/Filter/DefaultFilterTest.php +++ b/src/Prime/Tests/Filter/DefaultFilterTest.php @@ -2,7 +2,7 @@ namespace Flasher\Prime\Tests\Filter; -use Notify\Config\Config; +use Flasher\Prime\Config\Config; use Flasher\Prime\Envelope; use Flasher\Prime\Middleware\AddCreatedAtStampMiddleware; use Flasher\Prime\Middleware\AddPriorityStampMiddleware; diff --git a/src/Prime/Tests/Filter/FilterManagerTest.php b/src/Prime/Tests/Filter/FilterManagerTest.php index 29ef137c..1184858f 100644 --- a/src/Prime/Tests/Filter/FilterManagerTest.php +++ b/src/Prime/Tests/Filter/FilterManagerTest.php @@ -2,13 +2,13 @@ namespace Flasher\Prime\Tests\Filter; -use Notify\Config\Config; +use Flasher\Prime\Config\Config; use Flasher\Prime\Envelope; use Flasher\Prime\Filter\FilterBuilder; use Flasher\Prime\Filter\Specification\PrioritySpecification; use Flasher\Prime\Middleware\AddCreatedAtStampMiddleware; use Flasher\Prime\Middleware\AddPriorityStampMiddleware; -use Flasher\Prime\MiddlewareFlasher\PrimeBus; +use Flasher\Prime\Middleware\FlasherBus; use Flasher\Prime\Stamp\PriorityStamp; use PHPUnit\Framework\TestCase; @@ -54,7 +54,7 @@ final class FilterManagerTest extends TestCase ) ); - $middleware = new NotifyBus($config); + $middleware = new FlasherBus($config); $envelopes = array(); foreach ($notifications as $notification) { diff --git a/src/Prime/Tests/Manager/ManagerTest.php b/src/Prime/Tests/Manager/ManagerTest.php index d37b1677..f200a426 100644 --- a/src/Prime/Tests/Manager/ManagerTest.php +++ b/src/Prime/Tests/Manager/ManagerTest.php @@ -2,32 +2,32 @@ namespace Flasher\Prime\Tests\Manager; -use NotifyFlasher\Prime; +use Flasher\Prime\Flasher; use Flasher\Prime\Tests\TestCase; final class ManagerTest extends TestCase { public function testDefaultDriver() { - $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); + $config = $this->getMockBuilder('Flasher\Prime\Config\ConfigInterface')->getMock(); $config->method('get') ->with('default') ->willReturn('default_notifier'); - $manager = new Notify($config); + $manager = new Flasher($config); $this->assertEquals('default_notifier', $manager->getDefaultDriver()); } public function testMakeDriver() { - $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); + $config = $this->getMockBuilder('Flasher\Prime\Config\ConfigInterface')->getMock(); $config->method('get') ->with('default') ->willReturn('default_notifier'); - $manager = new Notify($config); + $manager = new Flasher($config); - $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); + $producer = $this->getMockBuilder('Flasher\Prime\Factory\FlasherFactoryInterface')->getMock(); $producer->method('supports')->willReturn(true); $manager->addDriver($producer); @@ -38,14 +38,14 @@ final class ManagerTest extends TestCase { $this->setExpectedException('InvalidArgumentException', 'Driver [test_driver] not supported.'); - $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); + $config = $this->getMockBuilder('Flasher\Prime\Config\ConfigInterface')->getMock(); $config->method('get') ->with('default') ->willReturn('default_notifier'); - $manager = new Notify($config); + $manager = new Flasher($config); - $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); + $producer = $this->getMockBuilder('Flasher\Prime\Factory\FlasherFactoryInterface')->getMock(); $manager->addDriver($producer); $manager->make('test_driver'); diff --git a/src/Prime/Tests/Middleware/MiddlewareStackTest.php b/src/Prime/Tests/Middleware/FlasherBusTest.php similarity index 93% rename from src/Prime/Tests/Middleware/MiddlewareStackTest.php rename to src/Prime/Tests/Middleware/FlasherBusTest.php index c7a40056..69a3d39e 100644 --- a/src/Prime/Tests/Middleware/MiddlewareStackTest.php +++ b/src/Prime/Tests/Middleware/FlasherBusTest.php @@ -6,11 +6,11 @@ use Flasher\Prime\Config\Config; use Flasher\Prime\Envelope; use Flasher\Prime\Middleware\AddCreatedAtStampMiddleware; use Flasher\Prime\Middleware\AddPriorityStampMiddleware; -use Flasher\Prime\Middleware\MiddlewareManager; +use Flasher\Prime\Middleware\FlasherBus; use Flasher\Prime\Stamp\PriorityStamp; use PHPUnit\Framework\TestCase; -final class MiddlewareStackTest extends TestCase +final class FlasherBusTest extends TestCase { public function testHandle() { @@ -29,7 +29,7 @@ final class MiddlewareStackTest extends TestCase ) )); - $stack = new MiddlewareManager($config); + $stack = new FlasherBus($config); $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); $envelope = new Envelope($notification); @@ -66,7 +66,7 @@ final class MiddlewareStackTest extends TestCase ) )); - $stack = new MiddlewareManager($config); + $stack = new FlasherBus($config); $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); $stamps = array( diff --git a/src/Prime/Tests/Producer/ProducerManagerTest.php b/src/Prime/Tests/Producer/ProducerManagerTest.php deleted file mode 100644 index ab0874a5..00000000 --- a/src/Prime/Tests/Producer/ProducerManagerTest.php +++ /dev/null @@ -1,72 +0,0 @@ -getMockBuilder('Notify\Config\ConfigInterface')->getMock(); - $manager = new Flasher\PrimeFlasher\Prime($config); - - $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); - $producer->method('supports')->willReturn(true); - $manager->addDriver($producer); - - $reflection = new ReflectionClass(get_class($manager)); - $extensions = $reflection->getProperty('drivers'); - $extensions->setAccessible(true); - - $drivers = $extensions->getValue($manager); - $this->assertCount(1, $drivers); - - $producer1 = $manager->make('producer_1'); - $this->assertSame($producer, $producer1); - } - - public function testNullDriver() - { - $this->setExpectedException('InvalidArgumentException', 'Driver [] not supported.'); - - $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); - $config->method('get')->willReturn(null); - - $manager = new \Flasher\PrimeFlasher\Prime($config); - - $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); - $manager->addDriver($producer); - - $this->assertSame($producer, $manager->make()); - } - - public function testNotSupportedDriver() - { - $this->setExpectedException('InvalidArgumentException', 'Driver [not_supported] not supported.'); - - $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); - $manager = new Flasher\PrimeFlasher\Prime($config); - - $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); - $manager->addDriver($producer); - - $this->assertSame($producer, $manager->make('not_supported')); - } - - public function testDispatcher() - { - $dispatcher = new EventDispatcher(); - $dispatcher->addListener(FlusherEvents::NOTIFICATION_CLEARED, function ($event) { - - return $event; - }); - - $dispatcher->dispatch(new Notification()); - } -} diff --git a/src/Prime/Tests/Storage/StorageManagerTest.php b/src/Prime/Tests/Storage/StorageManagerTest.php index 9ef22b1f..5d81d3fb 100644 --- a/src/Prime/Tests/Storage/StorageManagerTest.php +++ b/src/Prime/Tests/Storage/StorageManagerTest.php @@ -3,6 +3,7 @@ namespace Flasher\Prime\Tests\Storage; use Flasher\Prime\Envelope; +use Flasher\Prime\EventDispatcher\EventDispatcher; use Flasher\Prime\Notification\Notification; use Flasher\Prime\Stamp\HopsStamp; use Flasher\Prime\Stamp\UuidStamp; @@ -14,7 +15,7 @@ class StorageManagerTest extends TestCase { public function testAll() { - $storageManager = new StorageManager(new ArrayStorage()); + $storageManager = new StorageManager(new ArrayStorage(), new EventDispatcher()); $envelopes = array(); foreach (range(0, 4) as $index) { @@ -27,7 +28,7 @@ class StorageManagerTest extends TestCase public function testClear() { - $storageManager = new StorageManager(new ArrayStorage()); + $storageManager = new StorageManager(new ArrayStorage(), new EventDispatcher()); $envelopes = array(); foreach (range(0, 4) as $index) { @@ -42,7 +43,7 @@ class StorageManagerTest extends TestCase public function testAdd() { - $storageManager = new StorageManager(new ArrayStorage()); + $storageManager = new StorageManager(new ArrayStorage(),new EventDispatcher()); $storageManager->add(new Envelope(new Notification('success'))); $envelopes = $storageManager->all(); @@ -55,7 +56,7 @@ class StorageManagerTest extends TestCase public function testFlush() { - $storageManager = new StorageManager(new ArrayStorage()); + $storageManager = new StorageManager(new ArrayStorage(), new EventDispatcher()); $envelope = new Envelope( new Notification('error message', 'error'), diff --git a/src/Prime/Tests/Stubs/Producer/FakeProducer.php b/src/Prime/Tests/Stubs/Producer/FakeProducer.php deleted file mode 100644 index 51687b69..00000000 --- a/src/Prime/Tests/Stubs/Producer/FakeProducer.php +++ /dev/null @@ -1,13 +0,0 @@ -getType(), - $envelope->getMessage(), - $envelope->getTitle() - ); - } -} diff --git a/src/Prime/composer.json b/src/Prime/composer.json index b42998f6..385fbf44 100644 --- a/src/Prime/composer.json +++ b/src/Prime/composer.json @@ -27,6 +27,9 @@ "require": { "php": ">=5.3" }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0" + }, "autoload": { "psr-4": { "Flasher\\Prime\\": "", diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index cf6e9d4a..ad04c89d 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -36,7 +36,6 @@ "symfony/yaml": "^2.7|^3.0|^4.0|^5.0" }, "require-dev": { - "phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0", "twig/twig": "^1.34|^2.0|^3.0" }, "suggest": {