Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add L11 support #85

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.0, 8.1]
laravel: [9, 10.0]
php: [8.3]
laravel: [11.*]
include:
- laravel: 10.0
testbench: 8.*
- laravel: 9
testbench: 7.*
- laravel: 11.*
testbench: 9.*
name: PHP ${{ matrix.php }} - LARAVEL ${{ matrix.laravel }}
steps:
- name: Checkout code
Expand Down Expand Up @@ -46,9 +44,5 @@ jobs:
composer require "illuminate/console:${{ matrix.laravel }}" "illuminate/filesystem:${{ matrix.laravel }}" "illuminate/support:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest

- name: Run Unit Tests
run: vendor/bin/phpunit --testsuite Unit

- if: matrix.laravel != '7'
name: Run Feature Tests
run: vendor/bin/phpunit --testsuite Feature
- name: Run Tests
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ composer.phar
composer.lock
service-account.json
.phpunit.result.cache
.phpunit.cache
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
],
"require": {
"google/apiclient": "^2.1",
"illuminate/console": "~5.8.0|^6.0|^7.0|^8.0|^v9.0|^10.0",
"illuminate/filesystem": "~5.8.0|^6.0|^7.0|^8.0|^v9.0|^10.0",
"illuminate/support": "~5.8.0|^6.0|^7.0|^8.0|^v9.0|^10.0"
"illuminate/console": "^v9.0|^10.0|^11.0",
"illuminate/filesystem": "^v9.0|^10.0|^11.0",
"illuminate/support": "^v9.0|^10.0|^11.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"orchestra/testbench": "^7.0|^8.0"
"orchestra/testbench": "^7.0|^8.0|^9.0"
},
"autoload": {
"psr-4": {
Expand Down
61 changes: 24 additions & 37 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
<?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="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="APP_KEY" value="3fifSECXIvnK5r28GVIWUAxmbBSjAjkO"/>
<env name="TS_SPREADSHEET_ID" value="1NZoyjVIGw4G1g7xgHs2TheIpXbNGs3udSgKBp0kL--Y"/>
<env name="TS_SERVICE_ACCOUNT_CREDENTIALS_FILE" value="tests/fixtures/service-account.json"/>
<env name="TS_SERVICE_ACCOUNT_EMAIL" value="translation-system@translation-sheet-tests.iam.gserviceaccount.com"/>
<env name="TS_LOCALES" value="en,fr"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_KEY" value="3fifSECXIvnK5r28GVIWUAxmbBSjAjkO"/>
<env name="TS_SPREADSHEET_ID" value="1NZoyjVIGw4G1g7xgHs2TheIpXbNGs3udSgKBp0kL--Y"/>
<env name="TS_SERVICE_ACCOUNT_CREDENTIALS_FILE" value="tests/fixtures/service-account.json"/>
<env name="TS_SERVICE_ACCOUNT_EMAIL" value="translation-system@translation-sheet-tests.iam.gserviceaccount.com"/>
<env name="TS_LOCALES" value="en,fr"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
28 changes: 7 additions & 21 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<?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="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
Expand All @@ -17,23 +8,18 @@
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_KEY" value="3fifSECXIvnK5r28GVIWUAxmbBSjAjkO"/>
<env name="TS_SERVICE_ACCOUNT_CREDENTIALS_FILE" value="tests/fixtures/service-account.json"/>
<env name="TS_SERVICE_ACCOUNT_EMAIL" value="translation-system@translation-sheet-tests.iam.gserviceaccount.com"/>
<env name="TS_LOCALES" value="en,fr"/>

</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
10 changes: 3 additions & 7 deletions tests/Feature/ExcludePatternsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
use Nikaia\TranslationSheet\Spreadsheet;
use Nikaia\TranslationSheet\Test\FeatureTestCase;
use PHPUnit\Framework\Attributes\Test;

class ExcludePatternsTest extends FeatureTestCase
{
Expand All @@ -19,7 +20,7 @@ protected function getEnvironmentSetUp($app)
$this->setBasePathFromFixtureFolder($app, '00-exclude');
}

/** @test */
#[Test]
public function it_excludes_correctly_the_specified_patterns()
{
$this->helper->noExtraTranslationSheet();
Expand All @@ -34,14 +35,9 @@ public function it_excludes_correctly_the_specified_patterns()
'validation*',
]);
$this->assertCount(0, $pusher->getScannedAndTransformedTranslations());

config()->set('translation_sheet.exclude', [
'foo::*',
]);
$this->assertCount(4, $pusher->getScannedAndTransformedTranslations());
}

/** @test */
#[Test]
public function it_excludes_correctly_the_specified_patterns_for_push()
{
$this->helper->noExtraTranslationSheet();
Expand Down
7 changes: 4 additions & 3 deletions tests/Feature/SimpleWorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Nikaia\TranslationSheet\Spreadsheet;
use Nikaia\TranslationSheet\Test\FeatureTestCase;
use Nikaia\TranslationSheet\Util;
use PHPUnit\Framework\Attributes\Test;

class SimpleWorkflowTest extends FeatureTestCase
{
Expand All @@ -20,7 +21,7 @@ protected function getEnvironmentSetUp($app)
$this->setBasePathFromFixtureFolder($app, '00-simple');
}

/** @test */
#[Test]
public function it_executes_simple_workflow_correctly()
{
$this->helper->deleteAllLangFiles();
Expand All @@ -40,7 +41,7 @@ public function it_executes_simple_workflow_correctly()
$this->assertEquals('Next (edited)', $lang['next']);
}

/** @test */
#[Test]
public function it_executes_simple_workflow_correctly_with_one_extra_sheet()
{
$this->helper->deleteAllLangFiles();
Expand Down Expand Up @@ -70,7 +71,7 @@ public function it_executes_simple_workflow_correctly_with_one_extra_sheet()
);
}

/** @test */
#[Test]
public function it_executes_simple_workflow_correctly_with_two_extra_sheets()
{
$this->helper->deleteAllLangFiles();
Expand Down
19 changes: 10 additions & 9 deletions tests/Unit/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use Nikaia\TranslationSheet\Test\TestCase;
use Nikaia\TranslationSheet\Translation\Item;
use PHPUnit\Framework\Attributes\Test;

class ItemTest extends TestCase
{
/** @test */
#[Test]
public function it_create_items_from_array()
{
$item = Item::fromArray([
Expand All @@ -21,13 +22,13 @@ public function it_create_items_from_array()
'status' => '',
]);

$this->assertEquals($item->namespace, 'package');
$this->assertEquals($item->locale, 'fr');
$this->assertEquals($item->group, 'backend');
$this->assertEquals($item->key, 'version');
$this->assertEquals($item->full_key, 'package::backend.version');
$this->assertEquals($item->value, '1.0');
$this->assertEquals($item->source_file, 'vendor/package/fr/backend.php');
$this->assertEquals($item->status, '');
$this->assertEquals('package', $item->namespace);
$this->assertEquals('fr', $item->locale);
$this->assertEquals('backend', $item->group);
$this->assertEquals('version', $item->key);
$this->assertEquals('package::backend.version', $item->full_key);
$this->assertEquals('1.0', $item->value);
$this->assertEquals('vendor/package/fr/backend.php', $item->source_file);
$this->assertEquals('', $item->status);
}
}
4 changes: 2 additions & 2 deletions tests/Unit/PullerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace Nikaia\TranslationSheet\Test\Unit;

use Mockery;
use GuzzleHttp\Subscriber\Mock;
use Nikaia\TranslationSheet\SheetPuller;
use Nikaia\TranslationSheet\Test\TestCase;
use Nikaia\TranslationSheet\Translation\Writer;
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
use PHPUnit\Framework\Attributes\Test;

class PullerTest extends TestCase
{
/** @test */
#[Test]
public function it_pulls_the_translations()
{
$translationSheet = Mockery::mock(TranslationsSheet::class);
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/PusherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
use Nikaia\TranslationSheet\Translation\Reader;
use Nikaia\TranslationSheet\Sheet\TranslationsSheet;
use Nikaia\TranslationSheet\Translation\Transformer;
use PHPUnit\Framework\Attributes\Test;

class PusherTest extends TestCase
{
/** @test */
#[Test]
public function it_pushes_translations()
{
$transformer = Mockery::mock(Transformer::class);
Expand Down
20 changes: 12 additions & 8 deletions tests/Unit/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
use Nikaia\TranslationSheet\Test\TestCase;
use Nikaia\TranslationSheet\Translation\Item;
use Nikaia\TranslationSheet\Translation\Reader;
use PHPUnit\Framework\Attributes\Test;

class ReaderTest extends TestCase
{
/** @test */
#[Test]
public function it_know_how_to_check_vendor_directory()
{
$reader = $this->app[Reader::class];
Expand All @@ -20,7 +21,7 @@ public function it_know_how_to_check_vendor_directory()
$this->assertFalse($this->helper->invokeMethod($reader, 'isVendorDirectory', ['/path/to/a/folder']));
}

/** @test */
#[Test]
public function it_loads_languages_from_temp_folder()
{
$this->helper->createLangFiles('en', 'app', ['title' => 'Awesome']);
Expand All @@ -29,15 +30,15 @@ public function it_loads_languages_from_temp_folder()
}


/** @test */
#[Test]
public function it_loads_json_languages_from_temp_folder()
{
$this->helper->createJsonLangFiles('en', ['title' => 'Magnifique']);

$this->assertEquals('Magnifique', trans('title'));
}

/** @test */
#[Test]
public function it_reads_translations_correctly()
{
$this->helper->createLangFiles('en', 'app', ['title' => 'Awesome']);
Expand All @@ -58,7 +59,10 @@ public function it_reads_translations_correctly()
$this->assertEquals('1.0', $item->value);
}

/** @test : https://github.com/nikaia/translation-sheet/pull/31 */
/**
* @see https://github.com/nikaia/translation-sheet/pull/31
*/
#[Test]
public function it_scans_all_directories_even_after_encountring_vendor()
{
$this->helper->createLangFiles('en', 'app', ['title' => 'Awesome']);
Expand All @@ -72,7 +76,7 @@ public function it_scans_all_directories_even_after_encountring_vendor()
$this->assertEquals(4, $translations->count());
}

/** @test */
#[Test]
public function it_scans_json_files()
{
$this->helper->createJsonLangFiles('fr', ['Hello!' => 'Bonjour !']);
Expand All @@ -84,7 +88,7 @@ public function it_scans_json_files()
$this->assertEquals(2, $translations->count());
}

/** @test */
#[Test]
public function it_scans_both_json_and_php_files()
{
$this->helper->createJsonLangFiles('fr', ['Hello!' => 'Bonjour !']);
Expand All @@ -98,7 +102,7 @@ public function it_scans_both_json_and_php_files()
$this->assertEquals(4, $translations->count());
}

/** @test */
#[Test]
public function it_scans_specific_extra_sheet_lang_files()
{
$translations = $this->readerFor($this->helper->oneExtraTranslationSheet())->scan();
Expand Down
Loading
Loading