Skip to content

Tests #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
28a64c9
tests: improvements
May 7, 2025
9caf954
build: updated dependencies
May 7, 2025
302027f
ci: new tests
May 7, 2025
87016fe
ci: new tests
May 7, 2025
adcfab6
ci: new tests
May 7, 2025
bd0eae2
ci: new tests
May 7, 2025
0b3e660
ci: new tests
May 7, 2025
fbac459
ci: new tests
May 7, 2025
8ae7fd3
ci: new tests
May 7, 2025
330524c
ci: new tests
May 7, 2025
560344a
ci: new tests
May 7, 2025
7eb7219
ci: new tests
May 7, 2025
4153264
ci: new tests
May 7, 2025
05702db
ci: new tests
May 7, 2025
0f58a11
ci: new tests
May 7, 2025
ed8309c
ci: new tests
May 7, 2025
86cab8a
ci: new tests
May 7, 2025
5efdab9
ci: new tests
May 7, 2025
9b5691d
ci: new tests
May 7, 2025
4c5b3c0
ci: new tests
May 7, 2025
aa68f0e
tests: improvements
May 7, 2025
4c5806f
ci: new tests
May 7, 2025
6b2b020
ci: new tests
May 7, 2025
0f57e4e
ci: new tests
May 7, 2025
d603f81
ci: new tests
May 7, 2025
cd26ea9
ci: new tests
May 7, 2025
ec045a2
ci: new tests
May 7, 2025
8b7a5fc
build: updated dependencies
May 8, 2025
6bc81b1
tests: changed namespace
May 8, 2025
6865bd2
tests: changed namespace
May 8, 2025
a67c5ee
ci:
May 8, 2025
b26b21a
tests: improvements
May 8, 2025
442dbca
ci: new tests
May 8, 2025
443ae8a
ci: new tests
May 8, 2025
7b7b172
ci: new tests
May 8, 2025
e98e694
tests: improvements
May 8, 2025
5ef69a2
tests: improvements
May 8, 2025
602ab6e
tests: improvements
May 8, 2025
32e23b0
tests: improvements
May 8, 2025
9e4e10a
ci: new tests
May 8, 2025
1d635ab
ci: new tests
May 8, 2025
da233f2
ci: new tests
May 8, 2025
4c23f25
ci: new tests
May 8, 2025
8905b38
ci: new tests
May 8, 2025
450b804
ci: new tests
May 8, 2025
aa5fbcc
ci: new tests
May 8, 2025
4562e47
ci: new tests
May 8, 2025
aa32137
ci: new tests
May 8, 2025
d3dc2cb
ci: new tests
May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 151 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,157 @@ jobs:
echo "MYSQL_PORT=3306" >> .env

- name: Run Tests
run: ./vendor/bin/phpunit --testdox
run: make run-tests

phpunit-with-laravel:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- laravel: 8.*
php: 8.0
- laravel: 9.*
php: 8.0
- laravel: 10.*
php: 8.1
- laravel: 11.*
php: 8.2
- laravel: 11.*
php: 8.3
- laravel: 11.*
php: 8.4
- laravel: 12.*
php: 8.2
- laravel: 12.*
php: 8.3
- laravel: 12.*
php: 8.4
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_db
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
postgres:
image: postgres:14
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, pdo, mysql, pgsql
coverage: none

- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}

- name: Checkout PR
uses: actions/checkout@v4

- name: Preparing Laravel project
run: |
cd ${{ runner.workspace }}
composer create-project --prefer-dist laravel/laravel laravel ${{ matrix.laravel }}
cd ${{ runner.workspace }}/laravel
composer config repositories.local path ${{ runner.workspace }}/laravel-bulk-upsert
composer require lapaliv/laravel-bulk-upsert:@dev
echo "DB_HOST=127.0.0.1" >> .env
echo "DB_DATABASE=test_db" >> .env
echo "DB_USERNAME=test_user" >> .env
echo "DB_PASSWORD=test_password" >> .env
php artisan key:generate
cp .env .env.testing
mv ${{ runner.workspace }}/laravel/tests/Unit ${{ runner.workspace }}/laravel/tests/Unit_old
cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/App ${{ runner.workspace }}/laravel/tests/
cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/Database ${{ runner.workspace }}/laravel/tests/
cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/Unit ${{ runner.workspace }}/laravel/tests/
cp -r ${{ runner.workspace }}/laravel-bulk-upsert/tests/TestCaseWrapper.php ${{ runner.workspace }}/laravel/tests/
sed -i '/^[[:space:]]*<env name="DB_CONNECTION" value="/d' phpunit.xml
sed -i '/^[[:space:]]*<env name="DB_DATABASE" value="/d' phpunit.xml

- name: Wait for MySQL
run: |
echo "Waiting for MySQL..."
until mysqladmin ping -h 127.0.0.1 --silent; do
sleep 2
done
echo "MySQL is up!"

- name: Preparing MySQL
run: |
cd ${{ runner.workspace }}/laravel
sed -i 's/^DB_CONNECTION=.*/# &/' .env
sed -i 's/^DB_CONNECTION=.*/# &/' .env.testing
echo "DB_CONNECTION=mysql" >> .env
echo "DB_CONNECTION=mysql" >> .env.testing
php artisan config:show database.default

- name: Run tests (MySQL)
run: |
cd ${{ runner.workspace }}/laravel
./vendor/bin/phpunit

- name: Wait for PostgreSQL
run: |
echo "Waiting for PostgreSQL..."
until pg_isready -h 127.0.0.1 -p 5432; do
sleep 2
done
echo "PostgreSQL is up!"

- name: Preparing PostgreSQL
run: |
cd ${{ runner.workspace }}/laravel
sed -i 's/^DB_CONNECTION=.*/# &/' .env
sed -i 's/^DB_CONNECTION=.*/# &/' .env.testing
echo "DB_CONNECTION=pgsql" >> .env
echo "DB_CONNECTION=pgsql" >> .env.testing
php artisan config:show database.default

- name: Run tests (PostgreSQL)
run: |
cd ${{ runner.workspace }}/laravel
./vendor/bin/phpunit

- name: Preparing SQLite
run: |
cd ${{ runner.workspace }}/laravel
sed -i 's/^DB_CONNECTION=.*/# &/' .env
sed -i 's/^DB_CONNECTION=.*/# &/' .env.testing
sed -i 's/^DB_DATABASE=.*/# &/' .env
sed -i 's/^DB_DATABASE=.*/# &/' .env.testing
echo "DB_CONNECTION=sqlite" >> .env
echo "DB_CONNECTION=sqlite" >> .env.testing
rm ${{ runner.workspace }}/laravel/database/migrations/*
php artisan config:show database.default

- name: Run tests (SQLite)
run: |
cd ${{ runner.workspace }}/laravel
./vendor/bin/phpunit


psalm:
runs-on: ubuntu-22.04
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
run-mysql-tests:
env DB_CONNECTION=mysql DB_HOST=${MYSQL_HOST} DB_PORT=${MYSQL_PORT} DB_DATABASE=${MYSQL_DATABASE} DB_USERNAME=${MYSQL_USERNAME} DB_PASSWORD=${MYSQL_PASSWORD} ./vendor/bin/phpunit

run-pgsql-tests:
env DB_CONNECTION=pgsql DB_HOST=${POSTGRESQL_HOST} DB_PORT=${POSTGRESQL_PORT} DB_DATABASE=${POSTGRESQL_DATABASE} DB_USERNAME=${POSTGRESQL_USERNAME} DB_PASSWORD=${POSTGRESQL_PASSWORD} ./vendor/bin/phpunit

run-sqlite-tests:
env DB_CONNECTION=sqlite ./vendor/bin/phpunit

run-tests:
$(MAKE) run-mysql-tests && $(MAKE) run-pgsql-tests && $(MAKE) run-sqlite-tests
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
},
"autoload-dev": {
"psr-4": {
"Lapaliv\\BulkUpsert\\Tests\\": "tests",
"Lapaliv\\BulkUpsert\\Tests\\App\\": "tests/app"
"Tests\\": "tests"
}
},
"authors": [
Expand All @@ -40,7 +39,7 @@
"friendsofphp/php-cs-fixer": "^3.13",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.0|^10.0",
"vimeo/psalm": "^5.13",
"vimeo/psalm": "^6.10",
"vlucas/phpdotenv": "^5.6"
},
"extra": {
Expand Down
Loading
Loading