Skip to content

Commit d89b025

Browse files
author
Lucas Michot
authored
Always use stricter string assertions. (#36654)
1 parent 56dcc1e commit d89b025

17 files changed

+60
-60
lines changed

tests/Bus/BusBatchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public function test_chain_can_be_added_to_batch()
333333

334334
$this->assertEquals(3, $batch->totalJobs);
335335
$this->assertEquals(3, $batch->pendingJobs);
336-
$this->assertEquals('test-queue', $chainHeadJob->chainQueue);
336+
$this->assertSame('test-queue', $chainHeadJob->chainQueue);
337337
$this->assertTrue(is_string($chainHeadJob->batchId));
338338
$this->assertTrue(is_string($secondJob->batchId));
339339
$this->assertTrue(is_string($thirdJob->batchId));

tests/Container/ContextualBindingTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ public function testContextualBindingGivesValuesFromConfigOptionalValueNull()
386386

387387
$resolvedInstance = $container->make(ContainerTestContextInjectFromConfigIndividualValues::class);
388388

389-
$this->assertEquals('laravel', $resolvedInstance->username);
390-
$this->assertEquals('hunter42', $resolvedInstance->password);
389+
$this->assertSame('laravel', $resolvedInstance->username);
390+
$this->assertSame('hunter42', $resolvedInstance->password);
391391
$this->assertNull($resolvedInstance->alias);
392392
}
393393

@@ -422,9 +422,9 @@ public function testContextualBindingGivesValuesFromConfigOptionalValueSet()
422422

423423
$resolvedInstance = $container->make(ContainerTestContextInjectFromConfigIndividualValues::class);
424424

425-
$this->assertEquals('laravel', $resolvedInstance->username);
426-
$this->assertEquals('hunter42', $resolvedInstance->password);
427-
$this->assertEquals('lumen', $resolvedInstance->alias);
425+
$this->assertSame('laravel', $resolvedInstance->username);
426+
$this->assertSame('hunter42', $resolvedInstance->password);
427+
$this->assertSame('lumen', $resolvedInstance->alias);
428428
}
429429

430430
public function testContextualBindingGivesValuesFromConfigWithDefault()
@@ -451,8 +451,8 @@ public function testContextualBindingGivesValuesFromConfigWithDefault()
451451

452452
$resolvedInstance = $container->make(ContainerTestContextInjectFromConfigIndividualValues::class);
453453

454-
$this->assertEquals('DEFAULT_USERNAME', $resolvedInstance->username);
455-
$this->assertEquals('hunter42', $resolvedInstance->password);
454+
$this->assertSame('DEFAULT_USERNAME', $resolvedInstance->username);
455+
$this->assertSame('hunter42', $resolvedInstance->password);
456456
$this->assertNull($resolvedInstance->alias);
457457
}
458458

@@ -477,9 +477,9 @@ public function testContextualBindingGivesValuesFromConfigArray()
477477

478478
$resolvedInstance = $container->make(ContainerTestContextInjectFromConfigArray::class);
479479

480-
$this->assertEquals('laravel', $resolvedInstance->settings['username']);
481-
$this->assertEquals('hunter42', $resolvedInstance->settings['password']);
482-
$this->assertEquals('lumen', $resolvedInstance->settings['alias']);
480+
$this->assertSame('laravel', $resolvedInstance->settings['username']);
481+
$this->assertSame('hunter42', $resolvedInstance->settings['password']);
482+
$this->assertSame('lumen', $resolvedInstance->settings['alias']);
483483
}
484484
}
485485

tests/Database/DatabaseEloquentBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public function testGlobalMacrosAreCalledOnBuilder()
467467
$builder = $this->getBuilder();
468468

469469
$this->assertTrue(Builder::hasGlobalMacro('foo'));
470-
$this->assertEquals('bar', $builder->foo('bar'));
470+
$this->assertSame('bar', $builder->foo('bar'));
471471
$this->assertEquals($builder->bam(), $builder->getQuery());
472472
}
473473

tests/Database/DatabaseEloquentFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public function test_can_be_macroable()
481481
return 'Hello World';
482482
});
483483

484-
$this->assertEquals('Hello World', $factory->getFoo());
484+
$this->assertSame('Hello World', $factory->getFoo());
485485
}
486486

487487
/**

tests/Database/DatabaseEloquentIntegrationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,14 +1377,14 @@ public function testFreshMethodOnCollection()
13771377
EloquentTestUser::find(2)->update(['email' => '[email protected]']);
13781378

13791379
$this->assertCount(3, $users);
1380-
$this->assertNotEquals('Mathieu TUDISCO', $users[0]->name);
1381-
$this->assertNotEquals('[email protected]', $users[1]->email);
1380+
$this->assertNotSame('Mathieu TUDISCO', $users[0]->name);
1381+
$this->assertNotSame('[email protected]', $users[1]->email);
13821382

13831383
$refreshedUsers = $users->fresh();
13841384

13851385
$this->assertCount(2, $refreshedUsers);
1386-
$this->assertEquals('Mathieu TUDISCO', $refreshedUsers[0]->name);
1387-
$this->assertEquals('[email protected]', $refreshedUsers[1]->email);
1386+
$this->assertSame('Mathieu TUDISCO', $refreshedUsers[0]->name);
1387+
$this->assertSame('[email protected]', $refreshedUsers[1]->email);
13881388
}
13891389

13901390
public function testTimestampsUsingDefaultDateFormat()
@@ -1817,10 +1817,10 @@ public function testMorphPivotsCanBeRefreshed()
18171817
]);
18181818

18191819
$this->assertInstanceOf(MorphPivot::class, $freshPivot = $pivot->fresh());
1820-
$this->assertEquals('primary', $freshPivot->taxonomy);
1820+
$this->assertSame('primary', $freshPivot->taxonomy);
18211821

18221822
$this->assertSame($pivot, $pivot->refresh());
1823-
$this->assertEquals('primary', $pivot->taxonomy);
1823+
$this->assertSame('primary', $pivot->taxonomy);
18241824
}
18251825

18261826
/**

tests/Database/DatabaseQueryBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function testWhenCallbackWithReturn()
198198
public function testWhenCallbackWithDefault()
199199
{
200200
$callback = function ($query, $condition) {
201-
$this->assertEquals('truthy', $condition);
201+
$this->assertSame('truthy', $condition);
202202

203203
$query->where('id', '=', 1);
204204
};
@@ -263,7 +263,7 @@ public function testUnlessCallbackWithDefault()
263263
};
264264

265265
$default = function ($query, $condition) {
266-
$this->assertEquals('truthy', $condition);
266+
$this->assertSame('truthy', $condition);
267267

268268
$query->where('id', '=', 2);
269269
};

tests/Database/DatabaseTransactionsManagerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public function testBeginningTransactions()
1616
$manager->begin('admin', 1);
1717

1818
$this->assertCount(3, $manager->getTransactions());
19-
$this->assertEquals('default', $manager->getTransactions()[0]->connection);
19+
$this->assertSame('default', $manager->getTransactions()[0]->connection);
2020
$this->assertEquals(1, $manager->getTransactions()[0]->level);
21-
$this->assertEquals('default', $manager->getTransactions()[1]->connection);
21+
$this->assertSame('default', $manager->getTransactions()[1]->connection);
2222
$this->assertEquals(2, $manager->getTransactions()[1]->level);
23-
$this->assertEquals('admin', $manager->getTransactions()[2]->connection);
23+
$this->assertSame('admin', $manager->getTransactions()[2]->connection);
2424
$this->assertEquals(1, $manager->getTransactions()[2]->level);
2525
}
2626

@@ -36,10 +36,10 @@ public function testRollingBackTransactions()
3636

3737
$this->assertCount(2, $manager->getTransactions());
3838

39-
$this->assertEquals('default', $manager->getTransactions()[0]->connection);
39+
$this->assertSame('default', $manager->getTransactions()[0]->connection);
4040
$this->assertEquals(1, $manager->getTransactions()[0]->level);
4141

42-
$this->assertEquals('admin', $manager->getTransactions()[1]->connection);
42+
$this->assertSame('admin', $manager->getTransactions()[1]->connection);
4343
$this->assertEquals(1, $manager->getTransactions()[1]->level);
4444
}
4545

@@ -55,7 +55,7 @@ public function testRollingBackTransactionsAllTheWay()
5555

5656
$this->assertCount(1, $manager->getTransactions());
5757

58-
$this->assertEquals('admin', $manager->getTransactions()[0]->connection);
58+
$this->assertSame('admin', $manager->getTransactions()[0]->connection);
5959
$this->assertEquals(1, $manager->getTransactions()[0]->level);
6060
}
6161

@@ -71,7 +71,7 @@ public function testCommittingTransactions()
7171

7272
$this->assertCount(1, $manager->getTransactions());
7373

74-
$this->assertEquals('admin', $manager->getTransactions()[0]->connection);
74+
$this->assertSame('admin', $manager->getTransactions()[0]->connection);
7575
$this->assertEquals(1, $manager->getTransactions()[0]->level);
7676
}
7777

tests/Integration/Database/DatabaseSchemaBuilderAlterTableWithEnumTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testGetAllTablesAndColumnListing()
3030
$tables = Schema::getAllTables();
3131

3232
$this->assertCount(1, $tables);
33-
$this->assertEquals('stdClass', get_class($tables[0]));
33+
$this->assertSame('stdClass', get_class($tables[0]));
3434

3535
$tableProperties = array_values((array) $tables[0]);
3636
$this->assertEquals(['users', 'BASE TABLE'], $tableProperties);

tests/Integration/Queue/JobDispatchingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testJobCanUseCustomMethodsAfterDispatch()
2727
Job::dispatch('test')->replaceValue('new-test');
2828

2929
$this->assertTrue(Job::$ran);
30-
$this->assertEquals('new-test', Job::$value);
30+
$this->assertSame('new-test', Job::$value);
3131
}
3232
}
3333

tests/Integration/Queue/ModelSerializationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ public function testItSerializesACollectionInCorrectOrder()
232232

233233
$unserialized = unserialize($serialized);
234234

235-
$this->assertEquals('[email protected]', $unserialized->users->first()->email);
236-
$this->assertEquals('[email protected]', $unserialized->users->last()->email);
235+
$this->assertSame('[email protected]', $unserialized->users->first()->email);
236+
$this->assertSame('[email protected]', $unserialized->users->last()->email);
237237
}
238238

239239
public function testItCanUnserializeACollectionInCorrectOrderAndHandleDeletedModels()
@@ -252,8 +252,8 @@ public function testItCanUnserializeACollectionInCorrectOrderAndHandleDeletedMod
252252

253253
$this->assertCount(2, $unserialized->users);
254254

255-
$this->assertEquals('[email protected]', $unserialized->users->first()->email);
256-
$this->assertEquals('[email protected]', $unserialized->users->last()->email);
255+
$this->assertSame('[email protected]', $unserialized->users->first()->email);
256+
$this->assertSame('[email protected]', $unserialized->users->last()->email);
257257
}
258258

259259
public function testItCanUnserializeCustomCollection()

0 commit comments

Comments
 (0)