From a05bfd7f6160b13b2d039d9fae8651c71f7fb9fe Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 11:21:07 +0300 Subject: [PATCH 1/8] chore: add new combined github action --- .github/workflows/combined-tests.yml | 185 +++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 .github/workflows/combined-tests.yml diff --git a/.github/workflows/combined-tests.yml b/.github/workflows/combined-tests.yml new file mode 100644 index 0000000..92e3b8f --- /dev/null +++ b/.github/workflows/combined-tests.yml @@ -0,0 +1,185 @@ +name: tests-laravel-and-databases + +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 + - laravel: 12.* + testbench: 10.* + php: 8.4 + + # Laravel 11 + - laravel: 11.* + testbench: 9.* + php: 8.3 + + # Laravel 10 + - laravel: 10.* + testbench: 8.* + php: 8.2 + + # Laravel 9 + - laravel: 9.* + testbench: 7.* + php: 8.1 + + # Laravel 8 + - laravel: 8.* + testbench: 6.* + php: 8.0 + + # Laravel 7 + - laravel: 7.* + testbench: 5.* + php: 7.4 + + # Laravel 6 + - 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:15 + env: + POSTGRES_DB: laravel + POSTGRES_USER: forge + POSTGRES_PASSWORD: password + ports: [5433: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 From f0227a9598b43260d488d1b5d4f10265eb43c879 Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 11:47:28 +0300 Subject: [PATCH 2/8] debug: WIP github action --- .../workflows/combined-optimized-tests.yml | 185 ++++++++++++++++++ .github/workflows/combined-tests.yml | 2 +- 2 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/combined-optimized-tests.yml diff --git a/.github/workflows/combined-optimized-tests.yml b/.github/workflows/combined-optimized-tests.yml new file mode 100644 index 0000000..61c6f1f --- /dev/null +++ b/.github/workflows/combined-optimized-tests.yml @@ -0,0 +1,185 @@ +name: tests-laravel-and-databases-optimized + +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 + - laravel: 12.* + testbench: 10.* + php: 8.4 + + # Laravel 11 + - laravel: 11.* + testbench: 9.* + php: 8.3 + + # Laravel 10 + - laravel: 10.* + testbench: 8.* + php: 8.2 + + # Laravel 9 + - laravel: 9.* + testbench: 7.* + php: 8.1 + + # Laravel 8 + - laravel: 8.* + testbench: 6.* + php: 8.0 + + # Laravel 7 + - laravel: 7.* + testbench: 5.* + php: 7.4 + + # Laravel 6 + - 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:15 + env: + POSTGRES_DB: laravel + POSTGRES_USER: forge + POSTGRES_PASSWORD: password + ports: [5433: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/combined-tests.yml b/.github/workflows/combined-tests.yml index 92e3b8f..ca41861 100644 --- a/.github/workflows/combined-tests.yml +++ b/.github/workflows/combined-tests.yml @@ -89,7 +89,7 @@ jobs: ports: [3309:3306] pgsql: - image: postgres:15 + image: postgres:14 env: POSTGRES_DB: laravel POSTGRES_USER: forge From c7c62273d0293c8d7334502e5a33118b322ea6b8 Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 12:09:21 +0300 Subject: [PATCH 3/8] debug: WIP fix pgsql port in CI --- .github/workflows/combined-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/combined-tests.yml b/.github/workflows/combined-tests.yml index ca41861..441f7b5 100644 --- a/.github/workflows/combined-tests.yml +++ b/.github/workflows/combined-tests.yml @@ -94,7 +94,7 @@ jobs: POSTGRES_DB: laravel POSTGRES_USER: forge POSTGRES_PASSWORD: password - ports: [5433:5432] + ports: [5432:5432] mssql: image: mcr.microsoft.com/mssql/server:2019-latest From 37fc46bea987489075e9fb9bdb77927d8e5ebeda Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 12:12:05 +0300 Subject: [PATCH 4/8] debug: WIP stop unneeded tests in CI for now --- .github/workflows/fix-php-code-style-issues.yml | 2 +- .github/workflows/tests-for-databases.yml | 2 +- .github/workflows/tests-for-laravel-versions.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 2773652..3f934fb 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -4,7 +4,7 @@ on: push: branches: - main - pull_request: +# pull_request: workflow_dispatch: permissions: diff --git a/.github/workflows/tests-for-databases.yml b/.github/workflows/tests-for-databases.yml index c57bea5..662d4ba 100644 --- a/.github/workflows/tests-for-databases.yml +++ b/.github/workflows/tests-for-databases.yml @@ -4,7 +4,7 @@ on: push: branches: - main - pull_request: +# pull_request: workflow_dispatch: jobs: diff --git a/.github/workflows/tests-for-laravel-versions.yml b/.github/workflows/tests-for-laravel-versions.yml index 4f73444..6d44d0f 100644 --- a/.github/workflows/tests-for-laravel-versions.yml +++ b/.github/workflows/tests-for-laravel-versions.yml @@ -4,7 +4,7 @@ on: push: branches: - main - pull_request: +# pull_request: workflow_dispatch: jobs: From c4c684440305b6b4697ffa303f1651671573c8f4 Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 14:57:04 +0300 Subject: [PATCH 5/8] test: fix edge case for php8.0 in Laravel 8 and mysql --- .../workflows/combined-optimized-tests.yml | 185 ------------------ tests/FieldsTest.php | 25 +-- tests/Models/WithOverride.php | 15 ++ ..._07_100247_create_with_overrides_table.php | 23 +++ 4 files changed, 41 insertions(+), 207 deletions(-) delete mode 100644 .github/workflows/combined-optimized-tests.yml create mode 100644 tests/Models/WithOverride.php create mode 100644 tests/database/migrations/2025_11_07_100247_create_with_overrides_table.php diff --git a/.github/workflows/combined-optimized-tests.yml b/.github/workflows/combined-optimized-tests.yml deleted file mode 100644 index 61c6f1f..0000000 --- a/.github/workflows/combined-optimized-tests.yml +++ /dev/null @@ -1,185 +0,0 @@ -name: tests-laravel-and-databases-optimized - -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 - - laravel: 12.* - testbench: 10.* - php: 8.4 - - # Laravel 11 - - laravel: 11.* - testbench: 9.* - php: 8.3 - - # Laravel 10 - - laravel: 10.* - testbench: 8.* - php: 8.2 - - # Laravel 9 - - laravel: 9.* - testbench: 7.* - php: 8.1 - - # Laravel 8 - - laravel: 8.* - testbench: 6.* - php: 8.0 - - # Laravel 7 - - laravel: 7.* - testbench: 5.* - php: 7.4 - - # Laravel 6 - - 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:15 - env: - POSTGRES_DB: laravel - POSTGRES_USER: forge - POSTGRES_PASSWORD: password - ports: [5433: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/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'); + } +} From 8d0ca187f971a56ba5a0640f217597605d9cacce Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 15:28:01 +0300 Subject: [PATCH 6/8] chore(ci): consolidate workflows into test matrix - Renamed combined-tests.yml to test-matrix.yml for clarity - Removed redundant tests-for-databases.yml workflow - Removed redundant tests-for-laravel-versions.yml workflow - Cleaned up test matrix comments for better readability - Re-enabled pull_request trigger in code style workflow --- .../workflows/fix-php-code-style-issues.yml | 2 +- .../{combined-tests.yml => test-matrix.yml} | 9 +- .github/workflows/tests-for-databases.yml | 254 --------------- .../workflows/tests-for-laravel-versions.yml | 304 ------------------ 4 files changed, 2 insertions(+), 567 deletions(-) rename .github/workflows/{combined-tests.yml => test-matrix.yml} (96%) delete mode 100644 .github/workflows/tests-for-databases.yml delete mode 100644 .github/workflows/tests-for-laravel-versions.yml diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 3f934fb..2773652 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -4,7 +4,7 @@ on: push: branches: - main -# pull_request: + pull_request: workflow_dispatch: permissions: diff --git a/.github/workflows/combined-tests.yml b/.github/workflows/test-matrix.yml similarity index 96% rename from .github/workflows/combined-tests.yml rename to .github/workflows/test-matrix.yml index 441f7b5..4019df2 100644 --- a/.github/workflows/combined-tests.yml +++ b/.github/workflows/test-matrix.yml @@ -1,4 +1,4 @@ -name: tests-laravel-and-databases +name: Test Matrix on: push: @@ -17,37 +17,30 @@ jobs: laravel: [12.*, 11.*, 10.*, 9.*, 8.*, 7.*, 6.*] include: - # Laravel 12 - laravel: 12.* testbench: 10.* php: 8.4 - # Laravel 11 - laravel: 11.* testbench: 9.* php: 8.3 - # Laravel 10 - laravel: 10.* testbench: 8.* php: 8.2 - # Laravel 9 - laravel: 9.* testbench: 7.* php: 8.1 - # Laravel 8 - laravel: 8.* testbench: 6.* php: 8.0 - # Laravel 7 - laravel: 7.* testbench: 5.* php: 7.4 - # Laravel 6 - laravel: 6.* testbench: 4.* php: 7.4 diff --git a/.github/workflows/tests-for-databases.yml b/.github/workflows/tests-for-databases.yml deleted file mode 100644 index 662d4ba..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 6d44d0f..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 From 2dfe8c1d1b1317908aae6c7dbc147989f868ccd7 Mon Sep 17 00:00:00 2001 From: Watheq Alshowaiter Date: Sat, 8 Nov 2025 15:30:57 +0300 Subject: [PATCH 7/8] docs: update readme with new test badge --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 From 48b7786f8044d09522b98e3d008cc84b6640237f Mon Sep 17 00:00:00 2001 From: WatheqAlshowaiter <24838274+WatheqAlshowaiter@users.noreply.github.com> Date: Sat, 8 Nov 2025 12:42:51 +0000 Subject: [PATCH 8/8] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) 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