add transtion tests

This commit is contained in:
KHOUBZA Younes
2022-05-27 15:13:04 +01:00
parent 50050c6865
commit ac0a0953fd
6 changed files with 78 additions and 16 deletions
+2 -2
View File
@@ -42,8 +42,8 @@ jobs:
- name: Install dependencies
run: |
composer remove friendsofphp/php-cs-fixer laravel/laravel livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer remove friendsofphp/php-cs-fixer laravel/framework livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --testdox --configuration=phpunit-laravel.xml
run: vendor/bin/phpunit --configuration=phpunit-laravel.xml
+2 -2
View File
@@ -52,9 +52,9 @@ jobs:
- name: Install dependencies
run: |
composer remove friendsofphp/php-cs-fixer laravel/laravel livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer remove friendsofphp/php-cs-fixer laravel/framework livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer config extra.symfony.require "${{ matrix.symfony }}"
composer require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --testdox --configuration=phpunit-symfony.xml
run: vendor/bin/phpunit --configuration=phpunit-symfony.xml
+10 -11
View File
@@ -13,19 +13,9 @@
],
"require": {
"php": ">=5.3",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.8",
"laravel/laravel": "^9.1",
"livewire/livewire": "^2.10",
"orchestra/testbench": "^7.5",
"phpstan/phpstan": "^1.6",
"phpunit/phpunit": "^9.5",
"symfony/symfony": "^6.1"
},
"autoload": {
"files": [
"src/Cli/Laravel/notify.php",
@@ -114,5 +104,14 @@
"sort-packages": true
},
"minimum-stability": "stable",
"prefer-stable": true
"prefer-stable": true,
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.8",
"laravel/framework": "^9.14",
"livewire/livewire": "^2.10",
"orchestra/testbench": "^7.5",
"phpstan/phpstan": "^1.7",
"phpunit/phpunit": "^9.5",
"symfony/symfony": "^6.1"
}
}
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
cacheResult="false"
stopOnFailure="true"
>
<testsuites>
<testsuite name="flasher">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
+4 -1
View File
@@ -18,7 +18,10 @@ final class Translator implements TranslatorInterface
*/
private $translator;
public function __construct(SymfonyTranslatorInterface $translator)
/**
* @param SymfonyTranslatorInterface $translator
*/
public function __construct($translator)
{
$this->translator = $translator;
}
+38
View File
@@ -0,0 +1,38 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Tests\Symfony;
use Flasher\Symfony\Translation\Translator;
use Flasher\Tests\Prime\TestCase;
class TranslatorTest extends TestCase
{
public function testInitialState()
{
$translator = $this->getTranslator();
$this->assertEquals('en', $translator->getLocale());
}
/**
* @return Translator
*/
private function getTranslator()
{
$messageFormatter = null;
if (class_exists('Symfony\Component\Translation\Formatter\MessageFormatter')) {
$messageFormatter = new \Symfony\Component\Translation\Formatter\MessageFormatter();
} elseif (class_exists('Symfony\Component\Translation\MessageSelector')) {
$messageFormatter = new \Symfony\Component\Translation\MessageSelector();
}
$symfonyTranslator = new \Symfony\Component\Translation\Translator('en', $messageFormatter);
return new Translator($symfonyTranslator);
}
}