Skip to content

Commit d23de5f

Browse files
authored
[9.x] Remove all MSSQL checks (laravel#43853)
* Remove SkipMSSQL checks * wip * wip * wip * wip
1 parent 4849851 commit d23de5f

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

.github/workflows/databases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ jobs:
213213
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
214214

215215
- name: Execute tests
216-
run: vendor/bin/phpunit tests/Integration/Database --verbose --exclude-group SkipMSSQL
216+
run: vendor/bin/phpunit tests/Integration/Database --verbose
217217
env:
218218
DB_CONNECTION: sqlsrv
219219
DB_DATABASE: master

tests/Integration/Database/EloquentBelongsToManyTest.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ public function testCustomPivotClassUsingUpdateExistingPivot()
209209
);
210210
}
211211

212-
/** @group SkipMSSQL */
213212
public function testCustomPivotClassUpdatesTimestamps()
214213
{
215214
Carbon::setTestNow('2017-10-10 10:10:10');
@@ -233,8 +232,14 @@ public function testCustomPivotClassUpdatesTimestamps()
233232
);
234233
foreach ($post->tagsWithCustomExtraPivot as $tag) {
235234
$this->assertSame('exclude', $tag->pivot->flag);
236-
$this->assertSame('2017-10-10 10:10:10', $tag->pivot->getAttributes()['created_at']);
237-
$this->assertSame('2017-10-10 10:10:20', $tag->pivot->getAttributes()['updated_at']); // +10 seconds
235+
236+
if ($this->driver === 'sqlsrv') {
237+
$this->assertSame('2017-10-10 10:10:10.000', $tag->pivot->getAttributes()['created_at']);
238+
$this->assertSame('2017-10-10 10:10:20.000', $tag->pivot->getAttributes()['updated_at']); // +10 seconds
239+
} else {
240+
$this->assertSame('2017-10-10 10:10:10', $tag->pivot->getAttributes()['created_at']);
241+
$this->assertSame('2017-10-10 10:10:20', $tag->pivot->getAttributes()['updated_at']); // +10 seconds
242+
}
238243
}
239244
}
240245

@@ -528,7 +533,6 @@ public function testFirstOrCreateMethod()
528533

529534
public function testFirstOrCreateUnrelatedExisting()
530535
{
531-
/** @var Post $post */
532536
$post = Post::create(['title' => Str::random()]);
533537

534538
$name = Str::random();
@@ -791,53 +795,54 @@ public function testNoTouchingHappensIfNotConfigured()
791795
$this->assertNotSame('2017-10-10 10:10:10', $tag->fresh()->updated_at->toDateTimeString());
792796
}
793797

794-
/** @group SkipMSSQL */
795798
public function testCanRetrieveRelatedIds()
796799
{
797800
$post = Post::create(['title' => Str::random()]);
798801

799802
DB::table('tags')->insert([
800-
['id' => 200, 'name' => 'excluded'],
801-
['id' => 300, 'name' => Str::random()],
803+
['name' => 'excluded'],
804+
['name' => Str::random()],
802805
]);
803806

804807
DB::table('posts_tags')->insert([
805-
['post_id' => $post->id, 'tag_id' => 200, 'flag' => ''],
806-
['post_id' => $post->id, 'tag_id' => 300, 'flag' => 'exclude'],
807-
['post_id' => $post->id, 'tag_id' => 400, 'flag' => ''],
808+
['post_id' => $post->id, 'tag_id' => 1, 'flag' => ''],
809+
['post_id' => $post->id, 'tag_id' => 2, 'flag' => 'exclude'],
810+
['post_id' => $post->id, 'tag_id' => 3, 'flag' => ''],
808811
]);
809812

810-
$this->assertEquals([200, 400], $post->tags()->allRelatedIds()->toArray());
813+
$this->assertEquals([1, 3], $post->tags()->allRelatedIds()->toArray());
811814
}
812815

813-
/** @group SkipMSSQL */
814816
public function testCanTouchRelatedModels()
815817
{
816818
$post = Post::create(['title' => Str::random()]);
817819

818820
DB::table('tags')->insert([
819-
['id' => 200, 'name' => Str::random()],
820-
['id' => 300, 'name' => Str::random()],
821+
['name' => Str::random()],
822+
['name' => Str::random()],
821823
]);
822824

823825
DB::table('posts_tags')->insert([
824-
['post_id' => $post->id, 'tag_id' => 200, 'flag' => ''],
825-
['post_id' => $post->id, 'tag_id' => 300, 'flag' => 'exclude'],
826-
['post_id' => $post->id, 'tag_id' => 400, 'flag' => ''],
826+
['post_id' => $post->id, 'tag_id' => 1, 'flag' => ''],
827+
['post_id' => $post->id, 'tag_id' => 2, 'flag' => 'exclude'],
828+
['post_id' => $post->id, 'tag_id' => 3, 'flag' => ''],
827829
]);
828830

829831
Carbon::setTestNow('2017-10-10 10:10:10');
830832

831833
$post->tags()->touch();
832834

833835
foreach ($post->tags()->pluck('tags.updated_at') as $date) {
834-
$this->assertSame('2017-10-10 10:10:10', $date);
836+
if ($this->driver === 'sqlsrv') {
837+
$this->assertSame('2017-10-10 10:10:10.000', $date);
838+
} else {
839+
$this->assertSame('2017-10-10 10:10:10', $date);
840+
}
835841
}
836842

837-
$this->assertNotSame('2017-10-10 10:10:10', Tag::find(300)->updated_at);
843+
$this->assertNotSame('2017-10-10 10:10:10', Tag::find(2)->updated_at);
838844
}
839845

840-
/** @group SkipMSSQL */
841846
public function testWherePivotOnString()
842847
{
843848
$tag = Tag::create(['name' => Str::random()])->fresh();
@@ -854,7 +859,6 @@ public function testWherePivotOnString()
854859
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
855860
}
856861

857-
/** @group SkipMSSQL */
858862
public function testFirstWhere()
859863
{
860864
$tag = Tag::create(['name' => 'foo'])->fresh();
@@ -871,7 +875,6 @@ public function testFirstWhere()
871875
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
872876
}
873877

874-
/** @group SkipMSSQL */
875878
public function testWherePivotOnBoolean()
876879
{
877880
$tag = Tag::create(['name' => Str::random()])->fresh();
@@ -888,7 +891,6 @@ public function testWherePivotOnBoolean()
888891
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
889892
}
890893

891-
/** @group SkipMSSQL */
892894
public function testWherePivotInMethod()
893895
{
894896
$tag = Tag::create(['name' => Str::random()])->fresh();
@@ -923,7 +925,6 @@ public function testOrWherePivotInMethod()
923925
$this->assertEquals($relationTags->pluck('id')->toArray(), [$tag1->id, $tag3->id]);
924926
}
925927

926-
/** @group SkipMSSQL */
927928
public function testWherePivotNotInMethod()
928929
{
929930
$tag1 = Tag::create(['name' => Str::random()]);
@@ -962,7 +963,6 @@ public function testOrWherePivotNotInMethod()
962963
$this->assertEquals($relationTags->pluck('id')->toArray(), [$tag1->id, $tag2->id]);
963964
}
964965

965-
/** @group SkipMSSQL */
966966
public function testWherePivotNullMethod()
967967
{
968968
$tag1 = Tag::create(['name' => Str::random()]);
@@ -980,7 +980,6 @@ public function testWherePivotNullMethod()
980980
$this->assertEquals($relationTag->getAttributes(), $tag2->getAttributes());
981981
}
982982

983-
/** @group SkipMSSQL */
984983
public function testWherePivotNotNullMethod()
985984
{
986985
$tag1 = Tag::create(['name' => Str::random()])->fresh();
@@ -1105,7 +1104,6 @@ public function testPivotDoesntHavePrimaryKey()
11051104
$this->assertEquals(0, $user->postsWithCustomPivot()->first()->pivot->is_draft);
11061105
}
11071106

1108-
/** @group SkipMSSQL */
11091107
public function testOrderByPivotMethod()
11101108
{
11111109
$tag1 = Tag::create(['name' => Str::random()]);

tests/Integration/Database/EloquentCursorPaginateTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ public function testPaginationWithWhereClause()
8181
$this->assertCount(3, $query->cursorPaginate()->items());
8282
}
8383

84-
/** @group SkipMSSQL */
8584
public function testPaginationWithHasClause()
8685
{
8786
for ($i = 1; $i <= 3; $i++) {
88-
TestUser::create(['id' => $i]);
87+
TestUser::create();
8988
TestPost::create(['title' => 'Hello world', 'user_id' => null]);
9089
TestPost::create(['title' => 'Goodbye world', 'user_id' => 2]);
9190
TestPost::create(['title' => 'Howdy', 'user_id' => 3]);
@@ -98,11 +97,10 @@ public function testPaginationWithHasClause()
9897
$this->assertCount(2, $query->cursorPaginate()->items());
9998
}
10099

101-
/** @group SkipMSSQL */
102100
public function testPaginationWithWhereHasClause()
103101
{
104102
for ($i = 1; $i <= 3; $i++) {
105-
TestUser::create(['id' => $i]);
103+
TestUser::create();
106104
TestPost::create(['title' => 'Hello world', 'user_id' => null]);
107105
TestPost::create(['title' => 'Goodbye world', 'user_id' => 2]);
108106
TestPost::create(['title' => 'Howdy', 'user_id' => 3]);
@@ -117,11 +115,10 @@ public function testPaginationWithWhereHasClause()
117115
$this->assertCount(1, $query->cursorPaginate()->items());
118116
}
119117

120-
/** @group SkipMSSQL */
121118
public function testPaginationWithWhereExistsClause()
122119
{
123120
for ($i = 1; $i <= 3; $i++) {
124-
TestUser::create(['id' => $i]);
121+
TestUser::create();
125122
TestPost::create(['title' => 'Hello world', 'user_id' => null]);
126123
TestPost::create(['title' => 'Goodbye world', 'user_id' => 2]);
127124
TestPost::create(['title' => 'Howdy', 'user_id' => 3]);
@@ -138,11 +135,10 @@ public function testPaginationWithWhereExistsClause()
138135
$this->assertCount(2, $query->cursorPaginate()->items());
139136
}
140137

141-
/** @group SkipMSSQL */
142138
public function testPaginationWithMultipleWhereClauses()
143139
{
144140
for ($i = 1; $i <= 4; $i++) {
145-
TestUser::create(['id' => $i]);
141+
TestUser::create();
146142
TestPost::create(['title' => 'Hello world', 'user_id' => null]);
147143
TestPost::create(['title' => 'Goodbye world', 'user_id' => 2]);
148144
TestPost::create(['title' => 'Howdy', 'user_id' => 3]);
@@ -171,11 +167,10 @@ public function testPaginationWithMultipleWhereClauses()
171167
);
172168
}
173169

174-
/** @group SkipMSSQL */
175170
public function testPaginationWithAliasedOrderBy()
176171
{
177172
for ($i = 1; $i <= 6; $i++) {
178-
TestUser::create(['id' => $i]);
173+
TestUser::create();
179174
}
180175

181176
$query = TestUser::query()->select('id as user_id')->orderBy('user_id');
@@ -211,6 +206,7 @@ public function testPaginationWithDistinctColumnsAndSelectAndJoin()
211206
{
212207
for ($i = 1; $i <= 5; $i++) {
213208
$user = TestUser::create();
209+
214210
for ($j = 1; $j <= 10; $j++) {
215211
TestPost::create([
216212
'title' => 'Title '.$i,

tests/Integration/Database/EloquentDeleteTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
3232
});
3333
}
3434

35-
/** @group SkipMSSQL */
3635
public function testDeleteWithLimit()
3736
{
37+
if ($this->driver === 'sqlsrv') {
38+
$this->markTestSkipped('The limit keyword is not supported on MSSQL.');
39+
}
40+
3841
for ($i = 1; $i <= 10; $i++) {
3942
Comment::create([
4043
'post_id' => Post::create()->id,

tests/Integration/Database/EloquentMassPrunableTest.php

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

16-
/** @group SkipMSSQL */
1716
class EloquentMassPrunableTest extends DatabaseTestCase
1817
{
1918
protected function setUp(): void
@@ -38,6 +37,7 @@ protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
3837
])->each(function ($table) {
3938
Schema::create($table, function (Blueprint $table) {
4039
$table->increments('id');
40+
$table->string('name')->nullable();
4141
$table->softDeletes();
4242
$table->boolean('pruned')->default(false);
4343
$table->timestamps();
@@ -63,7 +63,7 @@ public function testPrunesRecords()
6363
->with(m::type(ModelsPruned::class));
6464

6565
collect(range(1, 5000))->map(function ($id) {
66-
return ['id' => $id];
66+
return ['name' => 'foo'];
6767
})->chunk(200)->each(function ($chunk) {
6868
MassPrunableTestModel::insert($chunk->all());
6969
});
@@ -82,7 +82,7 @@ public function testPrunesSoftDeletedRecords()
8282
->with(m::type(ModelsPruned::class));
8383

8484
collect(range(1, 5000))->map(function ($id) {
85-
return ['id' => $id, 'deleted_at' => now()];
85+
return ['deleted_at' => now()];
8686
})->chunk(200)->each(function ($chunk) {
8787
MassPrunableSoftDeleteTestModel::insert($chunk->all());
8888
});

tests/Integration/Database/EloquentPrunableTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Illuminate\Support\Facades\Schema;
1212
use LogicException;
1313

14-
/** @group SkipMSSQL */
1514
class EloquentPrunableTest extends DatabaseTestCase
1615
{
1716
protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
@@ -24,6 +23,7 @@ protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
2423
])->each(function ($table) {
2524
Schema::create($table, function (Blueprint $table) {
2625
$table->increments('id');
26+
$table->string('name')->nullable();
2727
$table->softDeletes();
2828
$table->boolean('pruned')->default(false);
2929
$table->timestamps();
@@ -46,7 +46,7 @@ public function testPrunesRecords()
4646
Event::fake();
4747

4848
collect(range(1, 5000))->map(function ($id) {
49-
return ['id' => $id];
49+
return ['name' => 'foo'];
5050
})->chunk(200)->each(function ($chunk) {
5151
PrunableTestModel::insert($chunk->all());
5252
});
@@ -64,7 +64,7 @@ public function testPrunesSoftDeletedRecords()
6464
Event::fake();
6565

6666
collect(range(1, 5000))->map(function ($id) {
67-
return ['id' => $id, 'deleted_at' => now()];
67+
return ['deleted_at' => now()];
6868
})->chunk(200)->each(function ($chunk) {
6969
PrunableSoftDeleteTestModel::insert($chunk->all());
7070
});
@@ -83,7 +83,7 @@ public function testPruneWithCustomPruneMethod()
8383
Event::fake();
8484

8585
collect(range(1, 5000))->map(function ($id) {
86-
return ['id' => $id];
86+
return ['name' => 'foo'];
8787
})->chunk(200)->each(function ($chunk) {
8888
PrunableWithCustomPruneMethodTestModel::insert($chunk->all());
8989
});

tests/Integration/Database/EloquentUpdateTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ public function testBasicUpdate()
4646
$this->assertCount(0, TestUpdateModel1::all());
4747
}
4848

49-
/** @group SkipMSSQL */
5049
public function testUpdateWithLimitsAndOrders()
5150
{
51+
if ($this->driver === 'sqlsrv') {
52+
$this->markTestSkipped('The limit keyword is not supported on MSSQL.');
53+
}
54+
5255
for ($i = 1; $i <= 10; $i++) {
5356
TestUpdateModel1::create();
5457
}

0 commit comments

Comments
 (0)