Skip to content

Commit

Permalink
More DB fixes (#38700)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored and driesvints committed Sep 13, 2021
1 parent 38ae7a5 commit 133f434
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"require-dev": {
"aws/aws-sdk-php": "^3.189.0",
"doctrine/dbal": "^2.6|^3.0",
"doctrine/dbal": "^2.13.3|^3.1.2",
"filp/whoops": "^2.8",
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
"league/flysystem-cached-adapter": "^1.0",
Expand Down Expand Up @@ -131,7 +131,7 @@
"ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.189.0).",
"brianium/paratest": "Required to run tests in parallel (^6.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.2).",
"filp/whoops": "Required for friendly error pages in development (^2.8).",
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
"guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.5.5|^7.0.1).",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
},
"suggest": {
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.2).",
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
"illuminate/console": "Required to use the database commands (^8.0).",
"illuminate/events": "Required to use the observers with Eloquent (^8.0).",
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Database/EloquentBelongsToManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function testCustomPivotClass()
$post->tagsWithCustomPivot()->attach($tag->id);

$this->assertInstanceOf(PostTagPivot::class, $post->tagsWithCustomPivot[0]->pivot);
$this->assertSame('1507630210', $post->tagsWithCustomPivot[0]->pivot->getAttributes()['created_at']);
$this->assertEquals('1507630210', $post->tagsWithCustomPivot[0]->pivot->getAttributes()['created_at']);

$this->assertInstanceOf(PostTagPivot::class, $post->tagsWithCustomPivotClass[0]->pivot);
$this->assertSame('posts_tags', $post->tagsWithCustomPivotClass()->getTable());
Expand Down Expand Up @@ -229,8 +229,8 @@ public function testCustomPivotClassUpdatesTimestamps()
);
foreach ($post->tagsWithCustomExtraPivot as $tag) {
$this->assertSame('exclude', $tag->pivot->flag);
$this->assertSame('1507630210', $tag->pivot->getAttributes()['created_at']);
$this->assertSame('1507630220', $tag->pivot->getAttributes()['updated_at']); // +10 seconds
$this->assertEquals('1507630210', $tag->pivot->getAttributes()['created_at']);
$this->assertEquals('1507630220', $tag->pivot->getAttributes()['updated_at']); // +10 seconds
}
}

Expand Down
26 changes: 13 additions & 13 deletions tests/Integration/Database/EloquentCollectionLoadCountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function testLoadCount()
$posts->loadCount('comments');

$this->assertCount(1, DB::getQueryLog());
$this->assertSame('2', $posts[0]->comments_count);
$this->assertSame('0', $posts[1]->comments_count);
$this->assertSame('2', $posts[0]->getOriginal('comments_count'));
$this->assertEquals('2', $posts[0]->comments_count);
$this->assertEquals('0', $posts[1]->comments_count);
$this->assertEquals('2', $posts[0]->getOriginal('comments_count'));
}

public function testLoadCountWithSameModels()
Expand All @@ -66,9 +66,9 @@ public function testLoadCountWithSameModels()
$posts->loadCount('comments');

$this->assertCount(1, DB::getQueryLog());
$this->assertSame('2', $posts[0]->comments_count);
$this->assertSame('0', $posts[1]->comments_count);
$this->assertSame('2', $posts[2]->comments_count);
$this->assertEquals('2', $posts[0]->comments_count);
$this->assertEquals('0', $posts[1]->comments_count);
$this->assertEquals('2', $posts[2]->comments_count);
}

public function testLoadCountOnDeletedModels()
Expand All @@ -80,8 +80,8 @@ public function testLoadCountOnDeletedModels()
$posts->loadCount('comments');

$this->assertCount(1, DB::getQueryLog());
$this->assertSame('2', $posts[0]->comments_count);
$this->assertSame('0', $posts[1]->comments_count);
$this->assertEquals('2', $posts[0]->comments_count);
$this->assertEquals('0', $posts[1]->comments_count);
}

public function testLoadCountWithArrayOfRelations()
Expand All @@ -93,10 +93,10 @@ public function testLoadCountWithArrayOfRelations()
$posts->loadCount(['comments', 'likes']);

$this->assertCount(1, DB::getQueryLog());
$this->assertSame('2', $posts[0]->comments_count);
$this->assertSame('1', $posts[0]->likes_count);
$this->assertSame('0', $posts[1]->comments_count);
$this->assertSame('0', $posts[1]->likes_count);
$this->assertEquals('2', $posts[0]->comments_count);
$this->assertEquals('1', $posts[0]->likes_count);
$this->assertEquals('0', $posts[1]->comments_count);
$this->assertEquals('0', $posts[1]->likes_count);
}

public function testLoadCountDoesNotOverrideAttributesWithDefaultValue()
Expand All @@ -107,7 +107,7 @@ public function testLoadCountDoesNotOverrideAttributesWithDefaultValue()
Collection::make([$post])->loadCount('comments');

$this->assertSame(200, $post->some_default_value);
$this->assertSame('2', $post->comments_count);
$this->assertEquals('2', $post->comments_count);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Database/EloquentPivotEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testCustomPivotUpdateEventHasExistingAttributes()

$project->collaborators()->updateExistingPivot($user->id, ['role' => 'Lead Developer']);

$this->assertSame(
$this->assertEquals(
[
'user_id' => '1',
'project_id' => '1',
Expand Down
18 changes: 9 additions & 9 deletions tests/Integration/Database/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testSole()
{
$expected = ['id' => '1', 'title' => 'Foo Post'];

$this->assertSame($expected, (array) DB::table('posts')->where('title', 'Foo Post')->select('id', 'title')->sole());
$this->assertEquals($expected, (array) DB::table('posts')->where('title', 'Foo Post')->select('id', 'title')->sole());
}

public function testSoleFailsForMultipleRecords()
Expand All @@ -61,21 +61,21 @@ public function testSelect()
{
$expected = ['id' => '1', 'title' => 'Foo Post'];

$this->assertSame($expected, (array) DB::table('posts')->select('id', 'title')->first());
$this->assertSame($expected, (array) DB::table('posts')->select(['id', 'title'])->first());
$this->assertEquals($expected, (array) DB::table('posts')->select('id', 'title')->first());
$this->assertEquals($expected, (array) DB::table('posts')->select(['id', 'title'])->first());
}

public function testSelectReplacesExistingSelects()
{
$this->assertSame(
$this->assertEquals(
['id' => '1', 'title' => 'Foo Post'],
(array) DB::table('posts')->select('content')->select(['id', 'title'])->first()
);
}

public function testSelectWithSubQuery()
{
$this->assertSame(
$this->assertEquals(
['id' => '1', 'title' => 'Foo Post', 'foo' => 'bar'],
(array) DB::table('posts')->select(['id', 'title', 'foo' => function ($query) {
$query->select('bar');
Expand All @@ -87,14 +87,14 @@ public function testAddSelect()
{
$expected = ['id' => '1', 'title' => 'Foo Post', 'content' => 'Lorem Ipsum.'];

$this->assertSame($expected, (array) DB::table('posts')->select('id')->addSelect('title', 'content')->first());
$this->assertSame($expected, (array) DB::table('posts')->select('id')->addSelect(['title', 'content'])->first());
$this->assertSame($expected, (array) DB::table('posts')->addSelect(['id', 'title', 'content'])->first());
$this->assertEquals($expected, (array) DB::table('posts')->select('id')->addSelect('title', 'content')->first());
$this->assertEquals($expected, (array) DB::table('posts')->select('id')->addSelect(['title', 'content'])->first());
$this->assertEquals($expected, (array) DB::table('posts')->addSelect(['id', 'title', 'content'])->first());
}

public function testAddSelectWithSubQuery()
{
$this->assertSame(
$this->assertEquals(
['id' => '1', 'title' => 'Foo Post', 'foo' => 'bar'],
(array) DB::table('posts')->addSelect(['id', 'title', 'foo' => function ($query) {
$query->select('bar');
Expand Down

0 comments on commit 133f434

Please sign in to comment.