Skip to content

Commit

Permalink
8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
railken committed Mar 28, 2024
1 parent 318365d commit 891a111
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 59 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
15 changes: 10 additions & 5 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ 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:
commit_message: Apply style changes
branch: ${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

26 changes: 12 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,29 +35,28 @@ 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
id: composer-cache
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'] }}
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
20 changes: 6 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
</php>
Expand Down
4 changes: 2 additions & 2 deletions src/DataSchema/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Amethyst\DataSchema;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;

class Helper
{
const PREFIX = '';

public static function toTable(string $name)
{
return static::PREFIX.Inflector::tableize(str_replace('-', '_', $name));
return static::PREFIX.(InflectorFactory::create()->build())->tableize(str_replace('-', '_', $name));
}
}
5 changes: 3 additions & 2 deletions src/Providers/DataSchemaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions tests/Managers/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Amethyst\Tests\Managers;

use Amethyst\Managers\AttributeManager;
use Amethyst\Managers\AttributeSchemaManager;
use Amethyst\Managers\DataSchemaManager;
use Amethyst\Tests\BaseTest;

Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 891a111

Please sign in to comment.