diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..3e25318 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,63 @@ +name: PHPUnit + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' # ← Changed from '8.3' to '8.4' + extensions: xdebug + coverage: xdebug # ← Explicitly enable coverage driver + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Download PHPUnit PHAR + run: | + wget https://phar.phpunit.de/phpunit.phar + chmod +x phpunit.phar + mv phpunit.phar /usr/local/bin/phpunit + + - name: Check PHPUnit version + run: phpunit --version + + - name: Run PHPUnit tests with coverage + run: | + mkdir -p build/logs + phpunit --configuration phpunit.xml --coverage-clover build/logs/clover.xml --debug + env: + XDEBUG_MODE: coverage + + - name: Send coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: build/logs/clover.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index fa02bc1..d9c2f91 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /vendor/ /composer.lock /.phpunit.cache/ -/.phpunit.result.cache \ No newline at end of file +/.phpunit.result.cache +/nbproject/ diff --git a/README.md b/README.md index 357f653..bbc8f62 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/Jagepard/Rudra-Model.svg?branch=master)](https://travis-ci.org/Jagepard/Rudra-Model) +[![PHPunit](https://github.com/Jagepard/Rudra-Model/actions/workflows/php.yml/badge.svg)](https://github.com/Jagepard/Rudra-Model/actions/workflows/php.yml) [![Maintainability](https://qlty.sh/badges/ca8bb591-ff66-41c3-8f18-4d4a93b3ee41/maintainability.svg)](https://qlty.sh/gh/Jagepard/projects/Rudra-Model) [![CodeFactor](https://www.codefactor.io/repository/github/jagepard/rudra-model/badge)](https://www.codefactor.io/repository/github/jagepard/rudra-model) [![Coverage Status](https://coveralls.io/repos/github/Jagepard/Rudra-Model/badge.svg?branch=master)](https://coveralls.io/github/Jagepard/Rudra-Model?branch=master) diff --git a/src/Repository.php b/src/Repository.php index 38c3a95..25be46d 100755 --- a/src/Repository.php +++ b/src/Repository.php @@ -225,7 +225,7 @@ protected static function updateStmtString(array $fields): string { $stmtFields = []; - foreach ($fields as $key => $data) { + foreach (array_keys($fields) as $key) { $stmtFields[] = "{$key}=:{$key}"; } @@ -238,14 +238,14 @@ protected static function updateStmtString(array $fields): string * - A list of column names. * - A list of placeholders (prefixed with colons) for parameter binding. * These strings can be directly used in the SQL INSERT query. - */ + */ protected static function createStmtString(array $fields): array { $insert = []; $execute = []; - foreach ($fields as $key => $data) { - $insert[] = "{$key}"; + foreach (array_keys($fields) as $key) { + $insert[] = $key; $execute[] = ":{$key}"; }