Compare commits

..

6 Commits

Author SHA1 Message Date
Khoubza Younes 53000d94f3 fix symfony version compare 2021-10-04 02:17:51 +01:00
Khoubza Younes 28817f081c update composer dependencies 2021-10-04 01:55:54 +01:00
Khoubza Younes c039a72b4c move tests to tests files 2021-10-03 21:39:04 +01:00
Khoubza Younes d67a2374f3 use php configuration for all bundles 2021-09-20 05:28:16 +01:00
Khoubza Younes b54b756be1 add Symfony 6 support 2021-09-19 16:12:41 +01:00
Khoubza Younes 376749c2e6 upgrade flasher dependencies 2021-09-08 08:28:21 +01:00
10 changed files with 42 additions and 344 deletions
-103
View File
@@ -1,103 +0,0 @@
name: Running tests
on:
push:
pull_request:
schedule:
- cron: '* * * * *'
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
symfony: [5.2.*, 5.1.*, 5.0.*, 4.4.*, 4.3.*, 4.2.*, 4.1.*, 4.0.*, 3.4.*, 3.3.*, 3.2.*, 3.1.*, 3.0.*, 2.8.*, 2.7.*]
include:
- symfony: 5.2.*
php: 7.2
phpunit: 8.3.*
- symfony: 5.1.*
php: 7.2
phpunit: 8.3.*
- symfony: 5.0.*
php: 7.2
phpunit: 8.3.*
- symfony: 4.4.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.3.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.2.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.1.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.0.*
php: 7.1
phpunit: 7.0.*
- symfony: 3.4.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.3.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.2.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.1.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.0.*
php: 5.5
phpunit: 4.8.36
- symfony: 2.8.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.7.*
php: 5.3
phpunit: 4.8.36
name: S${{ matrix.symfony }} - P${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-symfony-${{ matrix.symfony }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Install dependencies
run: |
composer require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --no-update
composer config extra.symfony.require "${{ matrix.symfony }}"
composer update --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
@@ -2,17 +2,21 @@
namespace Flasher\Toastr\Symfony\DependencyInjection;
use Flasher\Symfony\DependencyInjection\Extension;
use Flasher\Symfony\DependencyInjection\FlasherExtensionInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
final class FlasherToastrExtension extends Extension
final class FlasherToastrExtension extends Extension implements FlasherExtensionInterface
{
protected function getConfigFileLocator()
public function load(array $configs, ContainerBuilder $container)
{
return new FileLocator(__DIR__ . '/../Resources/config');
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('config.php');
}
protected function getConfigClass()
public function getConfigurationClass()
{
return new Configuration();
}
+10 -3
View File
@@ -2,12 +2,19 @@
namespace Flasher\Toastr\Symfony;
use Flasher\Symfony\DependencyInjection\Compiler\ResourceCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Flasher\Symfony\Bridge\FlasherBundle;
use Flasher\Toastr\Symfony\DependencyInjection\FlasherToastrExtension;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class FlasherToastrSymfonyBundle extends Bundle
class FlasherToastrSymfonyBundle extends FlasherBundle
{
public function getContainerExtension()
protected function flasherBuild(ContainerBuilder $container)
{
$container->addCompilerPass(new ResourceCompilerPass($this->getFlasherContainerExtension()));
}
protected function getFlasherContainerExtension()
{
return new FlasherToastrExtension();
}
+21
View File
@@ -0,0 +1,21 @@
<?php
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Flasher\Symfony\Bridge\Bridge;
if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
$definition = new ChildDefinition('flasher.notification_factory');
} else {
$definition = new DefinitionDecorator('flasher.notification_factory');
}
$definition
->setClass('Flasher\Toastr\Prime\ToastrFactory')
->addTag('flasher.factory', array('alias' => 'toastr'));
$container->setDefinition('flasher.toastr', $definition);
if (Bridge::canLoadAliases()) {
$container->setAlias('Flasher\Toastr\Prime\ToastrFactory', 'flasher.toastr');
}
-8
View File
@@ -1,8 +0,0 @@
services:
flasher.toastr:
parent: 'flasher.notification_factory'
class: Flasher\Toastr\Prime\ToastrFactory
tags:
- { name: 'flasher.factory', alias: 'toastr' }
Flasher\Toastr\Prime\ToastrFactory: '@flasher.toastr'
@@ -1,43 +0,0 @@
<?php
namespace Flasher\Toastr\Symfony\Tests\DependencyInjection;
use Flasher\Prime\Tests\TestCase;
use Flasher\Toastr\Symfony\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\Processor;
class ConfigurationTest extends TestCase
{
public function testDefaultConfig()
{
$config = $this->process(array());
$expected = array(
'scripts' => array(
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js',
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@0.1.3/dist/flasher-toastr.min.js',
),
'styles' => array(),
'options' => array(
'progressBar' => true,
'timeOut' => 5000,
),
);
$this->assertEquals($expected, $config);
}
/**
* Processes an array of configurations and returns a compiled version.
*
* @param array $configs An array of raw configurations
*
* @return array A normalized array
*/
private function process($configs)
{
$processor = new Processor();
return $processor->processConfiguration(new Configuration(), $configs);
}
}
@@ -1,72 +0,0 @@
<?php
namespace Flasher\Toastr\Symfony\Tests\DependencyInjection;
use Flasher\Prime\Tests\TestCase;
use Flasher\Symfony\DependencyInjection\FlasherExtension;
use Flasher\Symfony\FlasherSymfonyBundle;
use Flasher\Toastr\Symfony\DependencyInjection\FlasherToastrExtension;
use Flasher\Toastr\Symfony\FlasherToastrSymfonyBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FlasherToastrExtensionTest extends TestCase
{
public function testContainerContainFlasherServices()
{
$container = $this->getRawContainer();
$container->loadFromExtension('flasher', array());
$container->loadFromExtension('flasher_toastr', array());
$container->compile();
$this->assertTrue($container->has('flasher.toastr'));
}
public function testCreateInstanceOfToastrAdapter()
{
$container = $this->getRawContainer();
$container->loadFromExtension('flasher');
$container->loadFromExtension('flasher_toastr');
$container->compile();
$flasher = $container->getDefinition('flasher');
$calls = $flasher->getMethodCalls();
$this->assertCount(2, $calls);
$this->assertEquals('addFactory', $calls[0][0]);
$this->assertEquals('template', $calls[0][1][0]);
$this->assertEquals('flasher.notification_factory', (string) $calls[0][1][1]);
$this->assertEquals('addFactory', $calls[1][0]);
$this->assertEquals('toastr', $calls[1][1][0]);
$this->assertEquals('flasher.toastr', (string) $calls[1][1][1]);
}
private function getRawContainer()
{
$container = new ContainerBuilder();
$container->registerExtension(new FlasherExtension());
$flasherBundle = new FlasherSymfonyBundle();
$flasherBundle->build($container);
$container->registerExtension(new FlasherToastrExtension());
$adapterBundle = new FlasherToastrSymfonyBundle();
$adapterBundle->build($container);
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->getCompilerPassConfig()->setAfterRemovingPasses(array());
return $container;
}
private function getContainer()
{
$container = $this->getRawContainer();
$container->loadFromExtension('flasher', array());
$container->loadFromExtension('flasher_toastr', array());
$container->compile();
return $container;
}
}
+2 -13
View File
@@ -29,23 +29,12 @@
"license": "MIT",
"require": {
"php": ">=5.3",
"php-flasher/flasher-symfony": "^0.4.11",
"php-flasher/flasher-toastr": "^0.4.11"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0"
"php-flasher/flasher-symfony": "^0.6.2",
"php-flasher/flasher-toastr": "^0.6.2"
},
"autoload": {
"psr-4": {
"Flasher\\Toastr\\Symfony\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"autoload-dev": {
"psr-4": {
"Flasher\\Toastr\\Symfony\\Tests\\": "Tests/"
}
},
"config": {
-75
View File
@@ -1,75 +0,0 @@
{
"name": "php-flasher/flasher-toastr-symfony",
"type": "symfony-bundle",
"description": "PHP Flasher Symfony adapter for Toastr",
"keywords": [
"yoeunes",
"notify",
"php",
"laravel",
"symfony",
"Lumen",
"notifications",
"messages",
"alerts",
"pnotify",
"toastr ",
"bundle",
"flex"
],
"homepage": "https://php-flasher.github.io/",
"authors": [
{
"name": "Younes Khoubza",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"role": "Developer"
}
],
"license": "MIT",
"repositories": [
{
"type": "path",
"url": "../../Symfony",
"options": {
"symlink": true
}
},
{
"type": "path",
"url": "../Prime",
"options": {
"symlink": true
}
}
],
"require": {
"php": ">=5.3",
"php-flasher/flasher-symfony": "@dev",
"php-flasher/flasher-toastr": "@dev"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0"
},
"autoload": {
"psr-4": {
"Flasher\\Toastr\\Symfony\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"autoload-dev": {
"psr-4": {
"Flasher\\Toastr\\Symfony\\Tests\\": "Tests/"
}
},
"config": {
"sort-packages": true,
"platform": {
"php": "5.3.10"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true">
<testsuites>
<testsuite name="Flasher Test Suite">
<directory>Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./</directory>
</whitelist>
</filter>
</phpunit>