Skip to content

Add unit tests for "SqlServerDriver" #74

Add unit tests for "SqlServerDriver"

Add unit tests for "SqlServerDriver" #74

Workflow file for this run

on:
push:
branches: [ 'master' ]
pull_request:
branches: [ 'master' ]
permissions:
contents: read
jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ '5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
name: Run Unit Test on PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create the MySQL server
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: '5.7'
- name: Check the MySQL version
run: mysql -uroot -e 'SELECT version();'
- name: Create the MySQL database
run: |
mysql -uroot -e 'CREATE DATABASE IF NOT EXISTS dscb;'
mysql -uroot -e 'USE dscb; CREATE TABLE IF NOT EXISTS `post` (`id` int(10) NOT NULL AUTO_INCREMENT, `subject` varchar(100) NOT NULL, `message` varchar(500) NOT NULL, `resu_id` int(10) NOT NULL, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `description` (`description`), KEY `resu_id` (`resu_id`)) AUTO_INCREMENT=1;'
mysql -uroot -e 'USE dscb; CREATE TABLE IF NOT EXISTS `resu` (`id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(200) NOT NULL, `age` int(2) NOT NULL, `gender` varchar(10) NOT NULL, PRIMARY KEY (`id`)) AUTO_INCREMENT=1;'
mysql -uroot -e 'USE dscb; ALTER TABLE `post` ADD CONSTRAINT `post_resu_id_foreign` FOREIGN KEY (`resu_id`) REFERENCES `resu` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;'
mysql -uroot -e 'CREATE USER dscb@"%" IDENTIFIED BY "dscb";'
mysql -uroot -e 'GRANT ALL PRIVILEGES ON dscb.* TO "dscb"@"%"; FLUSH PRIVILEGES;'
- name: Create the MSSQL server
uses: potatoqualitee/mssqlsuite@v1.7
with:
install: sqlengine, sqlpackage
- name: Create the MSSQL database
run: |
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q 'CREATE TABLE resu (id INT NOT NULL PRIMARY KEY, name VARCHAR(200) NOT NULL, age INT NOT NULL, gender VARCHAR(10) NOT NULL);'
sqlcmd -S localhost -U sa -P dbatools.I0 -d tempdb -Q 'CREATE TABLE post (id INT NOT NULL PRIMARY KEY, subject VARCHAR(100) NOT NULL, message VARCHAR(500) NOT NULL, resu_id INT NOT NULL, description VARCHAR(100) NULL, FOREIGN KEY (resu_id) REFERENCES resu (id));'
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: sqlsrv
- name: Check the PHP version
run: php -v
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
run: vendor/bin/phpunit --coverage-clover=coverage.clover --testdox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4-beta
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}