Skip to content

Commit 3268a45

Browse files
Trigger based sniffers
1 parent 985b5de commit 3268a45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1874
-484
lines changed

.env.Mysql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DB_DRIVER=Mysql
2+
DB_USER=root
3+
DB_PWD=root
4+
DB_HOST=localhost
5+
DB_DATABASE=test_suite_light

.env.Postgres

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DB_DRIVER=Postgres
2+
DB_USER=root
3+
DB_PWD=root
4+
DB_HOST=localhost
5+
DB_DATABASE=test_suite_light

.env.Sqlite

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DB_DRIVER=Sqlite
2+
DB_USER=root
3+
DB_PWD=root
4+
DB_HOST=localhost
5+
DB_DATABASE=test_suite_light

.github/workflows/php.yml

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
name: GitHub CI
2-
3-
on:
4-
push:
5-
branches:
6-
- '*'
7-
pull_request:
8-
branches:
9-
- '*'
10-
schedule:
11-
- cron: '0 0 * * 0'
12-
13-
jobs:
14-
build:
15-
runs-on: ubuntu-latest
16-
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
php-version: ['7.0', '7.2']
21-
db-type: [sqlite, mysql, pgsql]
22-
composer-type: [lowest, stable, dev]
23-
exclude:
24-
- php-version: '7.0'
25-
db-type: sqlite
26-
27-
name: PHP ${{ matrix.php-version }} & ${{ matrix.db-type }} & ${{ matrix.composer-type }}
28-
29-
services:
30-
postgres:
31-
image: postgres
32-
ports:
33-
- 5432:5432
34-
env:
35-
POSTGRES_DB: test_suite_light
36-
POSTGRES_PASSWORD: root
37-
POSTGRES_USER: root
38-
39-
steps:
40-
- uses: actions/checkout@v2
41-
42-
- name: Setup PHP
43-
uses: shivammathur/setup-php@v2
44-
with:
45-
php-version: ${{ matrix.php-version }}
46-
extensions: mbstring, intl, apcu, pdo_${{ matrix.db-type }}
47-
ini-values: apc.enable_cli = 1
48-
49-
- name: Update composer
50-
run: composer self-update
51-
52-
- name: Validate composer.json
53-
run: composer validate
54-
55-
- name: Install dependencies
56-
run: |
57-
if [[ ${{ matrix.composer-type }} == 'lowest' ]]; then
58-
composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest
59-
elif [[ ${{ matrix.composer-type }} == 'stable' ]]; then
60-
composer update --prefer-dist --no-progress --no-suggest --prefer-stable
61-
else
62-
composer update --prefer-dist --no-progress --no-suggest
63-
fi
64-
65-
- name: Run tests
66-
run: |
67-
if [ ${{ matrix.db-type }} == 'mysql' ]; then
68-
sudo service mysql start && mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE IF NOT EXISTS test_suite_light;';
69-
fi
70-
composer run-tests-${{ matrix.db-type }} root root
1+
name: GitHub CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
schedule:
11+
- cron: '0 0 * * 0'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php-version: ['7.0', '7.2']
21+
db-type: [sqlite, mysql, pgsql]
22+
composer-type: [lowest, stable, dev]
23+
exclude:
24+
- php-version: '7.0'
25+
db-type: sqlite
26+
27+
name: PHP ${{ matrix.php-version }} & ${{ matrix.db-type }} & ${{ matrix.composer-type }}
28+
29+
services:
30+
postgres:
31+
image: postgres
32+
ports:
33+
- 5432:5432
34+
env:
35+
POSTGRES_DB: test_suite_light
36+
POSTGRES_PASSWORD: root
37+
POSTGRES_USER: root
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
42+
- name: Setup PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php-version }}
46+
extensions: mbstring, intl, apcu, pdo_${{ matrix.db-type }}
47+
ini-values: apc.enable_cli = 1
48+
49+
- name: Update composer
50+
run: composer self-update
51+
52+
- name: Validate composer.json
53+
run: composer validate
54+
55+
- name: Install dependencies
56+
run: |
57+
if [[ ${{ matrix.composer-type }} == 'lowest' ]]; then
58+
composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest
59+
elif [[ ${{ matrix.composer-type }} == 'stable' ]]; then
60+
composer update --prefer-dist --no-progress --no-suggest --prefer-stable
61+
else
62+
composer update --prefer-dist --no-progress --no-suggest
63+
fi
64+
65+
- name: Run tests
66+
run: |
67+
if [ ${{ matrix.db-type }} == 'mysql' ]; then
68+
sudo service mysql start && mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE IF NOT EXISTS test_suite_light;';
69+
fi
70+
composer run-tests-${{ matrix.db-type }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dummy_database
55
composer.lock
66
/.phpunit.result.cache
77
/tmp/
8+
.env

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
"minimum-stability": "dev",
1818
"require": {
1919
"php": ">=7.0",
20-
"cakephp/cakephp": "^3.6"
20+
"cakephp/cakephp": "^3.7",
21+
"ext-pdo": "*"
2122
},
2223
"require-dev": {
24+
"cakephp/migrations": "^2.3",
25+
"josegonzalez/dotenv": "dev-master",
2326
"phpunit/phpunit": "^6.1"
2427
},
2528
"autoload": {
@@ -30,7 +33,8 @@
3033
"autoload-dev": {
3134
"psr-4": {
3235
"CakephpTestSuiteLight\\Test\\": "tests",
33-
"TestApp\\": "tests/TestApp/src"
36+
"TestApp\\": "tests/TestApp/src",
37+
"TestApp\\Test\\": "tests/TestApp/tests"
3438
}
3539
},
3640
"scripts": {

run_tests.sh

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,9 @@
11
#!/bin/bash
22

33
DRIVER=$1;
4-
USER=$2;
5-
PWD=$3;
6-
DRIVER_NAMESPACE='Cake\Database\Driver\'
74

85
echo "Starting PHPUNIT tests"
9-
10-
if [ -n "$DRIVER" ]; then
11-
DRIVER="$DRIVER_NAMESPACE$DRIVER"
12-
export DB_DRIVER=$DRIVER
13-
echo "With driver: $DRIVER"
14-
else
15-
echo "Using default driver $DB_DRIVER"
16-
fi
17-
18-
if [ -n "$USER" ]; then
19-
export DB_USER=$USER
20-
echo "With user: $USER"
21-
else
22-
echo "Using default user $DB_USER"
23-
fi
24-
25-
if [ -n "$PWD" ]; then
26-
export DB_PWD=$PWD
27-
echo "With password: $PWD"
28-
else
29-
echo "Using default password $DB_PWD"
30-
fi
6+
export DB_DRIVER=$DRIVER
317

328
# Test Cases where tables get dropped are put separately,
339
# since they are giving a hard time to the fixtures
@@ -38,3 +14,10 @@ fi
3814
./vendor/bin/phpunit --testsuite DropCountries --stop-on-fail
3915
./vendor/bin/phpunit --testsuite DropTables --stop-on-fail
4016

17+
# Run the tests again using non-triggered based sniffers
18+
export TABLE_SNIFFER="CakephpTestSuiteLight\Sniffer\\${DRIVER}TableSniffer"
19+
20+
./vendor/bin/phpunit --testsuite Default --stop-on-fail
21+
./vendor/bin/phpunit --testsuite DropCities --stop-on-fail
22+
./vendor/bin/phpunit --testsuite DropCountries --stop-on-fail
23+
./vendor/bin/phpunit --testsuite DropTables --stop-on-fail

src/FixtureInjector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ class FixtureInjector extends \Cake\TestSuite\Fixture\FixtureInjector
3737
public function __construct(FixtureManager $manager, bool $withStatistics = false)
3838
{
3939
$this->_fixtureManager = $manager;
40-
$this->_fixtureManager
41-
->collectDirtyTables()
42-
->truncateDirtyTables();
4340
$this->statisticTool = new StatisticTool($manager, $withStatistics);
4441
}
4542

@@ -85,7 +82,6 @@ public function startTest(Test $test)
8582
*/
8683
public function endTest(Test $test, $time)
8784
{
88-
$this->_fixtureManager->collectDirtyTables();
8985
$this->statisticTool->collectTestStatistics($test, $time);
9086
}
9187

0 commit comments

Comments
 (0)