From 59da4a34666b9ccf6d09d19d046f827467bd041b Mon Sep 17 00:00:00 2001 From: KHOUBZA Younes Date: Tue, 15 Dec 2020 15:17:00 +0100 Subject: [PATCH] update tests --- composer.json | 16 +++--- .../FlasherNotyExtensionTest.php | 11 ++-- .../FlasherNotyfExtensionTest.php | 11 ++-- .../FlasherPnotifyExtensionTest.php | 11 ++-- src/Prime/Factory/AbstractFactory.php | 52 ------------------- src/Prime/Factory/FactoryInterface.php | 16 ------ src/Prime/Renderer/Response/ArrayResponse.php | 14 ----- src/Prime/Renderer/Response/HtmlResponse.php | 49 ----------------- .../Renderer/Response/ResponseInterface.php | 14 ----- .../Renderer/Response/ResponseManager.php | 37 ------------- .../Response/ResponseManagerInterface.php | 19 ------- .../FlasherSweetAlertExtensionTest.php | 11 ++-- .../EventSubscriberCompilerPassTest.php | 2 +- .../Compiler/FactoryCompilerPassTest.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 1 - .../FlasherToastrExtensionTest.php | 10 ++-- 16 files changed, 50 insertions(+), 226 deletions(-) delete mode 100644 src/Prime/Factory/AbstractFactory.php delete mode 100644 src/Prime/Factory/FactoryInterface.php delete mode 100644 src/Prime/Renderer/Response/ArrayResponse.php delete mode 100644 src/Prime/Renderer/Response/HtmlResponse.php delete mode 100644 src/Prime/Renderer/Response/ResponseInterface.php delete mode 100644 src/Prime/Renderer/Response/ResponseManager.php delete mode 100644 src/Prime/Renderer/Response/ResponseManagerInterface.php diff --git a/composer.json b/composer.json index dd719028..9e68ca95 100644 --- a/composer.json +++ b/composer.json @@ -14,14 +14,11 @@ "require": { "php": ">=5.3", "ext-json": "*", - "symfony/config": "^2.7|^3.0|^4.0|^5.0", - "symfony/dependency-injection": "^2.7|^3.0|^4.0|^5.0", - "symfony/http-kernel": "^2.7|^3.0|^4.0|^5.0", - "symfony/yaml": "^2.7|^3.0|^4.0|^5.0", - "twig/twig": "^1.34|^2.0|^3.0" + "illuminate/support": "^4.0|^5.0|^6.0|^7.0|^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0" + "phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0", + "orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0" }, "autoload": { "psr-4": { @@ -31,5 +28,10 @@ "src/Prime/helpers.php" ] }, - "minimum-stability": "dev" + "minimum-stability": "dev", + "config": { + "platform": { + "php": "5.4" + } + } } diff --git a/src/Noty/Symfony/Tests/DependencyInjection/FlasherNotyExtensionTest.php b/src/Noty/Symfony/Tests/DependencyInjection/FlasherNotyExtensionTest.php index eb5d1e01..3c2f9539 100644 --- a/src/Noty/Symfony/Tests/DependencyInjection/FlasherNotyExtensionTest.php +++ b/src/Noty/Symfony/Tests/DependencyInjection/FlasherNotyExtensionTest.php @@ -31,10 +31,15 @@ class FlasherNotyExtensionTest extends TestCase $flasher = $container->getDefinition('flasher'); $calls = $flasher->getMethodCalls(); - $this->assertCount(1, $calls); + $this->assertCount(2, $calls); + $this->assertSame('addFactory', $calls[0][0]); - $this->assertSame('noty', $calls[0][1][0]); - $this->assertSame('flasher.noty', (string) $calls[0][1][1]); + $this->assertSame('template', $calls[0][1][0]); + $this->assertSame('flasher.notification_factory', (string) $calls[0][1][1]); + + $this->assertSame('addFactory', $calls[1][0]); + $this->assertSame('noty', $calls[1][1][0]); + $this->assertSame('flasher.noty', (string) $calls[1][1][1]); } public function testConfigurationInjectedIntoFlasherConfig() diff --git a/src/Notyf/Symfony/Tests/DependencyInjection/FlasherNotyfExtensionTest.php b/src/Notyf/Symfony/Tests/DependencyInjection/FlasherNotyfExtensionTest.php index 2b361699..8c5be1ed 100644 --- a/src/Notyf/Symfony/Tests/DependencyInjection/FlasherNotyfExtensionTest.php +++ b/src/Notyf/Symfony/Tests/DependencyInjection/FlasherNotyfExtensionTest.php @@ -31,10 +31,15 @@ class FlasherNotyfExtensionTest extends TestCase $flasher = $container->getDefinition('flasher'); $calls = $flasher->getMethodCalls(); - $this->assertCount(1, $calls); + $this->assertCount(2, $calls); + $this->assertSame('addFactory', $calls[0][0]); - $this->assertSame('notyf', $calls[0][1][0]); - $this->assertSame('flasher.notyf', (string) $calls[0][1][1]); + $this->assertSame('template', $calls[0][1][0]); + $this->assertSame('flasher.notification_factory', (string) $calls[0][1][1]); + + $this->assertSame('addFactory', $calls[1][0]); + $this->assertSame('notyf', $calls[1][1][0]); + $this->assertSame('flasher.notyf', (string) $calls[1][1][1]); } public function testConfigurationInjectedIntoFlasherConfig() diff --git a/src/Pnotify/Symfony/Tests/DependencyInjection/FlasherPnotifyExtensionTest.php b/src/Pnotify/Symfony/Tests/DependencyInjection/FlasherPnotifyExtensionTest.php index 9de8bc3b..16d9825f 100644 --- a/src/Pnotify/Symfony/Tests/DependencyInjection/FlasherPnotifyExtensionTest.php +++ b/src/Pnotify/Symfony/Tests/DependencyInjection/FlasherPnotifyExtensionTest.php @@ -31,10 +31,15 @@ class FlasherPnotifyExtensionTest extends TestCase $flasher = $container->getDefinition('flasher'); $calls = $flasher->getMethodCalls(); - $this->assertCount(1, $calls); + $this->assertCount(2, $calls); + $this->assertSame('addFactory', $calls[0][0]); - $this->assertSame('pnotify', $calls[0][1][0]); - $this->assertSame('flasher.pnotify', (string) $calls[0][1][1]); + $this->assertSame('template', $calls[0][1][0]); + $this->assertSame('flasher.notification_factory', (string) $calls[0][1][1]); + + $this->assertSame('addFactory', $calls[1][0]); + $this->assertSame('pnotify', $calls[1][1][0]); + $this->assertSame('flasher.pnotify', (string) $calls[1][1][1]); } public function testConfigurationInjectedIntoFlasherConfig() diff --git a/src/Prime/Factory/AbstractFactory.php b/src/Prime/Factory/AbstractFactory.php deleted file mode 100644 index 4e3fd9f7..00000000 --- a/src/Prime/Factory/AbstractFactory.php +++ /dev/null @@ -1,52 +0,0 @@ -storageManager = $storageManager; - } - - /** - * {@inheritdoc} - */ - public function createNotificationBuilder() - { - return new NotificationBuilder($this->getStorageManager(), new Notification(), 'default'); - } - - /** - * Dynamically call the default driver instance. - * - * @param string $method - * @param array $parameters - * - * @return mixed - */ - public function __call($method, array $parameters) - { - return call_user_func_array(array($this->createNotificationBuilder(), $method), $parameters); - } - - /** - * @return StorageManagerInterface - */ - public function getStorageManager() - { - return $this->storageManager; - } -} diff --git a/src/Prime/Factory/FactoryInterface.php b/src/Prime/Factory/FactoryInterface.php deleted file mode 100644 index 3942cf82..00000000 --- a/src/Prime/Factory/FactoryInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -renderScripts($response['scripts'], $context); - $notifications = json_encode($response); - - return << -if ("undefined" === typeof PHPFlasher) { - alert("[PHPFlasher] not found, please include the '/bundles/flasher/flasher.js' file"); -} else { - PHPFlasher.render({$notifications}); -} - -HTML; - } - - /** - * @param string[] $scripts - * @param array $context - * - * @return string - */ - public function renderScripts($scripts, array $context) - { - $html = ''; - - foreach ($scripts as $file) { - if (empty($context['content']) || false === strpos($context['content'], $file)) { - $html .= sprintf('', $file).PHP_EOL; - } - } - - return $html; - } -} diff --git a/src/Prime/Renderer/Response/ResponseInterface.php b/src/Prime/Renderer/Response/ResponseInterface.php deleted file mode 100644 index 9747412b..00000000 --- a/src/Prime/Renderer/Response/ResponseInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ - private $responses; - - public function __construct() - { - $this->addResponse('array', new ArrayResponse()); - $this->addResponse('html', new HtmlResponse()); - } - - /** - * @inheritDoc - */ - public function addResponse($alias, ResponseInterface $response) - { - $this->responses[$alias] = $response; - } - - /** - * @inheritDoc - */ - public function create($alias) - { - if (!isset($this->responses[$alias])) { - throw new \InvalidArgumentException(sprintf('[%s] response not supported.', $alias)); - } - - return $this->responses[$alias]; - } -} diff --git a/src/Prime/Renderer/Response/ResponseManagerInterface.php b/src/Prime/Renderer/Response/ResponseManagerInterface.php deleted file mode 100644 index 093ca768..00000000 --- a/src/Prime/Renderer/Response/ResponseManagerInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -getDefinition('flasher'); $calls = $flasher->getMethodCalls(); - $this->assertCount(1, $calls); + $this->assertCount(2, $calls); + $this->assertSame('addFactory', $calls[0][0]); - $this->assertSame('sweet_alert', $calls[0][1][0]); - $this->assertSame('flasher.sweet_alert', (string) $calls[0][1][1]); + $this->assertSame('template', $calls[0][1][0]); + $this->assertSame('flasher.notification_factory', (string) $calls[0][1][1]); + + $this->assertSame('addFactory', $calls[1][0]); + $this->assertSame('sweet_alert', $calls[1][1][0]); + $this->assertSame('flasher.sweet_alert', (string) $calls[1][1][1]); } public function testConfigurationInjectedIntoFlasherConfig() diff --git a/src/Symfony/Tests/DependencyInjection/Compiler/EventSubscriberCompilerPassTest.php b/src/Symfony/Tests/DependencyInjection/Compiler/EventSubscriberCompilerPassTest.php index d8e4c271..acc6366f 100644 --- a/src/Symfony/Tests/DependencyInjection/Compiler/EventSubscriberCompilerPassTest.php +++ b/src/Symfony/Tests/DependencyInjection/Compiler/EventSubscriberCompilerPassTest.php @@ -22,7 +22,7 @@ class EventSubscriberCompilerPassTest extends TestCase $manager = $container->getDefinition('flasher.event_dispatcher'); $calls = $manager->getMethodCalls(); - $this->assertCount(4, $calls); + $this->assertCount(5, $calls); $this->assertEquals('addSubscriber', $calls[0][0]); $this->assertEquals('test_subscriber', $calls[0][1][0]); diff --git a/src/Symfony/Tests/DependencyInjection/Compiler/FactoryCompilerPassTest.php b/src/Symfony/Tests/DependencyInjection/Compiler/FactoryCompilerPassTest.php index df89af1a..f054e53e 100644 --- a/src/Symfony/Tests/DependencyInjection/Compiler/FactoryCompilerPassTest.php +++ b/src/Symfony/Tests/DependencyInjection/Compiler/FactoryCompilerPassTest.php @@ -22,7 +22,7 @@ class FactoryCompilerPassTest extends TestCase $manager = $container->getDefinition('flasher'); $calls = $manager->getMethodCalls(); - $this->assertCount(1, $calls); + $this->assertCount(2, $calls); $this->assertEquals('addFactory', $calls[0][0]); $this->assertEquals('test_flasher', $calls[0][1][0]); } diff --git a/src/Symfony/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Tests/DependencyInjection/ConfigurationTest.php index 5217105f..ca5ecba5 100644 --- a/src/Symfony/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Tests/DependencyInjection/ConfigurationTest.php @@ -13,7 +13,6 @@ class ConfigurationTest extends TestCase $config = $this->process(array()); $expected = array( - 'default' => 'toastr', 'scripts' => array( '/bundles/flasher/flasher.js', ), diff --git a/src/Toastr/Symfony/Tests/DependencyInjection/FlasherToastrExtensionTest.php b/src/Toastr/Symfony/Tests/DependencyInjection/FlasherToastrExtensionTest.php index ebf6bb72..13167e76 100644 --- a/src/Toastr/Symfony/Tests/DependencyInjection/FlasherToastrExtensionTest.php +++ b/src/Toastr/Symfony/Tests/DependencyInjection/FlasherToastrExtensionTest.php @@ -31,10 +31,14 @@ class FlasherToastrExtensionTest extends TestCase $flasher = $container->getDefinition('flasher'); $calls = $flasher->getMethodCalls(); - $this->assertCount(1, $calls); + $this->assertCount(2, $calls); $this->assertSame('addFactory', $calls[0][0]); - $this->assertSame('toastr', $calls[0][1][0]); - $this->assertSame('flasher.toastr', (string) $calls[0][1][1]); + $this->assertSame('template', $calls[0][1][0]); + $this->assertSame('flasher.notification_factory', (string) $calls[0][1][1]); + + $this->assertSame('addFactory', $calls[1][0]); + $this->assertSame('toastr', $calls[1][1][0]); + $this->assertSame('flasher.toastr', (string) $calls[1][1][1]); } public function testConfigurationInjectedIntoFlasherConfig()