Skip to content

Commit 8bd84a3

Browse files
authored
Merge pull request #128 from Astrotomic/laravel-7
Laravel 7
2 parents 707e3ef + f3af0e5 commit 8bd84a3

File tree

12 files changed

+102
-159
lines changed

12 files changed

+102
-159
lines changed

.gitattributes

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/.github export-ignore
2-
/.php_cs export-ignore
3-
/.gitbook.yaml export-ignore
4-
/.styleci.yml export-ignore
5-
/.gitattributes export-ignore
6-
/.scrutinizer.yml export-ignore
72
/docs export-ignore
83
/.codeclimate.yml export-ignore
4+
/.gitattributes export-ignore
5+
/.gitbook.yaml export-ignore
6+
/.php_cs export-ignore
7+
/.scrutinizer.yml export-ignore
8+
/.styleci.yml export-ignore
99

1010
# phpunit.xml.dist and tests are not excluded so tests can be run
1111
# this is usefull if this package ends up one day in Debian

.github/workflows/run-tests.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
php: [7.4, 7.3, 7.2]
16-
laravel: [6.*, 5.8.*]
16+
laravel: [7.*, 6.*, 5.8.*]
1717
dependency-version: [prefer-lowest, prefer-stable]
1818
os: [ubuntu-latest, windows-latest, macos-latest]
1919
include:
20+
- laravel: 7.*
21+
testbench: 5.*
2022
- laravel: 6.*
2123
testbench: 4.*
2224
- laravel: 5.8.*
@@ -53,16 +55,8 @@ jobs:
5355
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
5456
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
5557
56-
- name: Configure matchers
57-
uses: mheap/phpunit-matcher-action@master
58-
5958
- name: Execute tests
60-
run: vendor/bin/phpunit --teamcity --coverage-text --coverage-clover=coverage.clover
61-
62-
- name: Upload ScrutinizerCI coverage
63-
run: |
64-
php -r "copy('https://scrutinizer-ci.com/ocular.phar', 'ocular.phar');"
65-
php ocular.phar code-coverage:upload --repository="g/Astrotomic/laravel-translatable" --revision="${{ github.sha }}" --format=php-clover coverage.clover
59+
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
6660

6761
- name: Upload Codecov coverage
6862
uses: codecov/codecov-action@v1

.scrutinizer.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ build:
1515
override:
1616
- php-scrutinizer-run
1717

18-
tools:
19-
external_code_coverage:
20-
timeout: 900
21-
runs: 1
22-
2318
filter:
2419
paths:
2520
- src/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Please see [SECURITY](SECURITY.md) for details.
9898

9999
| Package | Laravel | PHP |
100100
| :--- | :--- | :--- |
101-
| **v11.6 - v11.7** | `5.8.* / 6.*` | `>=7.2` |
101+
| **v11.6 - v11.8** | `5.8.* / 6.* / 7.*` | `>=7.2` |
102102
| **v11.4 - v11.5** | `5.6.* / 5.7.* / 5.8.* / 6.*` | `>=7.1.3` |
103103
| **v11.0 - v11.3** | `5.6.* / 5.7.* / 5.8.*` | `>=7.1.3` |
104104

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
],
2626
"require": {
2727
"php": ">=7.2",
28-
"illuminate/contracts": "5.8.* || ^6.0",
29-
"illuminate/database": "5.8.* || ^6.0",
30-
"illuminate/support": "5.8.* || ^6.0"
28+
"illuminate/contracts": "5.8.* || ^6.0 || ^7.0",
29+
"illuminate/database": "5.8.* || ^6.0 || ^7.0",
30+
"illuminate/support": "5.8.* || ^6.0 || ^7.0"
3131
},
3232
"require-dev": {
33-
"orchestra/testbench": "3.8.* || ^4.0",
34-
"phpunit/phpunit": "^8.0"
33+
"orchestra/testbench": "3.8.* || ^4.0 || ^5.0",
34+
"phpunit/phpunit": "^8.0 || ^9.0"
3535
},
3636
"config": {
3737
"sort-packages": true
@@ -53,6 +53,8 @@
5353
"Astrotomic\\Translatable\\Tests\\": "tests/"
5454
}
5555
},
56+
"minimum-stability": "dev",
57+
"prefer-stable": true,
5658
"scripts": {
5759
"csfix": "php-cs-fixer fix --using-cache=no",
5860
"test": "vendor/bin/phpunit",

docs/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Introduction
22

3-
[![Total Downloads](https://img.shields.io/packagist/dt/astrotomic/laravel-translatable.svg?style=flat-square)](https://packagist.org/packages/astrotomic/laravel-translatable) [![TravisCI](https://img.shields.io/travis/Astrotomic/laravel-translatable/master?label=TravisCI&style=flat-square&cacheSeconds=600)](https://travis-ci.org/Astrotomic/laravel-translatable/branches) [![StyleCI](https://styleci.io/repos/192333549/shield)](https://styleci.io/repos/192333549) [![ScrutinizerCI](https://img.shields.io/scrutinizer/quality/g/Astrotomic/laravel-translatable/master.svg?label=ScrutinizerCI&style=flat-square)](https://scrutinizer-ci.com/g/Astrotomic/laravel-translatable/) [![Code Climate](https://img.shields.io/codeclimate/maintainability/Astrotomic/laravel-translatable.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/Astrotomic/laravel-translatable) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Astrotomic/laravel-translatable/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/Astrotomic/laravel-translatable/) [![Latest Version](http://img.shields.io/packagist/v/astrotomic/laravel-translatable.svg?style=flat-square)](https://packagist.org/packages/astrotomic/laravel-translatable) ![MIT License](https://img.shields.io/github/license/Astrotomic/laravel-translatable.svg?color=blue&style=flat-square) [![Open Collective](https://img.shields.io/opencollective/all/astrotomic?label=Open%20Collective&style=flat-square&cacheSeconds=600)](https://opencollective.com/astrotomic)
3+
[![Latest Version](http://img.shields.io/packagist/v/astrotomic/laravel-translatable.svg?label=Release&style=for-the-badge)](https://packagist.org/packages/astrotomic/laravel-translatable)
4+
[![MIT License](https://img.shields.io/github/license/Astrotomic/laravel-translatable.svg?label=License&color=blue&style=for-the-badge)](https://github.com/Astrotomic/laravel-translatable/blob/master/LICENSE)
5+
[![Offset Earth](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-green?style=for-the-badge)](https://offset.earth/treeware)
6+
7+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Astrotomic/laravel-translatable/run-tests?style=flat-square&logoColor=white&logo=github&label=Tests)](https://github.com/Astrotomic/laravel-translatable/actions?query=workflow%3Arun-tests)
8+
[![StyleCI](https://styleci.io/repos/192333549/shield)](https://styleci.io/repos/192333549)
9+
[![ScrutinizerCI](https://img.shields.io/scrutinizer/quality/g/Astrotomic/laravel-translatable/master.svg?label=Scrutinizer&logoColor=white&logo=scrutinizer-ci&style=flat-square)](https://scrutinizer-ci.com/g/Astrotomic/laravel-translatable/)
10+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/Astrotomic/laravel-translatable.svg?label=CodeClimate&logoColor=white&logo=code-climate&style=flat-square)](https://codeclimate.com/github/Astrotomic/laravel-translatable)
11+
[![Codecov Coverage](https://img.shields.io/codecov/c/github/Astrotomic/laravel-translatable?logo=codecov&logoColor=white&label=Codecov&style=flat-square)](https://codecov.io/gh/Astrotomic/laravel-translatable)
12+
[![Total Downloads](https://img.shields.io/packagist/dt/astrotomic/laravel-translatable.svg?label=Downloads&style=flat-square)](https://packagist.org/packages/astrotomic/laravel-translatable)
413

514
![Laravel Translatable](.gitbook/assets/laravel-translatable-2-1.png)
615

@@ -72,7 +81,18 @@ echo $post->translate('fr')->title; // Mon premier post
7281

7382
| Package | Laravel | PHP |
7483
| :--- | :--- | :--- |
75-
| **v11.6 - v11.7** | `5.8.* / 6.*` | `>=7.2` |
84+
| **v11.6 - v11.8** | `5.8.* / 6.* / 7.*` | `>=7.2` |
7685
| **v11.4 - v11.5** | `5.6.* / 5.7.* / 5.8.* / 6.*` | `>=7.1.3` |
7786
| **v11.0 - v11.3** | `5.6.* / 5.7.* / 5.8.*` | `>=7.1.3` |
7887

88+
## Treeware
89+
90+
You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.
91+
92+
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.
93+
94+
You can buy trees at https://offset.earth/treeware
95+
96+
Read more about Treeware at https://treeware.earth
97+
98+
[![We offset our carbon footprint via Offset Earth](https://toolkit.offset.earth/carbonpositiveworkforce/badge/5e186e68516eb60018c5172b?black=true&landscape=true)](https://offset.earth/treeware)

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## v11
44

5+
### v11.8.0
6+
7+
* Add Laravel 7 support - [\#128](https://github.com/Astrotomic/laravel-translatable/pull/128)
8+
59
### v11.7.1
610

711
* Add `.gitattributes` to exclude files from archive - [\#126](https://github.com/Astrotomic/laravel-translatable/pull/126)

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</filter>
2525
<php>
2626
<env name="APP_ENV" value="testing"/>
27-
<env name="DB_CONNECTION" value="sqlite"/>
27+
<env name="DB_CONNECTION" value="testing"/>
2828
<env name="DB_DATABASE" value=":memory:"/>
2929
</php>
3030
</phpunit>

tests/ScopesTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44

55
use Astrotomic\Translatable\Tests\Eloquent\Country;
66
use Astrotomic\Translatable\Tests\Eloquent\Vegetable;
7-
use Illuminate\Foundation\Testing\RefreshDatabase;
87

98
final class ScopesTest extends TestCase
109
{
11-
use RefreshDatabase;
12-
1310
/** @test */
1411
public function translated_in_scope_returns_only_translated_records_for_this_locale(): void
1512
{

tests/TestCase.php

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
namespace Astrotomic\Translatable\Tests;
44

55
use Astrotomic\Translatable\TranslatableServiceProvider;
6+
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Foundation\Testing\RefreshDatabase;
8+
use Illuminate\Support\Facades\Schema;
69
use Orchestra\Testbench\TestCase as OrchestraTestCase;
710

811
abstract class TestCase extends OrchestraTestCase
912
{
13+
use RefreshDatabase;
14+
1015
protected function setUp(): void
1116
{
1217
parent::setUp();
1318

14-
$this->loadMigrationsFrom([
15-
'--database' => 'testing',
16-
'--path' => realpath('tests/migrations'),
17-
]);
19+
$this->createTables();
1820

19-
$this->withFactories(realpath('tests/factories'));
21+
$this->withFactories(realpath(__DIR__.'/factories'));
2022
}
2123

2224
protected function getEnvironmentSetUp($app)
@@ -30,4 +32,55 @@ protected function getPackageProviders($app)
3032
TranslatableServiceProvider::class,
3133
];
3234
}
35+
36+
protected function createTables(): void
37+
{
38+
Schema::create('countries', function (Blueprint $table) {
39+
$table->increments('id');
40+
$table->string('code');
41+
$table->timestamps();
42+
$table->softDeletes();
43+
});
44+
45+
Schema::create('country_translations', function (Blueprint $table) {
46+
$table->increments('id');
47+
$table->integer('country_id')->unsigned();
48+
$table->string('name');
49+
$table->string('locale')->index();
50+
51+
$table->unique(['country_id', 'locale']);
52+
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
53+
});
54+
55+
Schema::create('vegetables', function (Blueprint $table) {
56+
$table->increments('identity');
57+
$table->integer('quantity')->default(0);
58+
$table->timestamps();
59+
});
60+
61+
Schema::create('vegetable_translations', function (Blueprint $table) {
62+
$table->increments('id');
63+
$table->integer('vegetable_identity')->unsigned();
64+
$table->string('name')->nullable();
65+
$table->string('locale')->index();
66+
67+
$table->unique(['vegetable_identity', 'locale']);
68+
$table->foreign('vegetable_identity')->references('identity')->on('vegetables');
69+
});
70+
71+
Schema::create('people', function (Blueprint $table) {
72+
$table->increments('id');
73+
$table->timestamps();
74+
});
75+
76+
Schema::create('person_translations', function (Blueprint $table) {
77+
$table->increments('id');
78+
$table->integer('person_id')->unsigned();
79+
$table->string('name');
80+
$table->string('locale')->index();
81+
82+
$table->unique(['person_id', 'locale']);
83+
$table->foreign('person_id')->references('id')->on('persons')->onDelete('cascade');
84+
});
85+
}
3386
}

0 commit comments

Comments
 (0)