From 891a111cc0c60b08dcfbfe9447eb189a13ee7668 Mon Sep 17 00:00:00 2001 From: Railken Date: Thu, 28 Mar 2024 23:22:55 +0100 Subject: [PATCH] 8.x --- .github/workflows/quality.yml | 11 +++++---- .github/workflows/style.yml | 15 ++++++++---- .github/workflows/test.yml | 26 ++++++++++----------- .gitignore | 8 ++++--- README.md | 6 ++--- composer.json | 9 ++++--- phpunit.xml.dist | 20 +++++----------- src/DataSchema/Helper.php | 4 ++-- src/Providers/DataSchemaServiceProvider.php | 5 ++-- tests/BaseTest.php | 4 ++++ tests/Managers/AttributeTest.php | 10 ++++---- 11 files changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 8c1105e..109fa44 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -11,11 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php with: - php-version: 7.2 + php-version: 8.3 extension-csv: mbstring, dom, fileinfo, mysql, zip coverage: xdebug #optional - name: Get composer cache directory @@ -24,8 +24,9 @@ jobs: - name: Install Composer dependencies run: | composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader - composer global require amethyst/cli + composer require --dev phpstan/phpstan - name: Test Quality run: | - export PATH="$HOME/.composer/vendor/bin:$PATH" - amethyst test:phpstan --verbose + export PATH="$HOME/.composer/vendor/bin:$PATH" + ./vendor/bin/phpstan analyse --level=0 src + ./vendor/bin/phpstan analyse --level=0 tests diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index a369c63..df1947d 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -11,17 +11,23 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 - + uses: actions/checkout@v4 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php + with: + php-version: 8.3 + extension-csv: mbstring, dom, fileinfo, mysql, zip + coverage: xdebug #optional - name: Install Composer dependencies run: | composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader - composer global require amethyst/cli + composer require --dev friendsofphp/php-cs-fixer - name: Run fix:style run: | export PATH="$HOME/.composer/vendor/bin:$PATH" - amethyst fix:style --verbose + ./vendor/bin/php-cs-fixer fix src + ./vendor/bin/php-cs-fixer fix tests - uses: stefanzweifel/git-auto-commit-action@v2.1.0 with: @@ -29,4 +35,3 @@ jobs: branch: ${{ github.ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 38bd89b..5aac74c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,22 +2,21 @@ name: Test on: pull_request: paths: - - '**.php' + - '**.php' + - '**.yml' push: paths: - '**.php' + - '**.yml' jobs: laravel: - name: Laravel ${{ matrix.laravel-versions }} (PHP ${{ matrix.php-versions }}) + name: Laravel ${{ matrix.laravel }} (PHP ${{ matrix.php }}) runs-on: ubuntu-latest env: DB_DATABASE: laravel DB_USERNAME: root DB_PASSWORD: password - BROADCAST_DRIVER: log - CACHE_DRIVER: redis - QUEUE_CONNECTION: redis - SESSION_DRIVER: redis + BROADCAST_DRIVER: log services: mysql: image: mysql:5.7 @@ -36,15 +35,15 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.2', '7.3', '7.4'] - laravel-versions: ['5.8.*', '6.*'] + php: ['8.2', '8.3'] + laravel: ['9.*', '10.*'] steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php }} extension-csv: mbstring, dom, fileinfo, mysql, zip coverage: xdebug #optional - name: Get composer cache directory @@ -52,13 +51,12 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Install Composer dependencies run: | - composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader - composer require --dev amethyst/cli - composer require --dev "laravel/framework:${{ matrix.laravel-versions }}" --no-update; + composer require --dev "laravel/framework:${{ matrix.laravel }}" --no-update + composer update --no-progress --no-suggest --prefer-dist --optimize-autoloader - name: Prepare the application run: | php -r "file_exists('.env') || copy('.env.example', '.env');" - name: Test - run: vendor/bin/amethyst test:phpunit --verbose + run: ./vendor/bin/phpunit --coverage-text --coverage-clover=build/logs/clover.xml env: DB_PORT: ${{ job.services.mysql.ports['3306'] }} diff --git a/.gitignore b/.gitignore index bae3e46..e08f95c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ vendor/ -var/ -phpunit.xml +\.php_cs\.cache +build/ \.env composer\.lock -build/ .phpunit.result.cache +phpunit.xml +.php-cs-fixer.cache +.phpunit.cache/test-results diff --git a/README.md b/README.md index 2ac9360..48ed94c 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ # amethyst-data-schema - [![Action Status](https://github.com/amethyst-php/data-schema/workflows/test/badge.svg)](https://github.com/amethyst-php/data-schema/actions) - -[Amethyst](https://github.com/amethyst-php/amethyst) package. +[![Amethyst](https://img.shields.io/badge/package-Amethyst-7e57c2)](https://github.com/amethyst-php/amethyst) # Requirements -PHP 7.2 and later. +PHP 8.2 and later. ## Installation diff --git a/composer.json b/composer.json index 59afce7..ae7981e 100644 --- a/composer.json +++ b/composer.json @@ -4,13 +4,12 @@ "keywords": ["laravel", "amethyst", "data-schema"], "license": "MIT", "require": { - "php": ">=7.2", - "amethyst/core": "0.2.*", - "amethyst/attribute-schema": "0.2.*", - "amethyst/relation-schema": "0.2.*" + "php": ">=8.2", + "amethyst/core": "0.3.*", + "amethyst/attribute-schema": "0.3.*", + "amethyst/relation-schema": "0.3.*" }, "require-dev": { - "phpunit/phpunit": "*", "orchestra/testbench": "*" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e2a5eac..7dfd4b5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,23 +1,15 @@ - + ./tests - - - ./src - - + + + ./src + + diff --git a/src/DataSchema/Helper.php b/src/DataSchema/Helper.php index 403bb73..9df779a 100644 --- a/src/DataSchema/Helper.php +++ b/src/DataSchema/Helper.php @@ -2,7 +2,7 @@ namespace Amethyst\DataSchema; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; class Helper { @@ -10,6 +10,6 @@ class Helper public static function toTable(string $name) { - return static::PREFIX.Inflector::tableize(str_replace('-', '_', $name)); + return static::PREFIX.(InflectorFactory::create()->build())->tableize(str_replace('-', '_', $name)); } } diff --git a/src/Providers/DataSchemaServiceProvider.php b/src/Providers/DataSchemaServiceProvider.php index 6868b4d..2904ac5 100644 --- a/src/Providers/DataSchemaServiceProvider.php +++ b/src/Providers/DataSchemaServiceProvider.php @@ -13,10 +13,11 @@ class DataSchemaServiceProvider extends CommonServiceProvider */ public function register() { - parent::register(); - $this->app->register(\Amethyst\Providers\AttributeSchemaServiceProvider::class); $this->app->register(\Amethyst\Providers\RelationSchemaServiceProvider::class); + + parent::register(); + $this->app->singleton('amethyst.data-schema', function ($app) { return new \Amethyst\Services\DataSchema(); diff --git a/tests/BaseTest.php b/tests/BaseTest.php index ee7355d..b111db3 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -12,6 +12,10 @@ public function setUp(): void parent::setUp(); $this->artisan('migrate:fresh'); + + app('amethyst.relation-schema')->boot(); + app('amethyst.attribute-schema')->boot(); + app('eloquent.mapper')->boot(); } protected function getPackageProviders($app) diff --git a/tests/Managers/AttributeTest.php b/tests/Managers/AttributeTest.php index b000eb8..8208e1e 100644 --- a/tests/Managers/AttributeTest.php +++ b/tests/Managers/AttributeTest.php @@ -2,7 +2,7 @@ namespace Amethyst\Tests\Managers; -use Amethyst\Managers\AttributeManager; +use Amethyst\Managers\AttributeSchemaManager; use Amethyst\Managers\DataSchemaManager; use Amethyst\Tests\BaseTest; @@ -16,7 +16,7 @@ public function testBasicAttribute() $manager = app('amethyst')->findManagerByName($data->name); - $attribute = app(AttributeManager::class)->createOrFail([ + $attribute = app(AttributeSchemaManager::class)->createOrFail([ 'name' => 'name', 'schema' => 'Text', 'model' => 'cat', @@ -28,7 +28,7 @@ public function testBasicAttribute() $this->assertEquals('cat-1', $resource->name); - $attribute = app(AttributeManager::class)->createOrFail([ + $attribute = app(AttributeSchemaManager::class)->createOrFail([ 'name' => 'description', 'schema' => 'Text', 'model' => 'cat', @@ -61,7 +61,7 @@ public function testAvoidAttributeCollision() $managerCat = app('amethyst')->findManagerByName($dataCat->name); - app(AttributeManager::class)->createOrFail([ + app(AttributeSchemaManager::class)->createOrFail([ 'name' => 'name', 'schema' => 'Text', 'model' => 'cat', @@ -73,7 +73,7 @@ public function testAvoidAttributeCollision() $managerDog = app('amethyst')->findManagerByName($dataDog->name); - app(AttributeManager::class)->createOrFail([ + app(AttributeSchemaManager::class)->createOrFail([ 'name' => 'label', 'schema' => 'Text', 'model' => 'dog',