Skip to content

Commit

Permalink
Add PHP8 support (#23)
Browse files Browse the repository at this point in the history
* Add PHP8 support

* Remove PHP CS-Fixer
  • Loading branch information
antonkomarev authored Dec 31, 2020
1 parent c2ed0c9 commit 878e2d6
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 106 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/CODE_OF_CONDUCT.md export-ignore
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor/
.php_cs.cache
.phpunit.result.cache
composer.lock
composer.phar
Expand Down
64 changes: 0 additions & 64 deletions .php_cs

This file was deleted.

6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0

env:
global:
Expand All @@ -15,6 +16,9 @@ before_script:
- if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable; fi
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi
- if [ $(phpenv version-name) = '7.3' ]; then composer require laravel/legacy-factories --dev; fi
- if [ $(phpenv version-name) = '7.4' ]; then composer require laravel/legacy-factories --dev; fi
- if [ $(phpenv version-name) = '8.0' ]; then composer require laravel/legacy-factories --dev; fi

script:
- ./vendor/bin/phpunit -c phpunit.xml.dist --verbose
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f

## [Unreleased]

## [5.3.0] - 2020-12-31

### Added

- ([#22]) Added Laravel 6.x support
- ([#22]) Added Laravel 7.x support
- ([#22]) Added Laravel 8.x support
- ([#23]) Added PHP 8.x support

### Removed

- ([#23]) Dropped PHP 5.6 support
- ([#23]) Dropped PHP 7.0 support

## [5.2.0] - 2018-09-09

### Added
Expand Down Expand Up @@ -101,4 +115,6 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f
[2.0.0]: https://github.com/cybercog/laravel-ownership/compare/1.0.0...2.0.0
[Upgrade instructions]: UPGRADING.md

[#23]: https://github.com/cybercog/laravel-ownership/pull/23
[#22]: https://github.com/cybercog/laravel-ownership/pull/22
[#19]: https://github.com/cybercog/laravel-ownership/pull/19
6 changes: 1 addition & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ Due to time constraints, we are not always able to respond as quickly as we woul

## Coding Guidelines

This project comes with a configuration file for php-cs-fixer (.php_cs) that you can use to (re)format your sourcecode for compliance with this project's coding guidelines:

```shell script
$ vendor/bin/php-cs-fixer fix
```
This project follows [PSR-12 coding style guide](https://www.php-fig.org/psr/psr-12/).

## PHPUnit tests

Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@
"docs": "https://github.com/cybercog/laravel-ownership/wiki"
},
"require": {
"php": "^5.6|^7.0",
"php": "^7.1.3|^8.0",
"illuminate/database": "^5.2|^6.0|^7.0|^8.0",
"illuminate/support": "^5.2|^6.0|^7.0|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.10",
"mockery/mockery": "^1.0",
"orchestra/database": "~3.5.0|~3.6.0|~3.7.0",
"orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0",
"phpunit/phpunit": "^6.0|^7.0"
"orchestra/database": "^3.5|^4.0|^5.0|^6.0",
"orchestra/testbench": "^3.5|^4.0|^5.0|^6.0",
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0"
},
"autoload": {
"psr-4": {
Expand Down
49 changes: 20 additions & 29 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

namespace Cog\Tests\Laravel\Ownership;

use Cog\Laravel\Ownership\Providers\OwnershipServiceProvider;
use Cog\Tests\Laravel\Ownership\Stubs\Models\Character;
use Cog\Tests\Laravel\Ownership\Stubs\Models\User;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Foundation\Application;
use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

/**
Expand All @@ -26,38 +29,28 @@ abstract class TestCase extends Orchestra
/**
* Actions to be performed on PHPUnit start.
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

$this->registerMigrations();
$this->migrateUnitTestTables();
$this->registerPackageFactories();
$this->registerTestMorphMaps();
}

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$this->setDefaultUserModel($app);
$this->setDefaultUserModel();
}

/**
* Load package service provider.
*
* @param \Illuminate\Foundation\Application $app
* @param Application $app
* @return array
*/
protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
\Cog\Laravel\Ownership\Providers\OwnershipServiceProvider::class,
\Orchestra\Database\ConsoleServiceProvider::class,
OwnershipServiceProvider::class,
ConsoleServiceProvider::class,
];
}

Expand All @@ -66,51 +59,49 @@ protected function getPackageProviders($app)
*
* @return void
*/
protected function registerMigrations()
protected function registerMigrations(): void
{
$this->loadMigrationsFrom([
'--realpath' => realpath(__DIR__ . '/database/migrations'),
]);
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
}

/**
* Perform unit test database migrations.
*
* @return void
*/
protected function migrateUnitTestTables()
protected function migrateUnitTestTables(): void
{
$this->artisan('migrate');
$this->artisan('migrate', ['--database' => 'sqlite'])->run();
}

/**
* Register package related model factories.
*
* @return void
*/
private function registerPackageFactories()
private function registerPackageFactories(): void
{
$pathToFactories = realpath(__DIR__ . '/database/factories');
$this->withFactories($pathToFactories);
$this->withFactories(__DIR__ . '/database/factories');
}

/**
* Set default user model used by tests.
*
* @param $app
* @return void
*/
private function setDefaultUserModel($app)
private function setDefaultUserModel(): void
{
$app['config']->set('auth.providers.users.model', User::class);
$this->app
->make('config')
->set('auth.providers.users.model', User::class);
}

/**
* Register morph map for test cases.
*
* @return void
*/
protected function registerTestMorphMaps()
protected function registerTestMorphMaps(): void
{
Relation::morphMap([
'character' => Character::class,
Expand Down

0 comments on commit 878e2d6

Please sign in to comment.