diff --git a/.github/workflows/test-matrix.yml b/.github/workflows/test-matrix.yml new file mode 100644 index 0000000..4019df2 --- /dev/null +++ b/.github/workflows/test-matrix.yml @@ -0,0 +1,178 @@ +name: Test Matrix + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 10 + + strategy: + fail-fast: false + matrix: + laravel: [12.*, 11.*, 10.*, 9.*, 8.*, 7.*, 6.*] + + include: + - laravel: 12.* + testbench: 10.* + php: 8.4 + + - laravel: 11.* + testbench: 9.* + php: 8.3 + + - laravel: 10.* + testbench: 8.* + php: 8.2 + + - laravel: 9.* + testbench: 7.* + php: 8.1 + + - laravel: 8.* + testbench: 6.* + php: 8.0 + + - laravel: 7.* + testbench: 5.* + php: 7.4 + + - laravel: 6.* + testbench: 4.* + php: 7.4 + + database: [sqlite, mysql_57, mysql_8, mariadb, pgsql, mssql] + + name: PHP ${{ matrix.php }} | L${{ matrix.laravel }} | DB:${{ matrix.database }} + + services: + mysql57: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: laravel + ports: [3307:3306] + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + mysql8: + image: mysql:8 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: laravel + ports: [3308:3306] + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + mariadb: + image: mariadb:10 + env: + MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes + MARIADB_DATABASE: laravel + ports: [3309:3306] + + pgsql: + image: postgres:14 + env: + POSTGRES_DB: laravel + POSTGRES_USER: forge + POSTGRES_PASSWORD: password + ports: [5432:5432] + + mssql: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + ACCEPT_EULA: Y + SA_PASSWORD: Forge123 + ports: [1434:1433] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + extensions: > + dom, curl, libxml, mbstring, zip, + pcntl, pdo, sqlite, pdo_sqlite, + pdo_mysql, pdo_pgsql, sqlsrv, pdo_sqlsrv, odbc, pdo_odbc + + - name: Prepare database ENV + run: | + if [[ "${{ matrix.database }}" == "sqlite" ]]; then + echo "DB_CONNECTION=sqlite" >> $GITHUB_ENV + echo "DB_DATABASE=:memory:" >> $GITHUB_ENV + fi + + if [[ "${{ matrix.database }}" == "mysql_57" ]]; then + echo "DB_CONNECTION=mysql" >> $GITHUB_ENV + echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV + echo "DB_PORT=3307" >> $GITHUB_ENV + echo "DB_USERNAME=root" >> $GITHUB_ENV + echo "DB_DATABASE=laravel" >> $GITHUB_ENV + fi + + if [[ "${{ matrix.database }}" == "mysql_8" ]]; then + echo "DB_CONNECTION=mysql" >> $GITHUB_ENV + echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV + echo "DB_PORT=3308" >> $GITHUB_ENV + echo "DB_USERNAME=root" >> $GITHUB_ENV + echo "DB_DATABASE=laravel" >> $GITHUB_ENV + fi + + if [[ "${{ matrix.database }}" == "mariadb" ]]; then + echo "DB_CONNECTION=mysql" >> $GITHUB_ENV + echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV + echo "DB_PORT=3309" >> $GITHUB_ENV + echo "DB_USERNAME=root" >> $GITHUB_ENV + echo "DB_DATABASE=laravel" >> $GITHUB_ENV + fi + + if [[ "${{ matrix.database }}" == "pgsql" ]]; then + echo "DB_CONNECTION=pgsql" >> $GITHUB_ENV + echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV + echo "DB_PORT=5433" >> $GITHUB_ENV + echo "DB_USERNAME=forge" >> $GITHUB_ENV + echo "DB_PASSWORD=password" >> $GITHUB_ENV + echo "DB_DATABASE=laravel" >> $GITHUB_ENV + fi + + if [[ "${{ matrix.database }}" == "mssql" ]]; then + echo "DB_CONNECTION=sqlsrv" >> $GITHUB_ENV + echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV + echo "DB_PORT=1434" >> $GITHUB_ENV + echo "DB_USERNAME=SA" >> $GITHUB_ENV + echo "DB_PASSWORD=Forge123" >> $GITHUB_ENV + echo "DB_DATABASE=master" >> $GITHUB_ENV + fi + + - name: Install SQL Server Tools (only for mssql) + if: matrix.database == 'mssql' + run: | + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev + echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: | + composer require \ + "laravel/framework:${{ matrix.laravel }}" \ + "orchestra/testbench:${{ matrix.testbench }}" \ + --no-interaction --no-update + composer update --prefer-dist --no-interaction + + - name: Run Tests + run: vendor/bin/phpunit diff --git a/.github/workflows/tests-for-databases.yml b/.github/workflows/tests-for-databases.yml deleted file mode 100644 index c57bea5..0000000 --- a/.github/workflows/tests-for-databases.yml +++ /dev/null @@ -1,254 +0,0 @@ -name: tests-for-databases - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -jobs: - mysql_57: - runs-on: ubuntu-24.04 - - services: - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: laravel - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - strategy: - fail-fast: true - - name: MySQL 5.7 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr - tools: composer:v2 - coverage: none - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Execute tests - run: vendor/bin/phpunit - env: - DB_CONNECTION: mysql - DB_COLLATION: utf8mb4_unicode_ci - - mysql_8: - runs-on: ubuntu-24.04 - - services: - mysql: - image: mysql:8 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: laravel - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - strategy: - fail-fast: true - - name: MySQL 8 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr - tools: composer:v2 - coverage: none - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Execute tests - run: vendor/bin/phpunit - env: - DB_CONNECTION: mysql - - mariadb: - runs-on: ubuntu-24.04 - - services: - mariadb: - image: mariadb:10 - env: - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes - MARIADB_DATABASE: laravel - ports: - - 3306:3306 - options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3 - - strategy: - fail-fast: true - - name: MariaDB 10 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr - tools: composer:v2 - coverage: none - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Execute tests - run: vendor/bin/phpunit - env: - DB_CONNECTION: mariadb - - pgsql: - runs-on: ubuntu-24.04 - - services: - postgresql: - image: postgres:14 - env: - POSTGRES_DB: laravel - POSTGRES_USER: forge - POSTGRES_PASSWORD: password - ports: - - 5432:5432 - options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 - - strategy: - fail-fast: true - - name: PostgreSQL 14 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, :php-psr - tools: composer:v2 - coverage: none - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Execute tests - run: vendor/bin/phpunit - env: - DB_CONNECTION: pgsql - DB_USERNAME: forge - DB_PASSWORD: password - - mssql: - runs-on: ubuntu-24.04 - - services: - sqlsrv: - image: mcr.microsoft.com/mssql/server:2019-latest - env: - ACCEPT_EULA: Y - SA_PASSWORD: Forge123 - ports: - - 1433:1433 - - name: SQL Server 2019 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlsrv, pdo, pdo_sqlsrv, odbc, pdo_odbc, :php-psr - tools: composer:v2 - coverage: none - - - name: Install SQL Server ODBC Driver and Tools - run: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev - echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Wait for SQL Server to be ready - run: | - echo "Waiting for SQL Server to start..." - for i in {1..30}; do - sqlcmd -S localhost -U SA -P Forge123 -Q "SELECT 1" -C && break - echo "SQL Server is starting up..." - sleep 2 - done - - - name: Execute tests - run: vendor/bin/phpunit - env: - DB_CONNECTION: sqlsrv - DB_HOST: localhost - DB_PORT: 1433 - DB_DATABASE: master - DB_USERNAME: SA - DB_PASSWORD: Forge123 - DB_ENCRYPT: true - DB_TRUST_SERVER_CERTIFICATE: true diff --git a/.github/workflows/tests-for-laravel-versions.yml b/.github/workflows/tests-for-laravel-versions.yml deleted file mode 100644 index 4f73444..0000000 --- a/.github/workflows/tests-for-laravel-versions.yml +++ /dev/null @@ -1,304 +0,0 @@ -name: tests-for-laravel-versions - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -jobs: - - test-laravel-12: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ ubuntu-latest ] - stability: [ prefer-stable ] - include: - - laravel: 12.* - testbench: 10.* - php: 8.4 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit - - test-laravel-11: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - stability: [prefer-stable] - include: - - laravel: 11.* - testbench: 9.* - php: 8.3 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit - - test-laravel-10: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - stability: [prefer-stable] - include: - - laravel: 10.* - testbench: 8.* - php: 8.2 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit - - test-laravel-9: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - stability: [prefer-stable] - include: - - laravel: 9.* - testbench: 7.* - php: 8.1 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit - - test-laravel-8: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - stability: [prefer-stable] - include: - - laravel: 8.* - testbench: 6.* - php: 8.0 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit - - test-laravel-7: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - stability: [prefer-stable] - include: - - laravel: 7.* - testbench: 5.* - php: 7.4 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit - - test-laravel-6: - runs-on: ${{ matrix.os }} - timeout-minutes: 5 - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - stability: [prefer-stable] - include: - - laravel: 6.* - testbench: 4.* - php: 7.4 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: List Installed Dependencies - run: composer show -D - - - name: Execute tests - run: vendor/bin/phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index 988ee6c..156a6c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to `model-required-fields` will be documented in this file. +## 3.2.1 - 2025-11-08 + +### What's Changed + +* chore: add new combined github action by @WatheqAlshowaiter in https://github.com/WatheqAlshowaiter/model-fields/pull/37 + +**Full Changelog**: https://github.com/WatheqAlshowaiter/model-fields/compare/3.2.0...3.2.1 + ## 3.2.0 - 2025-11-07 ### What's Changed diff --git a/README.md b/README.md index 706e56e..5500f5a 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ [![Required Laravel Version][ico-laravel]][link-packagist] [![Required PHP Version][ico-php]][link-packagist] [![Latest Version on Packagist][ico-version]][link-packagist] -![GitHub Tests For Laravel Versions Action Status][ico-tests-for-laravel-versions] -![GitHub Tests For Databases Action Status][ico-tests-for-databases] +![GitHub Test Matrix Action Status][ico-test-matrix] ![GitHub Code Style Action Status][ico-code-style] [![Total Downloads][ico-downloads]][link-downloads] ![GitHub Stars][ico-github-stars] @@ -23,9 +22,7 @@ [ico-code-style]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/model-fields/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square -[ico-tests-for-laravel-versions]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/model-fields/tests-for-laravel-versions.yml?branch=main&label=laravel%20versions%20tests&style=flat-square - -[ico-tests-for-databases]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/model-fields/tests-for-databases.yml?branch=main&label=databases%20tests&style=flat-square +[ico-test-matrix]: https://img.shields.io/github/actions/workflow/status/watheqalshowaiter/model-fields/test-matrix.yml?branch=main&label=tests&style=flat-square [ico-github-stars]: https://img.shields.io/github/stars/watheqalshowaiter/model-fields?style=flat-square diff --git a/tests/FieldsTest.php b/tests/FieldsTest.php index 0c28abc..af79a16 100644 --- a/tests/FieldsTest.php +++ b/tests/FieldsTest.php @@ -4,9 +4,7 @@ use BadMethodCallException; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\RefreshDatabase; -use Illuminate\Support\Facades\Schema; use ReflectionClass; use ReflectionException; use WatheqAlshowaiter\ModelFields\Exceptions\InvalidModelClassException; @@ -18,6 +16,7 @@ use WatheqAlshowaiter\ModelFields\Tests\Models\Someone; use WatheqAlshowaiter\ModelFields\Tests\Models\Son; use WatheqAlshowaiter\ModelFields\Tests\Models\Uncle; +use WatheqAlshowaiter\ModelFields\Tests\Models\WithOverride; class FieldsTest extends TestCase { @@ -39,28 +38,10 @@ public function test_get_required_fields_only_if_config_enabled_macro() public function test_macro_is_overridden_when_same_static_method_name_added() { - Schema::create('test_table', function ($table) { - $table->bigIncrements('id'); - $table->string('name'); - $table->timestamps(); - }); - - $testModelClass = new class extends Model - { - protected $table = 'test_table'; - - public static function requiredFields() - { - return [ - 'some_field', - ]; - } - }; - - $this->assertEquals(['some_field'], $testModelClass::requiredFields()); + $this->assertEquals(['some override text'], WithOverride::requiredFields()); // but other methods works fine - $this->assertEquals(['created_at', 'updated_at'], $testModelClass::nullableFields()); + $this->assertEquals(['created_at', 'updated_at'], WithOverride::nullableFields()); } public function test_throw_exception_if_model_is_not_extends_of_eloquent_model() diff --git a/tests/Models/WithOverride.php b/tests/Models/WithOverride.php new file mode 100644 index 0000000..d60109b --- /dev/null +++ b/tests/Models/WithOverride.php @@ -0,0 +1,15 @@ +bigIncrements('id'); + $table->string('name'); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('with_overrides'); + } +}