From cc0c0b5f500f6f157eed0bc6543fdbdf1dba824c Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Sun, 6 Dec 2020 19:33:03 +0100 Subject: [PATCH] fix all tests --- ...r.php => FlasherPnotifyServiceProvider.php | 7 ++--- ServiceProvider/Providers/Laravel.php | 28 +++++++++---------- ServiceProvider/Providers/Laravel4.php | 12 ++++---- ServiceProvider/Providers/Lumen.php | 10 +++---- .../Providers/ServiceProviderInterface.php | 4 +-- ServiceProvider/ServiceProviderManager.php | 4 +-- ... => FlasherPnotifyServiceProviderTest.php} | 14 +++++----- Tests/TestCase.php | 11 ++++---- composer.json | 2 +- phpunit.xml.dist | 2 +- 10 files changed, 46 insertions(+), 48 deletions(-) rename NotifyPnotifyServiceProvider.php => FlasherPnotifyServiceProvider.php (85%) rename Tests/{NotifyPnotifyServiceProviderTest.php => FlasherPnotifyServiceProviderTest.php} (69%) diff --git a/NotifyPnotifyServiceProvider.php b/FlasherPnotifyServiceProvider.php similarity index 85% rename from NotifyPnotifyServiceProvider.php rename to FlasherPnotifyServiceProvider.php index c752ec9f..b8aea7df 100644 --- a/NotifyPnotifyServiceProvider.php +++ b/FlasherPnotifyServiceProvider.php @@ -2,11 +2,11 @@ namespace Flasher\Pnotify\Laravel; -use Illuminate\Contracts\Support\DeferrableProvider; +use Illuminate\Container\Container; use Illuminate\Support\ServiceProvider; use Flasher\Pnotify\Laravel\ServiceProvider\ServiceProviderManager; -class NotifyPnotifyServiceProvider extends ServiceProvider +class FlasherPnotifyServiceProvider extends ServiceProvider { public function boot() { @@ -31,14 +31,13 @@ class NotifyPnotifyServiceProvider extends ServiceProvider public function provides() { return array( - 'flasher.factory', 'flasher.factory.pnotify', 'flasher.renderer.pnotify', ); } /** - * @return \Illuminate\Container\Container + * @return Container */ public function getApplication() { diff --git a/ServiceProvider/Providers/Laravel.php b/ServiceProvider/Providers/Laravel.php index 4db2f0c4..c00994a9 100644 --- a/ServiceProvider/Providers/Laravel.php +++ b/ServiceProvider/Providers/Laravel.php @@ -2,9 +2,9 @@ namespace Flasher\Pnotify\Laravel\ServiceProvider\Providers; -use Flasher\Pnotify\LaravelFlasher\PrimePnotifyServiceProvider; -use Flasher\PFlasher\Prime\TestsProducer\PnotifyProducer; -use Flasher\PFlasher\Prime\Renderer\PnotifyRenderer; +use Flasher\PFlasher\Prime\PnotifyRenderer; +use Flasher\Pnotify\Laravel\FlasherPnotifyServiceProvider; +use Flasher\Pnotify\Prime\PnotifyFactory; use Flasher\Prime\Flasher; use Flasher\Prime\Renderer\RendererManager; use Illuminate\Container\Container; @@ -24,19 +24,19 @@ class Laravel implements ServiceProviderInterface return $this->app instanceof Application; } - public function publishConfig(NotifyPnotifyServiceProvider $provider) + public function publishConfig(FlasherPnotifyServiceProvider $provider) { - $source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw; + $source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw; - $provider->publishes(array($source => config_path('notify_pnotify.php')), 'config'); + $provider->publishes(array($source => config_path('flasher_pnotify.php')), 'config'); - $provider->mergeConfigFrom($source, 'notify_pnotify'); + $provider->mergeConfigFrom($source, 'flasher_pnotify'); } public function registerNotifyPnotifyServices() { $this->app->singleton('flasher.factory.pnotify', function (Container $app) { - return new PnotifyProducer($app['flasher.storage'], $app['flasher.middleware']); + return new PnotifyFactory($app['flasher.event_dispatcher']); }); $this->app->singleton('flasher.renderer.pnotify', function (Container $app) { @@ -46,14 +46,14 @@ class Laravel implements ServiceProviderInterface $this->app->alias('flasher.factory.pnotify', 'Flasher\PFlasher\Prime\TestsProducer\PnotifyProducer'); $this->app->alias('flasher.renderer.pnotify', 'Flasher\PFlasher\Prime\Renderer\PnotifyRenderer'); - $this->app->extend('flasher.factory', function (Flasher $manager, Container $app) { - $manager->addDriver('pnotify', $app['flasher.factory.pnotify']); + $this->app->extend('flasher', function (Flasher $manager, Container $app) { + $manager->addDriver($app['flasher.factory.pnotify']); return $manager; }); $this->app->extend('flasher.renderer', function (RendererManager $manager, Container $app) { - $manager->addDriver('pnotify', $app['flasher.renderer.pnotify']); + $manager->addDriver($app['flasher.renderer.pnotify']); return $manager; }); @@ -61,10 +61,10 @@ class Laravel implements ServiceProviderInterface public function mergeConfigFromPnotify() { - $notifyConfig = $this->app['config']->get('flasher.adapters.pnotify', array()); + $flasherConfig = $this->app['config']->get('flasher.adapters.pnotify', array()); - $pnotifyConfig = $this->app['config']->get('notify_pnotify', array()); + $pnotifyConfig = $this->app['config']->get('flasher_pnotify', array()); - $this->app['config']->set('flasher.adapters.pnotify', array_merge($pnotifyConfig, $notifyConfig)); + $this->app['config']->set('flasher.adapters.pnotify', array_merge($pnotifyConfig, $flasherConfig)); } } diff --git a/ServiceProvider/Providers/Laravel4.php b/ServiceProvider/Providers/Laravel4.php index c26cb472..55528de2 100644 --- a/ServiceProvider/Providers/Laravel4.php +++ b/ServiceProvider/Providers/Laravel4.php @@ -2,8 +2,8 @@ namespace Flasher\Pnotify\Laravel\ServiceProvider\Providers; +use Flasher\Pnotify\Laravel\FlasherPnotifyServiceProvider; use Illuminate\Foundation\Application; -use Flasher\Pnotify\LaravelFlasher\PrimePnotifyServiceProvider; final class Laravel4 extends Laravel { @@ -12,17 +12,17 @@ final class Laravel4 extends Laravel return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.'); } - public function publishConfig(NotifyPnotifyServiceProvider $provider) + public function publishConfig(FlasherPnotifyServiceProvider $provider) { - $provider->package('php-flasher/flasher-laravel-pnotify', 'notify_pnotify', __DIR__.'/../../../resources'); + $provider->package('php-flasher/flasher-laravel-pnotify', 'notify_pnotify', __DIR__.'/../../Resources'); } public function mergeConfigFromPnotify() { - $notifyConfig = $this->app['config']->get('notify::config.adapters.pnotify', array()); + $flasherConfig = $this->app['config']->get('flasher::config.adapters.pnotify', array()); - $pnotifyConfig = $this->app['config']->get('notify_pnotify::config', array()); + $pnotifyConfig = $this->app['config']->get('flasher_pnotify::config', array()); - $this->app['config']->set('notify::config.adapters.pnotify', array_merge($pnotifyConfig, $notifyConfig)); + $this->app['config']->set('flasher::config.adapters.pnotify', array_merge($pnotifyConfig, $flasherConfig)); } } diff --git a/ServiceProvider/Providers/Lumen.php b/ServiceProvider/Providers/Lumen.php index 36747c71..a7740778 100644 --- a/ServiceProvider/Providers/Lumen.php +++ b/ServiceProvider/Providers/Lumen.php @@ -2,8 +2,8 @@ namespace Flasher\Pnotify\Laravel\ServiceProvider\Providers; +use Flasher\Pnotify\Laravel\FlasherPnotifyServiceProvider; use Laravel\Lumen\Application; -use Flasher\Pnotify\LaravelFlasher\PrimePnotifyServiceProvider; final class Lumen extends Laravel { @@ -12,12 +12,12 @@ final class Lumen extends Laravel return $this->app instanceof Application; } - public function publishConfig(NotifyPnotifyServiceProvider $provider) + public function publishConfig(FlasherPnotifyServiceProvider $provider) { - $source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw; + $source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw; - $this->app->configure('notify_pnotify'); + $this->app->configure('flasher_pnotify'); - $provider->mergeConfigFrom($source, 'notify_pnotify'); + $provider->mergeConfigFrom($source, 'flasher_pnotify'); } } diff --git a/ServiceProvider/Providers/ServiceProviderInterface.php b/ServiceProvider/Providers/ServiceProviderInterface.php index c1696ac9..5eff948a 100644 --- a/ServiceProvider/Providers/ServiceProviderInterface.php +++ b/ServiceProvider/Providers/ServiceProviderInterface.php @@ -2,13 +2,13 @@ namespace Flasher\Pnotify\Laravel\ServiceProvider\Providers; -use Flasher\Pnotify\LaravelFlasher\PrimePnotifyServiceProvider; +use Flasher\Pnotify\Laravel\FlasherPnotifyServiceProvider; interface ServiceProviderInterface { public function shouldBeUsed(); - public function publishConfig(NotifyPnotifyServiceProvider $provider); + public function publishConfig(FlasherPnotifyServiceProvider $provider); public function registerNotifyPnotifyServices(); diff --git a/ServiceProvider/ServiceProviderManager.php b/ServiceProvider/ServiceProviderManager.php index b220009e..6ee59e8a 100644 --- a/ServiceProvider/ServiceProviderManager.php +++ b/ServiceProvider/ServiceProviderManager.php @@ -2,7 +2,7 @@ namespace Flasher\Pnotify\Laravel\ServiceProvider; -use Flasher\Pnotify\LaravelFlasher\PrimePnotifyServiceProvider; +use Flasher\Pnotify\Laravel\FlasherPnotifyServiceProvider; use Flasher\Pnotify\Laravel\ServiceProvider\Providers\ServiceProviderInterface; final class ServiceProviderManager @@ -20,7 +20,7 @@ final class ServiceProviderManager private $notifyServiceProvider; - public function __construct(NotifyPnotifyServiceProvider $notifyServiceProvider) + public function __construct(FlasherPnotifyServiceProvider $notifyServiceProvider) { $this->notifyServiceProvider = $notifyServiceProvider; } diff --git a/Tests/NotifyPnotifyServiceProviderTest.php b/Tests/FlasherPnotifyServiceProviderTest.php similarity index 69% rename from Tests/NotifyPnotifyServiceProviderTest.php rename to Tests/FlasherPnotifyServiceProviderTest.php index 46e987e1..6c086cb6 100644 --- a/Tests/NotifyPnotifyServiceProviderTest.php +++ b/Tests/FlasherPnotifyServiceProviderTest.php @@ -2,31 +2,31 @@ namespace Flasher\Pnotify\Laravel\Tests; -class NotifyPnotifyServiceProviderTest extends TestCase +class FlasherPnotifyServiceProviderTest extends TestCase { public function testContainerContainNotifyServices() { - $this->assertTrue($this->app->bound('flasher.factory')); + $this->assertTrue($this->app->bound('flasher')); $this->assertTrue($this->app->bound('flasher.factory.pnotify')); } public function testNotifyFactoryIsAddedToExtensionsArray() { - $manager = $this->app->make('flasher.factory'); + $flasher = $this->app->make('flasher'); - $reflection = new \ReflectionClass($manager); + $reflection = new \ReflectionClass($flasher); $property = $reflection->getProperty('drivers'); $property->setAccessible(true); - $extensions = $property->getValue($manager); + $extensions = $property->getValue($flasher); $this->assertCount(1, $extensions); - $this->assertInstanceOf('Flasher\Prime\FlasherInterface', $extensions['pnotify']); + $this->assertInstanceOf('Flasher\Prime\Factory\FlasherFactoryInterface', $extensions[0]); } public function testConfigPnotifyInjectedInGlobalNotifyConfig() { - $manager = $this->app->make('flasher.factory'); + $manager = $this->app->make('flasher'); $reflection = new \ReflectionClass($manager); $property = $reflection->getProperty('config'); diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 577be22c..6151be5f 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -12,28 +12,27 @@ use Illuminate\Config\Repository as Config; class TestCase extends Orchestra { /** - * @param \Illuminate\Foundation\Application $app + * @param Application $app * * @return array */ protected function getPackageProviders($app = null) { return array( - 'Flasher\LaravelFlasher\PrimeServiceProvider', - 'Flasher\Pnotify\LaravelFlasher\PrimePnotifyServiceProvider', + 'Flasher\Laravel\FlasherServiceProvider', + 'Flasher\Pnotify\Laravel\FlasherPnotifyServiceProvider', ); } /** - * @param \Illuminate\Foundation\Application $app + * @param Application $app */ protected function getEnvironmentSetUp($app) { $separator = $this->isLaravel4() ? '::config' : ''; $app['config']->set('session'.$separator.'.driver', 'array'); - $app['config']->set('notify'.$separator.'.stamps_middlewares', array()); - $app['config']->set('notify'.$separator.'.adapters', array( + $app['config']->set('flasher'.$separator.'.adapters', array( 'pnotify' => array('scripts' => array('jquery.js'), 'styles' => array('styles.css'), 'options' => array()), )); } diff --git a/composer.json b/composer.json index a6e167c8..52b1ecb5 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "extra": { "laravel": { "providers": [ - "Flasher\\Pnotify\\Laravel\\NotifyPnotifyServiceProvider" + "FlasherPnotifyServiceProvider" ] } }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2621c486..1e1af721 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,7 @@ - src/ + ./