mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 23:17:47 +01:00
fix all tests
This commit is contained in:
@@ -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()
|
||||
{
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+7
-7
@@ -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');
|
||||
+5
-6
@@ -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()),
|
||||
));
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Flasher\\Pnotify\\Laravel\\NotifyPnotifyServiceProvider"
|
||||
"FlasherPnotifyServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src/</directory>
|
||||
<directory suffix=".php">./</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
Reference in New Issue
Block a user