Skip to content

Commit a84070d

Browse files
[11.x] CI Improvements (#52851)
* [11.x] CI Improvements Re-enable SQL Server 2017 Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: StyleCI Bot <[email protected]>
1 parent 84540bd commit a84070d

23 files changed

+138
-213
lines changed

.github/workflows/databases.yml

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ jobs:
247247

248248
mssql_2019:
249249
runs-on: ubuntu-22.04
250+
timeout-minutes: 5
250251

251252
services:
252253
sqlsrv:
@@ -292,52 +293,53 @@ jobs:
292293
DB_USERNAME: SA
293294
DB_PASSWORD: Forge123
294295

295-
# mssql_2017:
296-
# runs-on: ubuntu-22.04
297-
298-
# services:
299-
# sqlsrv:
300-
# image: mcr.microsoft.com/mssql/server:2017-latest
301-
# env:
302-
# ACCEPT_EULA: Y
303-
# SA_PASSWORD: Forge123
304-
# ports:
305-
# - 1433:1433
306-
307-
# strategy:
308-
# fail-fast: true
309-
310-
# name: SQL Server 2017
311-
312-
# steps:
313-
# - name: Checkout code
314-
# uses: actions/checkout@v4
315-
316-
# - name: Setup PHP
317-
# uses: shivammathur/setup-php@v2
318-
# with:
319-
# php-version: 8.2
320-
# extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlsrv, pdo, pdo_sqlsrv, odbc, pdo_odbc, :php-psr
321-
# tools: composer:v2
322-
# coverage: none
323-
324-
# - name: Set Framework version
325-
# run: composer config version "11.x-dev"
326-
327-
# - name: Install dependencies
328-
# uses: nick-fields/retry@v3
329-
# with:
330-
# timeout_minutes: 5
331-
# max_attempts: 5
332-
# command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
333-
334-
# - name: Execute tests
335-
# run: vendor/bin/phpunit tests/Integration/Database
336-
# env:
337-
# DB_CONNECTION: sqlsrv
338-
# DB_DATABASE: master
339-
# DB_USERNAME: SA
340-
# DB_PASSWORD: Forge123
296+
mssql_2017:
297+
runs-on: ubuntu-20.04
298+
timeout-minutes: 5
299+
300+
services:
301+
sqlsrv:
302+
image: mcr.microsoft.com/mssql/server:2017-latest
303+
env:
304+
ACCEPT_EULA: Y
305+
SA_PASSWORD: Forge123
306+
ports:
307+
- 1433:1433
308+
309+
strategy:
310+
fail-fast: true
311+
312+
name: SQL Server 2017
313+
314+
steps:
315+
- name: Checkout code
316+
uses: actions/checkout@v4
317+
318+
- name: Setup PHP
319+
uses: shivammathur/setup-php@v2
320+
with:
321+
php-version: 8.2
322+
extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlsrv, pdo, pdo_sqlsrv, odbc, pdo_odbc, :php-psr
323+
tools: composer:v2
324+
coverage: none
325+
326+
- name: Set Framework version
327+
run: composer config version "11.x-dev"
328+
329+
- name: Install dependencies
330+
uses: nick-fields/retry@v3
331+
with:
332+
timeout_minutes: 5
333+
max_attempts: 5
334+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
335+
336+
- name: Execute tests
337+
run: vendor/bin/phpunit tests/Integration/Database
338+
env:
339+
DB_CONNECTION: sqlsrv
340+
DB_DATABASE: master
341+
DB_USERNAME: SA
342+
DB_PASSWORD: Forge123
341343

342344
sqlite:
343345
runs-on: ubuntu-24.04

.github/workflows/queues.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ jobs:
7373
max_attempts: 5
7474
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
7575

76+
- name: Setup SQLite Database
77+
run: php vendor/bin/testbench package:create-sqlite-db
78+
7679
- name: Execute tests
7780
run: vendor/bin/phpunit tests/Integration/Queue
7881
env:
79-
DB_CONNECTION: testing
82+
DB_CONNECTION: sqlite
8083
QUEUE_CONNECTION: database
8184

8285
redis:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"league/flysystem-sftp-v3": "^3.0",
108108
"mockery/mockery": "^1.6",
109109
"nyholm/psr7": "^1.2",
110-
"orchestra/testbench-core": "^9.4.0",
110+
"orchestra/testbench-core": "^9.5",
111111
"pda/pheanstalk": "^5.0",
112112
"phpstan/phpstan": "^1.11.5",
113113
"phpunit/phpunit": "^10.5|^11.0",

tests/Integration/Database/EloquentModelCustomCastingTest.php renamed to tests/Database/EloquentModelCustomCastingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Illuminate\Tests\Integration\Database;
3+
namespace Illuminate\Tests\Database;
44

55
use Brick\Math\BigNumber;
66
use GMP;

tests/Integration/Database/MariaDb/MariaDbTestCase.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
namespace Illuminate\Tests\Integration\Database\MariaDb;
44

55
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
6+
use Orchestra\Testbench\Attributes\RequiresDatabase;
67

8+
#[RequiresDatabase('mariadb')]
79
abstract class MariaDbTestCase extends DatabaseTestCase
810
{
9-
protected function defineDatabaseMigrations()
10-
{
11-
if ($this->driver !== 'mariadb') {
12-
$this->markTestSkipped('Test requires a MariaDB connection.');
13-
}
14-
}
11+
//
1512
}

tests/Integration/Database/MySql/MySqlTestCase.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
namespace Illuminate\Tests\Integration\Database\MySql;
44

55
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
6+
use Orchestra\Testbench\Attributes\RequiresDatabase;
67

8+
#[RequiresDatabase('mysql')]
79
abstract class MySqlTestCase extends DatabaseTestCase
810
{
9-
protected function defineDatabaseMigrations()
10-
{
11-
if ($this->driver !== 'mysql') {
12-
$this->markTestSkipped('Test requires a MySQL connection.');
13-
}
14-
}
11+
//
1512
}

tests/Integration/Database/Postgres/FulltextTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Schema\Blueprint;
66
use Illuminate\Support\Facades\DB;
77
use Illuminate\Support\Facades\Schema;
8+
use Orchestra\Testbench\Attributes\RequiresDatabase;
89
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
910
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1011

@@ -50,12 +51,9 @@ public function testWhereFulltext()
5051
$this->assertSame('PostgreSQL vs. YourSQL', $articles[1]->title);
5152
}
5253

54+
#[RequiresDatabase('pgsql', '>=11.0')]
5355
public function testWhereFulltextWithWebsearch()
5456
{
55-
if (version_compare($this->getConnection()->getServerVersion(), '11.0', '<')) {
56-
$this->markTestSkipped('Test requires a PostgreSQL connection >= 11.0');
57-
}
58-
5957
$articles = DB::table('articles')->whereFulltext(['title', 'body'], '+PostgreSQL -YourSQL', ['mode' => 'websearch'])->get();
6058

6159
$this->assertCount(5, $articles);

tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Schema\Blueprint;
66
use Illuminate\Support\Facades\DB;
77
use Illuminate\Support\Facades\Schema;
8+
use Orchestra\Testbench\Attributes\RequiresDatabase;
89
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
910
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1011

@@ -165,12 +166,9 @@ public function testGetViews()
165166
}));
166167
}
167168

169+
#[RequiresDatabase('pgsql', '>=11.0')]
168170
public function testDropPartitionedTables()
169171
{
170-
if (version_compare($this->getConnection()->getServerVersion(), '11.0', '<')) {
171-
$this->markTestSkipped('Test requires a PostgreSQL connection >= 11.0');
172-
}
173-
174172
DB::statement('create table groups (id bigserial, tenant_id bigint, name varchar, primary key (id, tenant_id)) partition by hash (tenant_id)');
175173
DB::statement('create table groups_1 partition of groups for values with (modulus 2, remainder 0)');
176174
DB::statement('create table groups_2 partition of groups for values with (modulus 2, remainder 1)');

tests/Integration/Database/Postgres/PostgresTestCase.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
namespace Illuminate\Tests\Integration\Database\Postgres;
44

55
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
6+
use Orchestra\Testbench\Attributes\RequiresDatabase;
67

8+
#[RequiresDatabase('pgsql')]
79
abstract class PostgresTestCase extends DatabaseTestCase
810
{
9-
protected function defineDatabaseMigrations()
10-
{
11-
if ($this->driver !== 'pgsql') {
12-
$this->markTestSkipped('Test requires a PostgreSQL connection.');
13-
}
14-
}
11+
//
1512
}

tests/Integration/Database/Queue/BatchableTransactionTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Support\Facades\Bus;
77
use Illuminate\Support\Facades\DB;
88
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
9+
use Orchestra\Testbench\Attributes\WithConfig;
910
use Orchestra\Testbench\Attributes\WithMigration;
1011
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1112
use Symfony\Component\Process\Exception\ProcessSignaledException;
@@ -15,21 +16,18 @@
1516

1617
#[RequiresPhpExtension('pcntl')]
1718
#[WithMigration('laravel', 'queue')]
19+
#[WithConfig('queue.default', 'database')]
1820
class BatchableTransactionTest extends DatabaseTestCase
1921
{
2022
use DatabaseMigrations;
2123

22-
protected function defineEnvironment($app)
24+
protected function setUp(): void
2325
{
24-
parent::defineEnvironment($app);
26+
parent::setUp();
2527

26-
$config = $app['config'];
27-
28-
if ($config->get('database.default') === 'testing') {
28+
if ($this->usesSqliteInMemoryDatabaseConnection()) {
2929
$this->markTestSkipped('Test does not support using :memory: database connection');
3030
}
31-
32-
$config->set(['queue.default' => 'database']);
3331
}
3432

3533
public function testItCanHandleTimeoutJob()

tests/Integration/Database/Queue/QueueTransactionTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Foundation\Testing\DatabaseMigrations;
66
use Illuminate\Support\Facades\DB;
77
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
8+
use Orchestra\Testbench\Attributes\WithConfig;
89
use Orchestra\Testbench\Attributes\WithMigration;
910
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1011
use Symfony\Component\Process\Exception\ProcessSignaledException;
@@ -14,21 +15,18 @@
1415

1516
#[RequiresPhpExtension('pcntl')]
1617
#[WithMigration('laravel', 'queue')]
18+
#[WithConfig('queue.default', 'database')]
1719
class QueueTransactionTest extends DatabaseTestCase
1820
{
1921
use DatabaseMigrations;
2022

21-
protected function defineEnvironment($app)
23+
protected function setUp(): void
2224
{
23-
parent::defineEnvironment($app);
25+
parent::setUp();
2426

25-
$config = $app['config'];
26-
27-
if ($config->get('database.default') === 'testing') {
27+
if ($this->usesSqliteInMemoryDatabaseConnection()) {
2828
$this->markTestSkipped('Test does not support using :memory: database connection');
2929
}
30-
31-
$config->set(['queue.default' => 'database']);
3230
}
3331

3432
public function testItCanHandleTimeoutJob()

tests/Integration/Database/SchemaBuilderSchemaNameTest.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
use Illuminate\Database\Schema\Blueprint;
66
use Illuminate\Support\Facades\DB;
77
use Illuminate\Support\Facades\Schema;
8+
use Orchestra\Testbench\Attributes\RequiresDatabase;
89
use PHPUnit\Framework\Attributes\DataProvider;
910

11+
#[RequiresDatabase(['pgsql', 'sqlsrv'])]
1012
class SchemaBuilderSchemaNameTest extends DatabaseTestCase
1113
{
1214
protected function defineDatabaseMigrations()
1315
{
14-
if (! in_array($this->driver, ['pgsql', 'sqlsrv'])) {
15-
$this->markTestSkipped('Test requires a PostgreSQL or SQL Server connection.');
16-
}
17-
1816
if ($this->driver === 'pgsql') {
1917
DB::connection('without-prefix')->statement('create schema if not exists my_schema');
2018
DB::connection('with-prefix')->statement('create schema if not exists my_schema');
@@ -372,12 +370,9 @@ public function testHasView($connection)
372370
}
373371

374372
#[DataProvider('connectionProvider')]
373+
#[RequiresDatabase('pgsql')]
375374
public function testComment($connection)
376375
{
377-
if ($this->driver !== 'pgsql') {
378-
$this->markTestSkipped('Test requires a PostgreSQL connection.');
379-
}
380-
381376
$schema = Schema::connection($connection);
382377

383378
$schema->create('my_schema.table', function (Blueprint $table) {
@@ -407,12 +402,9 @@ public function testComment($connection)
407402
}
408403

409404
#[DataProvider('connectionProvider')]
405+
#[RequiresDatabase('pgsql')]
410406
public function testAutoIncrementStartingValue($connection)
411407
{
412-
if ($this->driver !== 'pgsql') {
413-
$this->markTestSkipped('Test requires a PostgreSQL connection.');
414-
}
415-
416408
$this->expectNotToPerformAssertions();
417409

418410
$schema = Schema::connection($connection);
@@ -426,12 +418,9 @@ public function testAutoIncrementStartingValue($connection)
426418
}
427419

428420
#[DataProvider('connectionProvider')]
421+
#[RequiresDatabase('sqlsrv')]
429422
public function testHasTable($connection)
430423
{
431-
if ($this->driver !== 'sqlsrv') {
432-
$this->markTestSkipped('Test requires a SQL Server connection.');
433-
}
434-
435424
$db = DB::connection($connection);
436425
$schema = $db->getSchemaBuilder();
437426

0 commit comments

Comments
 (0)