diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 282131b..da236c8 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -22,7 +22,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 3 + runs: 12 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index 4915c53..cc4af1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: php +sudo: false + php: - 5.5.9 - 5.5 @@ -7,11 +9,14 @@ php: - 7.0 - hhvm -sudo: false +env: + - TESTBENCH_VERSION=3.0.* + - TESTBENCH_VERSION=3.1.* + - TESTBENCH_VERSION=3.2.* before_script: - travis_retry composer self-update - - travis_retry composer install --prefer-source --no-interaction + - travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench:${TESTBENCH_VERSION}" script: - composer validate @@ -19,5 +24,5 @@ script: - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover after_script: - - if [ "$TRAVIS_PHP_VERSION" != "7.0" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" != "7.0" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/LICENSE.md b/LICENSE.md index fe39b39..7741bae 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 ARCANEDEV - LaravelLang +Copyright (c) 2015-2016 | ARCANEDEV - LaravelLang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index da7845d..391ee2b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Packagist Downloads][badge_downloads]](https://packagist.org/packages/arcanedev/laravel-lang) [badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-lang.svg?style=flat-square -[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.0%7C5.1-orange.svg?style=flat-square +[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.x-orange.svg?style=flat-square [badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelLang.svg?style=flat-square [badge_hhvm]: https://img.shields.io/hhvm/arcanedev/laravel-lang.svg?style=flat-square @@ -27,7 +27,7 @@ *By [ARCANEDEV©](http://www.arcanedev.net/)* -Translations manager and checker for Laravel 5 based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang) translations. +Translations manager and checker for Laravel v5 based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang) translations. Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelLang/releases), [license](LICENSE.md), and [contribution guidelines](CONTRIBUTING.md). @@ -36,6 +36,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelLang/r * Easy setup & configuration. * Missing translations Checker. * Translations Publisher. + * Laravel 5.0, 5.1 & 5.2 are supported. * Well documented & IDE Friendly. * Well tested with maximum code quality. * Made with :heart: & :coffee:. @@ -49,14 +50,8 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelLang/r ## TODO - - [ ] Test Laravel 5.0 support. - [ ] Adding LaravelLang API. -## DONE - - - [x] Laravel 5.1 supported. - - [x] Complete the documentation. - ## Contribution Any ideas are welcome. Feel free to submit any issues or pull requests, please check the [contribution guidelines](CONTRIBUTING.md). diff --git a/composer.json b/composer.json index c86e03a..110aea3 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ { "name": "ARCANEDEV", "email": "arcanedev.maroc@gmail.com", - "homepage": "https://github.com/ARCANEDEV", + "homepage": "https://github.com/arcanedev-maroc", "role": "Developer" } ], @@ -21,8 +21,7 @@ "caouecs/laravel4-lang": "~2.0" }, "require-dev": { - "orchestra/testbench": "~3.1", - "phpunit/phpcov": "~2.0", + "phpunit/phpcov": "~2.0|~3.0", "phpunit/phpunit": "~4.0|~5.0" }, "autoload": { @@ -35,9 +34,12 @@ "Arcanedev\\LaravelLang\\Tests\\": "tests/" } }, + "scripts": { + "testbench": "composer require --dev \"orchestra/testbench=~3.0\"" + }, "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } diff --git a/src/Commands/CheckCommand.php b/src/Commands/CheckCommand.php index b36c2fb..d1caa6f 100644 --- a/src/Commands/CheckCommand.php +++ b/src/Commands/CheckCommand.php @@ -54,10 +54,11 @@ class CheckCommand extends Command */ public function __construct(TransChecker $checker) { - parent::__construct(); - + $this->name = $this->signature; $this->checker = $checker; $this->count = 0; + + parent::__construct(); } /* ------------------------------------------------------------------------------------------------ diff --git a/src/Commands/PublishCommand.php b/src/Commands/PublishCommand.php index 76e56ad..5d92d92 100644 --- a/src/Commands/PublishCommand.php +++ b/src/Commands/PublishCommand.php @@ -3,6 +3,8 @@ use Arcanedev\LaravelLang\Bases\Command; use Arcanedev\LaravelLang\Contracts\TransPublisher; use Arcanedev\LaravelLang\Exceptions\LangPublishException; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; /** * Class PublishCommand @@ -50,9 +52,10 @@ class PublishCommand extends Command */ public function __construct(TransPublisher $publisher) { - parent::__construct(); - $this->publisher = $publisher; + $this->name = 'trans:publish'; + + parent::__construct(); } /* ------------------------------------------------------------------------------------------------ @@ -100,4 +103,28 @@ private function publish($locale, $force) $this->error($e->getMessage()); } } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['locale', InputArgument::REQUIRED, 'The language to publish the translations.'], + ]; + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['force', 'f', InputOption::VALUE_OPTIONAL, 'Force to override the translations', false], + ]; + } } diff --git a/src/LaravelLangServiceProvider.php b/src/LaravelLangServiceProvider.php index 0ee364e..74ad2c4 100644 --- a/src/LaravelLangServiceProvider.php +++ b/src/LaravelLangServiceProvider.php @@ -47,22 +47,8 @@ public function getBasePath() | Main Functions | ------------------------------------------------------------------------------------------------ */ - /** - * Boot the service provider. - */ - public function boot() - { - parent::boot(); - - $this->publishes([ - $this->getConfigFile() => config_path("{$this->package}.php"), - ], 'config'); - } - /** * Register the service provider. - * - * @return void */ public function register() { @@ -79,6 +65,16 @@ public function register() } } + /** + * Boot the service provider. + */ + public function boot() + { + $this->publishes([ + $this->getConfigFile() => config_path("{$this->package}.php"), + ], 'config'); + } + /** * Get the services provided by the provider. * @@ -107,8 +103,8 @@ private function registerTransManager() { $this->singleton('arcanedev.laravel-lang.manager', function (Application $app) { /** - * @var \Illuminate\Filesystem\Filesystem $files - * @var \Illuminate\Config\Repository $config + * @var \Illuminate\Filesystem\Filesystem $files + * @var \Illuminate\Contracts\Config\Repository $config */ $files = $app['files']; $config = $app['config']; @@ -120,7 +116,7 @@ private function registerTransManager() return new TransManager($files, $paths); }); - $this->app->bind( + $this->bind( \Arcanedev\LaravelLang\Contracts\TransManager::class, 'arcanedev.laravel-lang.manager' ); @@ -135,7 +131,7 @@ private function registerTransChecker() /** * @var \Illuminate\Translation\Translator $translator * @var \Arcanedev\LaravelLang\Contracts\TransManager $manager - * @var \Illuminate\Config\Repository $config + * @var \Illuminate\Contracts\Config\Repository $config */ $translator = $app['translator']; $manager = $app['arcanedev.laravel-lang.manager']; @@ -144,12 +140,15 @@ private function registerTransChecker() return new TransChecker($translator, $manager, $config->get('laravel-lang', [])); }); - $this->app->bind( + $this->bind( \Arcanedev\LaravelLang\Contracts\TransChecker::class, 'arcanedev.laravel-lang.checker' ); } + /** + * Register the lang publisher. + */ private function registerLangPublisher() { $this->singleton('arcanedev.laravel-lang.publisher', function (Application $app) { @@ -163,7 +162,7 @@ private function registerLangPublisher() return new TransPublisher($files, $manager, $app->langPath()); }); - $this->app->bind( + $this->bind( \Arcanedev\LaravelLang\Contracts\TransPublisher::class, 'arcanedev.laravel-lang.publisher' ); diff --git a/tests/Commands/CheckCommandTest.php b/tests/Commands/CheckCommandTest.php index 12e584c..487813d 100644 --- a/tests/Commands/CheckCommandTest.php +++ b/tests/Commands/CheckCommandTest.php @@ -10,20 +10,6 @@ */ class CheckCommandTest extends TestCase { - /* ------------------------------------------------------------------------------------------------ - | Main Functions - | ------------------------------------------------------------------------------------------------ - */ - public function setUp() - { - parent::setUp(); - } - - public function tearDown() - { - parent::tearDown(); - } - /* ------------------------------------------------------------------------------------------------ | Test Functions | ------------------------------------------------------------------------------------------------ diff --git a/tests/Commands/PublishCommandTest.php b/tests/Commands/PublishCommandTest.php index 8f03f27..bb6537b 100644 --- a/tests/Commands/PublishCommandTest.php +++ b/tests/Commands/PublishCommandTest.php @@ -10,20 +10,6 @@ */ class PublishCommandTest extends TestCase { - /* ------------------------------------------------------------------------------------------------ - | Main Functions - | ------------------------------------------------------------------------------------------------ - */ - public function setUp() - { - parent::setUp(); - } - - public function tearDown() - { - parent::tearDown(); - } - /* ------------------------------------------------------------------------------------------------ | Test Functions | ------------------------------------------------------------------------------------------------ diff --git a/tests/LaravelLangServiceProviderTest.php b/tests/LaravelLangServiceProviderTest.php index d6bc4b0..1d891ee 100644 --- a/tests/LaravelLangServiceProviderTest.php +++ b/tests/LaravelLangServiceProviderTest.php @@ -30,9 +30,9 @@ public function setUp() public function tearDown() { - parent::tearDown(); - unset($this->provider); + + parent::tearDown(); } /* ------------------------------------------------------------------------------------------------ diff --git a/tests/Providers/CommandServiceProviderTest.php b/tests/Providers/CommandServiceProviderTest.php index a84dab1..26282d7 100644 --- a/tests/Providers/CommandServiceProviderTest.php +++ b/tests/Providers/CommandServiceProviderTest.php @@ -31,9 +31,9 @@ public function setUp() public function tearDown() { - parent::tearDown(); - unset($this->provider); + + parent::tearDown(); } /* ------------------------------------------------------------------------------------------------ diff --git a/tests/TestCase.php b/tests/TestCase.php index efd949a..da15579 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,27 +14,18 @@ abstract class TestCase extends BaseTestCase | Properties | ------------------------------------------------------------------------------------------------ */ + /** + * All the available locales. + * + * @var array + */ protected $locales = [ - 'ar', 'bg', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'es', 'fa', 'fi', 'fr', - 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ka', 'km', 'ko', 'lt', 'me', 'mk', - 'ms', 'nb', 'nl', 'pl', 'pt', 'pt-BR', 'ro', 'ru', 'sc', 'sk', 'sl', 'sq', 'sr', - 'sv', 'th', 'tk', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW', + 'ar', 'bg', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'es', 'fa', 'fi', 'fr', 'gl', + 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ka', 'km', 'ko', 'lt', 'me', 'mk', 'ms', + 'nb', 'nl', 'pl', 'pt', 'pt-BR', 'ro', 'ru', 'sc', 'sk', 'sl', 'sq', 'sr', 'sv', + 'th', 'tk', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW', ]; - /* ------------------------------------------------------------------------------------------------ - | Main Functions - | ------------------------------------------------------------------------------------------------ - */ - public function setUp() - { - parent::setUp(); - } - - public function tearDown() - { - parent::tearDown(); - } - /* ------------------------------------------------------------------------------------------------ | Laravel Functions | ------------------------------------------------------------------------------------------------ @@ -74,7 +65,7 @@ protected function getPackageAliases($app) */ protected function getEnvironmentSetUp($app) { - /** @var \Illuminate\Config\Repository $config */ + /** @var \Illuminate\Contracts\Config\Repository $config */ $basePath = dirname(__DIR__); $config = $app['config']; @@ -133,7 +124,8 @@ protected function filesystem() */ protected function cleanLangDirectory($locale) { - return $this->filesystem()->cleanDirectory($this->app->langPath() . DS . $locale); + return $this->filesystem() + ->cleanDirectory($this->app->langPath() . DS . $locale); } /** @@ -145,7 +137,8 @@ protected function cleanLangDirectory($locale) */ protected function deleteLangDirectory($locale) { - return $this->filesystem()->deleteDirectory($this->app->langPath() . DS . $locale); + return $this->filesystem() + ->deleteDirectory($this->app->langPath() . DS . $locale); } /** diff --git a/tests/TransCheckerTest.php b/tests/TransCheckerTest.php index 041bbf0..4962940 100644 --- a/tests/TransCheckerTest.php +++ b/tests/TransCheckerTest.php @@ -30,9 +30,9 @@ public function setUp() public function tearDown() { - parent::tearDown(); - unset($this->checker); + + parent::tearDown(); } /* ------------------------------------------------------------------------------------------------ diff --git a/tests/TransManagerTest.php b/tests/TransManagerTest.php index 5284c72..f177215 100644 --- a/tests/TransManagerTest.php +++ b/tests/TransManagerTest.php @@ -30,9 +30,9 @@ public function setUp() public function tearDown() { - parent::tearDown(); - unset($this->manager); + + parent::tearDown(); } /* ------------------------------------------------------------------------------------------------ diff --git a/tests/TransPublisherTest.php b/tests/TransPublisherTest.php index 9efa020..ed34953 100644 --- a/tests/TransPublisherTest.php +++ b/tests/TransPublisherTest.php @@ -30,9 +30,9 @@ public function setUp() public function tearDown() { - parent::tearDown(); - unset($this->publisher); + + parent::tearDown(); } /* ------------------------------------------------------------------------------------------------ @@ -42,13 +42,10 @@ public function tearDown() /** @test */ public function it_can_be_instantiated() { - $expectations = [ + $this->assertInstanceOf( \Arcanedev\LaravelLang\TransPublisher::class, - ]; - - foreach ($expectations as $expected) { - $this->instance($expected, $this->publisher); - } + $this->publisher + ); } /** @test */ diff --git a/tests/TranslatorTest.php b/tests/TranslatorTest.php index 94ae2a0..cbcec2c 100644 --- a/tests/TranslatorTest.php +++ b/tests/TranslatorTest.php @@ -30,9 +30,9 @@ public function setUp() public function tearDown() { - parent::tearDown(); - unset($this->translator); + + parent::tearDown(); } /* ------------------------------------------------------------------------------------------------