Skip to content

Commit 5e837d5

Browse files
authored
[8.x] PostgreSQL, MSSQL & MariaDB builds (#39477)
* PostgreSQL build * wip * wip * wip * Skip MySQL tests * Fix column type * Fixes * wip * Test on MariaDB * Test on SQL Server * wip * wip * wip * Disable MSSQL builds for now * Skip some MSSQL failures * wip * skip some more tests * wip * wip
1 parent c7e5c76 commit 5e837d5

13 files changed

+179
-12
lines changed

.github/workflows/databases.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,134 @@ jobs:
8888
env:
8989
DB_CONNECTION: mysql
9090
DB_USERNAME: root
91+
92+
mariadb:
93+
runs-on: ubuntu-20.04
94+
95+
services:
96+
mysql:
97+
image: mariadb:10
98+
env:
99+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
100+
MYSQL_DATABASE: forge
101+
ports:
102+
- 3306:3306
103+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
104+
105+
strategy:
106+
fail-fast: true
107+
108+
name: MariaDB 10
109+
110+
steps:
111+
- name: Checkout code
112+
uses: actions/checkout@v2
113+
114+
- name: Setup PHP
115+
uses: shivammathur/setup-php@v2
116+
with:
117+
php-version: 8.1
118+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql
119+
tools: composer:v2
120+
coverage: none
121+
122+
- name: Install dependencies
123+
uses: nick-invision/retry@v1
124+
with:
125+
timeout_minutes: 5
126+
max_attempts: 5
127+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
128+
129+
- name: Execute tests
130+
run: vendor/bin/phpunit tests/Integration/Database --verbose
131+
env:
132+
DB_CONNECTION: mysql
133+
DB_USERNAME: root
134+
135+
pgsql:
136+
runs-on: ubuntu-20.04
137+
138+
services:
139+
postgresql:
140+
image: postgres:14
141+
env:
142+
POSTGRES_DB: forge
143+
POSTGRES_USER: forge
144+
POSTGRES_PASSWORD: password
145+
ports:
146+
- 5432:5432
147+
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
148+
149+
strategy:
150+
fail-fast: true
151+
152+
name: PostgreSQL 14
153+
154+
steps:
155+
- name: Checkout code
156+
uses: actions/checkout@v2
157+
158+
- name: Setup PHP
159+
uses: shivammathur/setup-php@v2
160+
with:
161+
php-version: 8.1
162+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql
163+
tools: composer:v2
164+
coverage: none
165+
166+
- name: Install dependencies
167+
uses: nick-invision/retry@v1
168+
with:
169+
timeout_minutes: 5
170+
max_attempts: 5
171+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
172+
173+
- name: Execute tests
174+
run: vendor/bin/phpunit tests/Integration/Database --verbose --exclude-group MySQL
175+
env:
176+
DB_CONNECTION: pgsql
177+
DB_PASSWORD: password
178+
179+
mssql:
180+
runs-on: ubuntu-20.04
181+
182+
services:
183+
sqlsrv:
184+
image: mcr.microsoft.com/mssql/server:2019-latest
185+
env:
186+
ACCEPT_EULA: Y
187+
SA_PASSWORD: Forge123
188+
ports:
189+
- 1433:1433
190+
191+
strategy:
192+
fail-fast: true
193+
194+
name: SQL Server 2019
195+
196+
steps:
197+
- name: Checkout code
198+
uses: actions/checkout@v2
199+
200+
- name: Setup PHP
201+
uses: shivammathur/setup-php@v2
202+
with:
203+
php-version: 8.1
204+
extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlsrv, pdo, pdo_sqlsrv
205+
tools: composer:v2
206+
coverage: none
207+
208+
- name: Install dependencies
209+
uses: nick-invision/retry@v1
210+
with:
211+
timeout_minutes: 5
212+
max_attempts: 5
213+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
214+
215+
- name: Execute tests
216+
run: vendor/bin/phpunit tests/Integration/Database --verbose --exclude-group MySQL,SkipMSSQL
217+
env:
218+
DB_CONNECTION: sqlsrv
219+
DB_DATABASE: master
220+
DB_USERNAME: SA
221+
DB_PASSWORD: Forge123

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
!vendor/**/.gitignore
9696
9797
windows_tests:
98-
runs-on: windows-latest
98+
runs-on: windows-2019
9999

100100
strategy:
101101
fail-fast: true

tests/Integration/Database/DatabaseEmulatePreparesMySqlConnectionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PDO;
66

77
/**
8+
* @group MySQL
89
* @requires extension pdo_mysql
910
* @requires OS Linux|Darwin
1011
*/

tests/Integration/Database/DatabaseMySqlConnectionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Schema;
88

99
/**
10+
* @group MySQL
1011
* @requires extension pdo_mysql
1112
* @requires OS Linux|Darwin
1213
*/

tests/Integration/Database/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use stdClass;
88

99
/**
10+
* @group MySQL
1011
* @requires extension pdo_mysql
1112
* @requires OS Linux|Darwin
1213
*/

tests/Integration/Database/EloquentBelongsToManyTest.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ protected function setUp(): void
4848

4949
Schema::create('posts_tags', function (Blueprint $table) {
5050
$table->integer('post_id');
51-
$table->string('tag_id');
51+
$table->integer('tag_id')->default(0);
52+
$table->string('tag_name')->default('')->nullable();
5253
$table->string('flag')->default('')->nullable();
5354
$table->timestamps();
5455
});
@@ -203,6 +204,7 @@ public function testCustomPivotClassUsingUpdateExistingPivot()
203204
);
204205
}
205206

207+
/** @group SkipMSSQL */
206208
public function testCustomPivotClassUpdatesTimestamps()
207209
{
208210
Carbon::setTestNow('2017-10-10 10:10:10');
@@ -402,8 +404,8 @@ public function testFindOrNewMethod()
402404

403405
$this->assertEquals($tag->id, $post->tags()->findOrNew($tag->id)->id);
404406

405-
$this->assertNull($post->tags()->findOrNew('asd')->id);
406-
$this->assertInstanceOf(Tag::class, $post->tags()->findOrNew('asd'));
407+
$this->assertNull($post->tags()->findOrNew(666)->id);
408+
$this->assertInstanceOf(Tag::class, $post->tags()->findOrNew(666));
407409
}
408410

409411
public function testFirstOrNewMethod()
@@ -416,8 +418,8 @@ public function testFirstOrNewMethod()
416418

417419
$this->assertEquals($tag->id, $post->tags()->firstOrNew(['id' => $tag->id])->id);
418420

419-
$this->assertNull($post->tags()->firstOrNew(['id' => 'asd'])->id);
420-
$this->assertInstanceOf(Tag::class, $post->tags()->firstOrNew(['id' => 'asd']));
421+
$this->assertNull($post->tags()->firstOrNew(['id' => 666])->id);
422+
$this->assertInstanceOf(Tag::class, $post->tags()->firstOrNew(['id' => 666]));
421423
}
422424

423425
public function testFirstOrCreateMethod()
@@ -446,7 +448,7 @@ public function testUpdateOrCreateMethod()
446448
$post->tags()->updateOrCreate(['id' => $tag->id], ['name' => 'wavez']);
447449
$this->assertSame('wavez', $tag->fresh()->name);
448450

449-
$post->tags()->updateOrCreate(['id' => 'asd'], ['name' => 'dives']);
451+
$post->tags()->updateOrCreate(['id' => 666], ['name' => 'dives']);
450452
$this->assertNotNull($post->tags()->whereName('dives')->first());
451453
}
452454

@@ -598,6 +600,7 @@ public function testNoTouchingHappensIfNotConfigured()
598600
$this->assertNotSame('2017-10-10 10:10:10', $tag->fresh()->updated_at->toDateTimeString());
599601
}
600602

603+
/** @group SkipMSSQL */
601604
public function testCanRetrieveRelatedIds()
602605
{
603606
$post = Post::create(['title' => Str::random()]);
@@ -616,6 +619,7 @@ public function testCanRetrieveRelatedIds()
616619
$this->assertEquals([200, 400], $post->tags()->allRelatedIds()->toArray());
617620
}
618621

622+
/** @group SkipMSSQL */
619623
public function testCanTouchRelatedModels()
620624
{
621625
$post = Post::create(['title' => Str::random()]);
@@ -642,6 +646,7 @@ public function testCanTouchRelatedModels()
642646
$this->assertNotSame('2017-10-10 10:10:10', Tag::find(300)->updated_at);
643647
}
644648

649+
/** @group SkipMSSQL */
645650
public function testWherePivotOnString()
646651
{
647652
$tag = Tag::create(['name' => Str::random()]);
@@ -658,6 +663,7 @@ public function testWherePivotOnString()
658663
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
659664
}
660665

666+
/** @group SkipMSSQL */
661667
public function testFirstWhere()
662668
{
663669
$tag = Tag::create(['name' => 'foo']);
@@ -674,6 +680,7 @@ public function testFirstWhere()
674680
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
675681
}
676682

683+
/** @group SkipMSSQL */
677684
public function testWherePivotOnBoolean()
678685
{
679686
$tag = Tag::create(['name' => Str::random()]);
@@ -690,6 +697,7 @@ public function testWherePivotOnBoolean()
690697
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
691698
}
692699

700+
/** @group SkipMSSQL */
693701
public function testWherePivotInMethod()
694702
{
695703
$tag = Tag::create(['name' => Str::random()]);
@@ -724,6 +732,7 @@ public function testOrWherePivotInMethod()
724732
$this->assertEquals($relationTags->pluck('id')->toArray(), [$tag1->id, $tag3->id]);
725733
}
726734

735+
/** @group SkipMSSQL */
727736
public function testWherePivotNotInMethod()
728737
{
729738
$tag1 = Tag::create(['name' => Str::random()]);
@@ -762,6 +771,7 @@ public function testOrWherePivotNotInMethod()
762771
$this->assertEquals($relationTags->pluck('id')->toArray(), [$tag1->id, $tag2->id]);
763772
}
764773

774+
/** @group SkipMSSQL */
765775
public function testWherePivotNullMethod()
766776
{
767777
$tag1 = Tag::create(['name' => Str::random()]);
@@ -779,6 +789,7 @@ public function testWherePivotNullMethod()
779789
$this->assertEquals($relationTag->getAttributes(), $tag2->getAttributes());
780790
}
781791

792+
/** @group SkipMSSQL */
782793
public function testWherePivotNotNullMethod()
783794
{
784795
$tag1 = Tag::create(['name' => Str::random()]);
@@ -853,17 +864,17 @@ public function testCustomRelatedKey()
853864
$post = Post::create(['title' => Str::random()]);
854865

855866
$tag = $post->tagsWithCustomRelatedKey()->create(['name' => Str::random()]);
856-
$this->assertEquals($tag->name, $post->tagsWithCustomRelatedKey()->first()->pivot->tag_id);
867+
$this->assertEquals($tag->name, $post->tagsWithCustomRelatedKey()->first()->pivot->tag_name);
857868

858869
$post->tagsWithCustomRelatedKey()->detach($tag);
859870

860871
$post->tagsWithCustomRelatedKey()->attach($tag);
861-
$this->assertEquals($tag->name, $post->tagsWithCustomRelatedKey()->first()->pivot->tag_id);
872+
$this->assertEquals($tag->name, $post->tagsWithCustomRelatedKey()->first()->pivot->tag_name);
862873

863874
$post->tagsWithCustomRelatedKey()->detach(new Collection([$tag]));
864875

865876
$post->tagsWithCustomRelatedKey()->attach(new Collection([$tag]));
866-
$this->assertEquals($tag->name, $post->tagsWithCustomRelatedKey()->first()->pivot->tag_id);
877+
$this->assertEquals($tag->name, $post->tagsWithCustomRelatedKey()->first()->pivot->tag_name);
867878

868879
$post->tagsWithCustomRelatedKey()->updateExistingPivot($tag, ['flag' => 'exclude']);
869880
$this->assertSame('exclude', $post->tagsWithCustomRelatedKey()->first()->pivot->flag);
@@ -903,6 +914,7 @@ public function testPivotDoesntHavePrimaryKey()
903914
$this->assertEquals(0, $user->postsWithCustomPivot()->first()->pivot->is_draft);
904915
}
905916

917+
/** @group SkipMSSQL */
906918
public function testOrderByPivotMethod()
907919
{
908920
$tag1 = Tag::create(['name' => Str::random()]);
@@ -935,6 +947,7 @@ class User extends Model
935947
protected static function boot()
936948
{
937949
parent::boot();
950+
938951
static::creating(function ($model) {
939952
$model->setAttribute('uuid', Str::random());
940953
});
@@ -959,6 +972,7 @@ class Post extends Model
959972
protected static function boot()
960973
{
961974
parent::boot();
975+
962976
static::creating(function ($model) {
963977
$model->setAttribute('uuid', Str::random());
964978
});
@@ -1013,7 +1027,7 @@ public function tagsWithCustomAccessor()
10131027

10141028
public function tagsWithCustomRelatedKey()
10151029
{
1016-
return $this->belongsToMany(Tag::class, 'posts_tags', 'post_id', 'tag_id', 'id', 'name')
1030+
return $this->belongsToMany(Tag::class, 'posts_tags', 'post_id', 'tag_name', 'id', 'name')
10171031
->withPivot('flag');
10181032
}
10191033

tests/Integration/Database/EloquentCursorPaginateTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function testPaginationWithWhereClause()
6666
$this->assertCount(3, $query->cursorPaginate()->items());
6767
}
6868

69+
/** @group SkipMSSQL */
6970
public function testPaginationWithHasClause()
7071
{
7172
for ($i = 1; $i <= 3; $i++) {
@@ -82,6 +83,7 @@ public function testPaginationWithHasClause()
8283
$this->assertCount(2, $query->cursorPaginate()->items());
8384
}
8485

86+
/** @group SkipMSSQL */
8587
public function testPaginationWithWhereHasClause()
8688
{
8789
for ($i = 1; $i <= 3; $i++) {
@@ -100,6 +102,7 @@ public function testPaginationWithWhereHasClause()
100102
$this->assertCount(1, $query->cursorPaginate()->items());
101103
}
102104

105+
/** @group SkipMSSQL */
103106
public function testPaginationWithWhereExistsClause()
104107
{
105108
for ($i = 1; $i <= 3; $i++) {
@@ -120,6 +123,7 @@ public function testPaginationWithWhereExistsClause()
120123
$this->assertCount(2, $query->cursorPaginate()->items());
121124
}
122125

126+
/** @group SkipMSSQL */
123127
public function testPaginationWithMultipleWhereClauses()
124128
{
125129
for ($i = 1; $i <= 4; $i++) {
@@ -152,6 +156,7 @@ public function testPaginationWithMultipleWhereClauses()
152156
);
153157
}
154158

159+
/** @group SkipMSSQL */
155160
public function testPaginationWithAliasedOrderBy()
156161
{
157162
for ($i = 1; $i <= 6; $i++) {

tests/Integration/Database/EloquentHasManyThroughTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testBasicCreateAndRetrieve()
4444
{
4545
$user = User::create(['name' => Str::random()]);
4646

47-
$team1 = Team::create(['id' => 10, 'owner_id' => $user->id]);
47+
$team1 = Team::create(['owner_id' => $user->id]);
4848
$team2 = Team::create(['owner_id' => $user->id]);
4949

5050
$mate1 = User::create(['name' => 'John', 'team_id' => $team1->id]);

tests/Integration/Database/EloquentMassPrunableTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use LogicException;
1414
use Mockery as m;
1515

16+
/** @group SkipMSSQL */
1617
class EloquentMassPrunableTest extends DatabaseTestCase
1718
{
1819
protected function setUp(): void

0 commit comments

Comments
 (0)