fix laravel adapters tests

This commit is contained in:
Khoubza Younes
2020-12-13 08:07:49 +01:00
parent ae800e996b
commit bce8eee039
3 changed files with 55 additions and 26 deletions
+1 -1
View File
@@ -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;
});
+54 -22
View File
@@ -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'));
}
}
-3
View File
@@ -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()