Skip to content

Commit 5122b9a

Browse files
committed
Test in PHP 8.1 & Laravel 9.0
1 parent b0e86e8 commit 5122b9a

File tree

7 files changed

+51
-90
lines changed

7 files changed

+51
-90
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,20 @@ jobs:
2424
2525
strategy:
2626
matrix:
27-
php: [7.1, 7.2, 7.3, 7.4, 8.0]
27+
php: [7.3, 7.4, '8.0', 8.1]
2828
lib:
29-
- { laravel: ^8.0, testbench: ^6.0, composer_flags: --prefer-stable }
30-
- { laravel: ^7.0, testbench: ^5.0, composer_flags: --prefer-stable }
31-
- { laravel: ^6.0, testbench: ^4.0, composer_flags: --prefer-stable }
32-
- { laravel: ^6.0, testbench: ^4.0, composer_flags: --prefer-stable --prefer-lowest }
33-
- { laravel: 5.8.*, testbench: 3.8.*, composer_flags: --prefer-stable }
29+
- { laravel: ^9.0 }
30+
- { laravel: ^8.0 }
31+
- { laravel: ^7.0 }
32+
- { laravel: ^6.0 }
33+
- { laravel: ^6.0, flags: --prefer-lowest }
3434
exclude:
35-
- lib: { laravel: ^8.0, testbench: ^6.0, composer_flags: --prefer-stable }
36-
php: 7.2
37-
- lib: { laravel: ^8.0, testbench: ^6.0, composer_flags: --prefer-stable }
38-
php: 7.1
39-
- lib: { laravel: ^7.0, testbench: ^5.0, composer_flags: --prefer-stable }
40-
php: 7.1
41-
- lib: { laravel: ^6.0, testbench: ^4.0, composer_flags: --prefer-stable }
42-
php: 7.1
43-
- lib: { laravel: ^6.0, testbench: ^4.0, composer_flags: --prefer-stable --prefer-lowest }
44-
php: 7.1
45-
- lib: { laravel: 5.8.*, testbench: 3.8.*, composer_flags: --prefer-stable }
46-
php: 8.0
47-
- lib: { laravel: 5.7.*, testbench: 3.7.*, composer_flags: --prefer-stable }
48-
php: 8.0
49-
- lib: { laravel: 5.6.*, testbench: 3.6.*, composer_flags: --prefer-stable }
50-
php: 8.0
35+
- { php: 8.1, lib: { laravel: ^7.0 } }
36+
- { php: 8.1, lib: { laravel: ^6.0 } }
37+
- { php: 8.1, lib: { laravel: ^6.0, flags: --prefer-lowest } }
38+
- { php: '8.0', lib: { laravel: ^6.0, flags: --prefer-lowest } }
39+
- { php: 7.4, lib: { laravel: ^9.0 } }
40+
- { php: 7.3, lib: { laravel: ^9.0 } }
5141

5242
steps:
5343
- uses: actions/checkout@v2
@@ -60,14 +50,7 @@ jobs:
6050

6151
- name: Adjust Package Versions
6252
run: |
63-
composer require "laravel/framework:${{ matrix.lib.laravel }}" --dev --no-update ${{ matrix.lib.composer_flags }}
64-
if php -r 'exit((int)!version_compare(PHP_VERSION, "8", ">="));'; then
65-
composer require "orchestra/testbench:>=4.14" --dev --no-update ${{ matrix.lib.composer_flags }}
66-
composer require "phpunit/phpunit:>=9.3" --dev --no-update ${{ matrix.lib.composer_flags }}
67-
else
68-
composer require "orchestra/testbench:${{ matrix.lib.testbench }}" --dev --no-update ${{ matrix.lib.composer_flags }}
69-
fi
70-
composer update ${{ matrix.lib.composer_flags }}
53+
composer require "laravel/framework:${{ matrix.lib.laravel }}" --dev ${{ matrix.lib.flags }}
7154
7255
- run: mkdir -p build/logs
7356
- run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml

.php_cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ A tiny extension of `MySqlConnection` that manages **session** system variables
44

55
## Requirements
66

7-
- PHP: `^7.1 || ^8.0`
8-
- Laravel: `^5.8 || ^6.0 || ^7.0 || ^8.0`
7+
- PHP: `^7.3 || ^8.0`
8+
- Laravel: `^6.0 || ^7.0 || ^8.0 || ^9.0`
99

1010
## Installing
1111

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
}
2222
},
2323
"require": {
24-
"php": "^7.1 || ^8.0",
24+
"php": "^7.3 || ^8.0",
2525
"ext-pdo": "*",
26-
"illuminate/support": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
27-
"illuminate/database": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
26+
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0",
27+
"illuminate/database": "^6.0 || ^7.0 || ^8.0 || ^9.0",
2828
"mpyw/unclosure": "^1.0",
2929
"mpyw/laravel-pdo-emulation-control": "^1.0"
3030
},
3131
"require-dev": {
32-
"orchestra/testbench": "^6.0",
33-
"friendsofphp/php-cs-fixer": "^2.15"
34-
}
32+
"orchestra/testbench": "*"
33+
},
34+
"minimum-stability": "dev",
35+
"prefer-stable": true
3536
}

tests/BasicVariableAssignmentTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,35 @@ public function provideBasicVariables(): array
5454
{
5555
return [
5656
'assigning float (native)' => ['long_query_time', false, 10.0, 15.0, 15.0],
57-
'assigning float (emulated)' => ['long_query_time', true, '10.000000', 15.0, '15.000000'],
57+
'assigning float (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), 15.0, $this->v81('15.000000', 15.0)],
5858
'assigning integer (native)' => ['long_query_time', false, 10.0, 15, 15.0],
59-
'assigning integer (emulated)' => ['long_query_time', true, '10.000000', 15, '15.000000'],
59+
'assigning integer (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), 15, $this->v81('15.000000', 15.0)],
6060
'assigning boolean (native)' => ['foreign_key_checks', false, 1, false, 0],
61-
'assigning boolean (emulated)' => ['foreign_key_checks', true, '1', false, '0'],
61+
'assigning boolean (emulated)' => ['foreign_key_checks', true, $this->v81('1', 1), false, $this->v81('0', 0)],
6262
'assigning string (native)' => ['tx_isolation', false, 'REPEATABLE-READ', 'read-committed', 'READ-COMMITTED'],
6363
'assigning string (emulated)' => ['tx_isolation', true, 'REPEATABLE-READ', 'read-committed', 'READ-COMMITTED'],
6464
'assigning wrapped float (native)' => ['long_query_time', false, 10.0, Value::float(15.0), 15.0],
65-
'assigning wrapped float (emulated)' => ['long_query_time', true, '10.000000', Value::float(15.0), '15.000000'],
65+
'assigning wrapped float (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), Value::float(15.0), $this->v81('15.000000', 15.0)],
6666
'assigning wrapped integer (native)' => ['long_query_time', false, 10.0, Value::int(15), 15.0],
67-
'assigning wrapped integer (emulated)' => ['long_query_time', true, '10.000000', Value::int(15), '15.000000'],
67+
'assigning wrapped integer (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), Value::int(15), $this->v81('15.000000', 15.0)],
6868
'assigning wrapped boolean (native)' => ['foreign_key_checks', false, 1, Value::bool(false), 0],
69-
'assigning wrapped boolean (emulated)' => ['foreign_key_checks', true, '1', Value::bool(false), '0'],
69+
'assigning wrapped boolean (emulated)' => ['foreign_key_checks', true, $this->v81('1', 1), Value::bool(false), $this->v81('0', 0)],
7070
'assigning wrapped string (native)' => ['tx_isolation', false, 'REPEATABLE-READ', Value::str('read-committed'), 'READ-COMMITTED'],
7171
'assigning wrapped string (emulated)' => ['tx_isolation', true, 'REPEATABLE-READ', Value::str('read-committed'), 'READ-COMMITTED'],
7272
'replacing explicit float (native)' => ['long_query_time', false, 10.0, Replacer::float(function ($v) { return $v + 5.0; }), 15.0],
73-
'replacing explicit float (emulated)' => ['long_query_time', true, '10.000000', Replacer::float(function ($v) { return $v + 5.0; }), '15.000000'],
73+
'replacing explicit float (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), Replacer::float(function ($v) { return $v + 5.0; }), $this->v81('15.000000', 15.0)],
7474
'replacing explicit integer (native)' => ['long_query_time', false, 10.0, Replacer::int(function ($v) { return $v + 5; }), 15.0],
75-
'replacing explicit integer (emulated)' => ['long_query_time', true, '10.000000', Replacer::int(function ($v) { return $v + 5; }), '15.000000'],
75+
'replacing explicit integer (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), Replacer::int(function ($v) { return $v + 5; }), $this->v81('15.000000', 15.0)],
7676
'replacing explicit boolean (native)' => ['foreign_key_checks', false, 1, Replacer::bool(function ($v) { return !$v; }), 0],
77-
'replacing explicit boolean (emulated)' => ['foreign_key_checks', true, '1', Replacer::bool(function ($v) { return !$v; }), '0'],
77+
'replacing explicit boolean (emulated)' => ['foreign_key_checks', true, $this->v81('1', 1), Replacer::bool(function ($v) { return !$v; }), $this->v81('0', 0)],
7878
'replacing explicit string (native)' => ['tx_isolation', false, 'REPEATABLE-READ', Replacer::str(function ($v) { return str_ireplace('repeatable-read', 'read-committed', $v); }), 'READ-COMMITTED'],
7979
'replacing explicit string (emulated)' => ['tx_isolation', true, 'REPEATABLE-READ', Replacer::str(function ($v) { return str_ireplace('repeatable-read', 'read-committed', $v); }), 'READ-COMMITTED'],
8080
'replacing implicit float (native)' => ['long_query_time', false, 10.0, function ($v): float { return $v + 5.0; }, 15.0],
81-
'replacing implicit float (emulated)' => ['long_query_time', true, '10.000000', function ($v): float { return $v + 5.0; }, '15.000000'],
81+
'replacing implicit float (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), function ($v): float { return $v + 5.0; }, $this->v81('15.000000', 15.0)],
8282
'replacing implicit integer (native)' => ['long_query_time', false, 10.0, function ($v): int { return $v + 5; }, 15.0],
83-
'replacing implicit integer (emulated)' => ['long_query_time', true, '10.000000', function ($v): int { return $v + 5; }, '15.000000'],
83+
'replacing implicit integer (emulated)' => ['long_query_time', true, $this->v81('10.000000', 10.0), function ($v): int { return $v + 5; }, $this->v81('15.000000', 15.0)],
8484
'replacing implicit boolean (native)' => ['foreign_key_checks', false, 1, function ($v): bool { return !$v; }, 0],
85-
'replacing implicit boolean (emulated)' => ['foreign_key_checks', true, '1', function ($v): bool { return !$v; }, '0'],
85+
'replacing implicit boolean (emulated)' => ['foreign_key_checks', true, $this->v81('1', 1), function ($v): bool { return !$v; }, $this->v81('0', 0)],
8686
'replacing implicit string (native)' => ['tx_isolation', false, 'REPEATABLE-READ', function ($v): string { return str_ireplace('repeatable-read', 'read-committed', $v); }, 'READ-COMMITTED'],
8787
'replacing implicit string (emulated)' => ['tx_isolation', true, 'REPEATABLE-READ', function ($v): string { return str_ireplace('repeatable-read', 'read-committed', $v); }, 'READ-COMMITTED'],
8888
];
@@ -165,7 +165,7 @@ public function testAssignmentPriorityOnLazilyResolvedConnection(): void
165165

166166
$this->assertPdoResolved($db->getName());
167167

168-
$this->assertSame('13.000000', $db->selectOne('select @@long_query_time as value')->value);
168+
$this->assertSame($this->v81('13.000000', 13.0), $db->selectOne('select @@long_query_time as value')->value);
169169

170170
$this->assertPdoResolved($db->getName());
171171
});
@@ -206,7 +206,7 @@ public function testAssignmentPriorityOnEagerlyResolvedConnection(): void
206206

207207
$this->assertPdoResolved($db->getName());
208208

209-
$this->assertSame('13.000000', $db->selectOne('select @@long_query_time as value')->value);
209+
$this->assertSame($this->v81('13.000000', 13.0), $db->selectOne('select @@long_query_time as value')->value);
210210

211211
$this->assertPdoResolved($db->getName());
212212
});

tests/ReconnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testOnlyMemoizedVariablesAreReassigned(): void
2525

2626
$this->onEmulatedConnection(function (MySqlConnection $db) {
2727
$this->assertSame('REPEATABLE-READ', $db->selectOne('select @@tx_isolation as value')->value);
28-
$this->assertSame('10.000000', $db->selectOne('select @@long_query_time as value')->value);
28+
$this->assertSame($this->v81('10.000000', 10.0), $db->selectOne('select @@long_query_time as value')->value);
2929

3030
$db
3131
->setSystemVariable('tx_isolation', 'read-committed')
@@ -34,7 +34,7 @@ public function testOnlyMemoizedVariablesAreReassigned(): void
3434
$db->reconnect();
3535

3636
$this->assertSame('READ-COMMITTED', $db->selectOne('select @@tx_isolation as value')->value);
37-
$this->assertSame('10.000000', $db->selectOne('select @@long_query_time as value')->value);
37+
$this->assertSame($this->v81('10.000000', 10.0), $db->selectOne('select @@long_query_time as value')->value);
3838
});
3939
}
4040

tests/TestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,17 @@ protected function assertPdoNotResolved(string $connection): void
8181
{
8282
$this->assertInstanceOf(Closure::class, $this->getConnectionPropertyValue($connection, 'pdo'));
8383
}
84+
85+
/**
86+
* @param mixed $v80
87+
* @param mixed $v81
88+
* @return mixed
89+
*/
90+
protected function v81($v80, $v81)
91+
{
92+
// Since PHP 8.1, always get native number regardless of emulation.
93+
return version_compare(PHP_VERSION, '8.1', '<')
94+
? $v80
95+
: $v81;
96+
}
8497
}

0 commit comments

Comments
 (0)