You've already forked php-flasher
mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-04-05 12:32:55 +01:00
fix laravel adapters tests
This commit is contained in:
@@ -40,7 +40,7 @@ class Laravel implements ServiceProviderInterface
|
||||
$this->app->alias('flasher.pnotify', 'Flasher\Pnotify\Prime\PnotifyFactory');
|
||||
|
||||
$this->app->extend('flasher', function (Flasher $manager, Container $app) {
|
||||
$manager->addFactory('pnotify', $app['flasher.factory.pnotify']);
|
||||
$manager->addFactory('pnotify', $app['flasher.pnotify']);
|
||||
|
||||
return $manager;
|
||||
});
|
||||
|
||||
@@ -6,38 +6,70 @@ class FlasherPnotifyServiceProviderTest extends TestCase
|
||||
{
|
||||
public function testContainerContainNotifyServices()
|
||||
{
|
||||
$this->assertTrue($this->app->bound('flasher'));
|
||||
$this->assertTrue($this->app->bound('flasher.factory.pnotify'));
|
||||
$this->assertTrue($this->app->bound('flasher.pnotify'));
|
||||
$this->assertInstanceOf('Flasher\Pnotify\Prime\PnotifyFactory', $this->app->make('flasher.pnotify'));
|
||||
}
|
||||
|
||||
public function testNotifyFactoryIsAddedToExtensionsArray()
|
||||
{
|
||||
$flasher = $this->app->make('flasher');
|
||||
$adapter = $flasher->create('pnotify');
|
||||
|
||||
$reflection = new \ReflectionClass($flasher);
|
||||
$property = $reflection->getProperty('drivers');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$extensions = $property->getValue($flasher);
|
||||
|
||||
$this->assertCount(1, $extensions);
|
||||
$this->assertInstanceOf('Flasher\Prime\Factory\FactoryInterface', $extensions[0]);
|
||||
$this->assertInstanceOf('Flasher\Pnotify\Prime\PnotifyFactory', $adapter);
|
||||
}
|
||||
|
||||
public function testConfigPnotifyInjectedInGlobalNotifyConfig()
|
||||
public function testConfigNotyInjectedInGlobalNotifyConfig()
|
||||
{
|
||||
$manager = $this->app->make('flasher');
|
||||
$config = $this->app->make('flasher.config');
|
||||
|
||||
$reflection = new \ReflectionClass($manager);
|
||||
$property = $reflection->getProperty('config');
|
||||
$property->setAccessible(true);
|
||||
$expected = array(
|
||||
'pnotify' => array(
|
||||
'scripts' => array(
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.js',
|
||||
),
|
||||
'styles' => array(
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.css',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.brighttheme.css',
|
||||
),
|
||||
'options' => array(
|
||||
'type' => 'notice',
|
||||
'title' => false,
|
||||
'titleTrusted' => false,
|
||||
'text' => false,
|
||||
'textTrusted' => false,
|
||||
'styling' => 'brighttheme',
|
||||
'icons' => 'brighttheme',
|
||||
'mode' => 'no-preference',
|
||||
'addClass' => '',
|
||||
'addModalClass' => '',
|
||||
'addModelessClass' => '',
|
||||
'autoOpen' => true,
|
||||
'width' => '360px',
|
||||
'minHeight' => '16px',
|
||||
'maxTextHeight' => '200px',
|
||||
'icon' => true,
|
||||
'animation' => 'fade',
|
||||
'animateSpeed' => 'normal',
|
||||
'shadow' => true,
|
||||
'hide' => true,
|
||||
'delay' => 5000,
|
||||
'mouseReset' => true,
|
||||
'closer' => true,
|
||||
'closerHover' => true,
|
||||
'sticker' => true,
|
||||
'stickerHover' => true,
|
||||
'labels' => array(
|
||||
'close' => 'Close',
|
||||
'stick' => 'Pin',
|
||||
'unstick' => 'Unpin',
|
||||
),
|
||||
'remove' => true,
|
||||
'destroy' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$config = $property->getValue($manager);
|
||||
|
||||
$this->assertArrayHasKey('pnotify', $config->get('adapters'));
|
||||
|
||||
$this->assertEquals(array(
|
||||
'pnotify' => array('scripts' => array('jquery.js'), 'styles' => array('styles.css'), 'options' => array()),
|
||||
), $config->get('adapters'));
|
||||
$this->assertEquals($expected, $config->get('adapters'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,6 @@ class TestCase extends Orchestra
|
||||
$separator = $this->isLaravel4() ? '::config' : '';
|
||||
|
||||
$app['config']->set('session'.$separator.'.driver', 'array');
|
||||
$app['config']->set('flasher'.$separator.'.adapters', array(
|
||||
'pnotify' => array('scripts' => array('jquery.js'), 'styles' => array('styles.css'), 'options' => array()),
|
||||
));
|
||||
}
|
||||
|
||||
private function isLaravel4()
|
||||
|
||||
Reference in New Issue
Block a user