Skip to content

Commit eae25ea

Browse files
committed
PHPLIB-462: Replace assertInternalType with type-specific methods
1 parent 89ca718 commit eae25ea

11 files changed

+34
-34
lines changed

tests/ClientTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testSelectCollectionInheritsOptions()
6767
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
6868
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
6969
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
70-
$this->assertInternalType('array', $debug['typeMap']);
70+
$this->assertIsArray($debug['typeMap']);
7171
$this->assertSame(['root' => 'array'], $debug['typeMap']);
7272
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
7373
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -90,7 +90,7 @@ public function testSelectCollectionPassesOptions()
9090
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
9191
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
9292
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
93-
$this->assertInternalType('array', $debug['typeMap']);
93+
$this->assertIsArray($debug['typeMap']);
9494
$this->assertSame(['root' => 'array'], $debug['typeMap']);
9595
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
9696
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -129,7 +129,7 @@ public function testSelectDatabaseInheritsOptions()
129129
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
130130
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
131131
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
132-
$this->assertInternalType('array', $debug['typeMap']);
132+
$this->assertIsArray($debug['typeMap']);
133133
$this->assertSame(['root' => 'array'], $debug['typeMap']);
134134
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
135135
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -152,7 +152,7 @@ public function testSelectDatabasePassesOptions()
152152
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
153153
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
154154
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
155-
$this->assertInternalType('array', $debug['typeMap']);
155+
$this->assertIsArray($debug['typeMap']);
156156
$this->assertSame(['root' => 'array'], $debug['typeMap']);
157157
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
158158
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());

tests/Collection/CollectionFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function testWithOptionsInheritsOptions()
262262
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
263263
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
264264
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
265-
$this->assertInternalType('array', $debug['typeMap']);
265+
$this->assertIsArray($debug['typeMap']);
266266
$this->assertSame(['root' => 'array'], $debug['typeMap']);
267267
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
268268
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -284,7 +284,7 @@ public function testWithOptionsPassesOptions()
284284
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
285285
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
286286
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
287-
$this->assertInternalType('array', $debug['typeMap']);
287+
$this->assertIsArray($debug['typeMap']);
288288
$this->assertSame(['root' => 'array'], $debug['typeMap']);
289289
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
290290
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());

tests/Collection/CrudSpecFunctionalTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
300300
break;
301301

302302
case 'bulkWrite':
303-
$this->assertInternalType('array', $expectedResult);
303+
$this->assertIsArray($expectedResult);
304304
$this->assertInstanceOf(\MongoDB\BulkWriteResult::class, $actualResult);
305305

306306
if (isset($expectedResult['deletedCount'])) {
@@ -357,7 +357,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
357357

358358
case 'deleteMany':
359359
case 'deleteOne':
360-
$this->assertInternalType('array', $expectedResult);
360+
$this->assertIsArray($expectedResult);
361361
$this->assertInstanceOf(\MongoDB\DeleteResult::class, $actualResult);
362362

363363
if (isset($expectedResult['deletedCount'])) {
@@ -375,7 +375,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
375375
break;
376376

377377
case 'insertMany':
378-
$this->assertInternalType('array', $expectedResult);
378+
$this->assertIsArray($expectedResult);
379379
$this->assertInstanceOf(\MongoDB\InsertManyResult::class, $actualResult);
380380

381381
if (isset($expectedResult['insertedCount'])) {
@@ -391,7 +391,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
391391
break;
392392

393393
case 'insertOne':
394-
$this->assertInternalType('array', $expectedResult);
394+
$this->assertIsArray($expectedResult);
395395
$this->assertInstanceOf(\MongoDB\InsertOneResult::class, $actualResult);
396396

397397
if (isset($expectedResult['insertedCount'])) {
@@ -409,7 +409,7 @@ private function executeAssertResult(array $operation, $expectedResult, $actualR
409409
case 'replaceOne':
410410
case 'updateMany':
411411
case 'updateOne':
412-
$this->assertInternalType('array', $expectedResult);
412+
$this->assertIsArray($expectedResult);
413413
$this->assertInstanceOf(\MongoDB\UpdateResult::class, $actualResult);
414414

415415
if (isset($expectedResult['matchedCount'])) {

tests/Database/DatabaseFunctionalTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testCommandAppliesTypeMapToCursor()
111111
$commandResult = current($cursor->toArray());
112112

113113
$this->assertCommandSucceeded($commandResult);
114-
$this->assertInternalType('array', $commandResult);
114+
$this->assertIsArray($commandResult);
115115
$this->assertArrayHasKey('ismaster', $commandResult);
116116
$this->assertTrue($commandResult['ismaster']);
117117
}
@@ -207,7 +207,7 @@ public function testSelectCollectionInheritsOptions()
207207
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
208208
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
209209
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
210-
$this->assertInternalType('array', $debug['typeMap']);
210+
$this->assertIsArray($debug['typeMap']);
211211
$this->assertSame(['root' => 'array'], $debug['typeMap']);
212212
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
213213
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -229,7 +229,7 @@ public function testSelectCollectionPassesOptions()
229229
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
230230
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
231231
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
232-
$this->assertInternalType('array', $debug['typeMap']);
232+
$this->assertIsArray($debug['typeMap']);
233233
$this->assertSame(['root' => 'array'], $debug['typeMap']);
234234
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
235235
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -303,7 +303,7 @@ public function testWithOptionsInheritsOptions()
303303
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
304304
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
305305
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
306-
$this->assertInternalType('array', $debug['typeMap']);
306+
$this->assertIsArray($debug['typeMap']);
307307
$this->assertSame(['root' => 'array'], $debug['typeMap']);
308308
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
309309
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
@@ -325,7 +325,7 @@ public function testWithOptionsPassesOptions()
325325
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
326326
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
327327
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
328-
$this->assertInternalType('array', $debug['typeMap']);
328+
$this->assertIsArray($debug['typeMap']);
329329
$this->assertSame(['root' => 'array'], $debug['typeMap']);
330330
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
331331
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());

tests/DocumentationExamplesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function testExample_38_41()
498498

499499
$this->assertSame(2, $insertManyResult->getInsertedCount());
500500
foreach ($insertManyResult->getInsertedIds() as $id) {
501-
$this->assertInternalType('int', $id);
501+
$this->assertIsInt($id);
502502
}
503503
$this->assertInventoryCount(2);
504504

tests/GridFS/BucketFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public function testOpenDownloadStreamAndMultipleReadOperations($input)
502502
$expectedReadLength = min(4096, strlen($input) - strlen($buffer));
503503
$buffer .= $read = fread($stream, 4096);
504504

505-
$this->assertInternalType('string', $read);
505+
$this->assertIsString($read);
506506
$this->assertEquals($expectedReadLength, strlen($read));
507507
}
508508

tests/GridFS/FunctionalTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function doSetUp()
3939
*/
4040
protected function assertStreamContents($expectedContents, $stream)
4141
{
42-
$this->assertInternalType('resource', $stream);
42+
$this->assertIsResource($stream);
4343
$this->assertSame('stream', get_resource_type($stream));
4444
$this->assertEquals($expectedContents, stream_get_contents($stream, -1, 0));
4545
}

tests/Operation/WatchFunctionalTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function (array $event) use (&$events) {
277277
private function assertResumeAfter($expectedResumeToken, stdClass $command)
278278
{
279279
$this->assertObjectHasAttribute('pipeline', $command);
280-
$this->assertInternalType('array', $command->pipeline);
280+
$this->assertIsArray($command->pipeline);
281281
$this->assertArrayHasKey(0, $command->pipeline);
282282
$this->assertObjectHasAttribute('$changeStream', $command->pipeline[0]);
283283
$this->assertObjectHasAttribute('resumeAfter', $command->pipeline[0]->{'$changeStream'});
@@ -354,7 +354,7 @@ function (array $event) use (&$events) {
354354
private function assertStartAtOperationTime(TimestampInterface $expectedOperationTime, stdClass $command)
355355
{
356356
$this->assertObjectHasAttribute('pipeline', $command);
357-
$this->assertInternalType('array', $command->pipeline);
357+
$this->assertIsArray($command->pipeline);
358358
$this->assertArrayHasKey(0, $command->pipeline);
359359
$this->assertObjectHasAttribute('$changeStream', $command->pipeline[0]);
360360
$this->assertObjectHasAttribute('startAtOperationTime', $command->pipeline[0]->{'$changeStream'});
@@ -1183,7 +1183,7 @@ public function testSessionFreed()
11831183
$rp = $rc->getProperty('resumeCallable');
11841184
$rp->setAccessible(true);
11851185

1186-
$this->assertInternalType('callable', $rp->getValue($changeStream));
1186+
$this->assertIsCallable($rp->getValue($changeStream));
11871187

11881188
// Invalidate the cursor to verify that resumeCallable is unset when the cursor is exhausted.
11891189
$this->dropCollection();
@@ -1210,9 +1210,9 @@ function(array $event) use (&$commands) {
12101210
private function getPostBatchResumeTokenFromReply(stdClass $reply)
12111211
{
12121212
$this->assertObjectHasAttribute('cursor', $reply);
1213-
$this->assertInternalType('object', $reply->cursor);
1213+
$this->assertIsObject($reply->cursor);
12141214
$this->assertObjectHasAttribute('postBatchResumeToken', $reply->cursor);
1215-
$this->assertInternalType('object', $reply->cursor->postBatchResumeToken);
1215+
$this->assertIsObject($reply->cursor->postBatchResumeToken);
12161216

12171217
return $reply->cursor->postBatchResumeToken;
12181218
}

tests/SpecTests/CommandMonitoringSpecTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function assertCommandMatches(stdClass $expected, stdClass $actual
3232

3333
if (isset($expected->killCursors) && isset($expected->cursors) && is_array($expected->cursors)) {
3434
static::assertObjectHasAttribute('cursors', $actual);
35-
static::assertInternalType('array', $actual->cursors);
35+
static::assertIsArray($actual->cursors);
3636

3737
foreach ($expected->cursors as $i => $cursorId) {
3838
static::assertArrayHasKey($i, $actual->cursors);
@@ -63,7 +63,7 @@ public static function assertCommandReplyMatches(stdClass $expected, stdClass $a
6363
{
6464
if (isset($expected->cursor->id) && $expected->cursor->id === 42) {
6565
static::assertObjectHasAttribute('cursor', $actual);
66-
static::assertInternalType('object', $actual->cursor);
66+
static::assertIsObject($actual->cursor);
6767
static::assertObjectHasAttribute('id', $actual->cursor);
6868
static::assertThat($actual->cursor->id, static::logicalOr(
6969
static::isInstanceOf(Int64::class),
@@ -74,7 +74,7 @@ public static function assertCommandReplyMatches(stdClass $expected, stdClass $a
7474

7575
if (isset($expected->cursorsUnknown) && is_array($expected->cursorsUnknown)) {
7676
static::assertObjectHasAttribute('cursorsUnknown', $actual);
77-
static::assertInternalType('array', $actual->cursorsUnknown);
77+
static::assertIsArray($actual->cursorsUnknown);
7878

7979
foreach ($expected->cursorsUnknown as $i => $cursorId) {
8080
static::assertArrayHasKey($i, $actual->cursorsUnknown);
@@ -92,14 +92,14 @@ public static function assertCommandReplyMatches(stdClass $expected, stdClass $a
9292

9393
if (isset($expected->ok) && is_numeric($expected->ok)) {
9494
static::assertObjectHasAttribute('ok', $actual);
95-
static::assertInternalType('numeric', $actual->ok);
95+
static::assertIsNumeric($actual->ok);
9696
static::assertEquals($expected->ok, $actual->ok);
9797
unset($expected->ok);
9898
}
9999

100100
if (isset($expected->writeErrors) && is_array($expected->writeErrors)) {
101101
static::assertObjectHasAttribute('writeErrors', $actual);
102-
static::assertInternalType('array', $actual->writeErrors);
102+
static::assertIsArray($actual->writeErrors);
103103

104104
foreach ($expected->writeErrors as $i => $expectedWriteError) {
105105
static::assertArrayHasKey($i, $actual->writeErrors);
@@ -116,7 +116,7 @@ public static function assertCommandReplyMatches(stdClass $expected, stdClass $a
116116

117117
if (isset($expectedWriteError->errmsg) && $expectedWriteError->errmsg === '') {
118118
static::assertObjectHasAttribute('errmsg', $actualWriteError);
119-
static::assertInternalType('string', $actualWriteError->errmsg);
119+
static::assertIsString($actualWriteError->errmsg);
120120
static::assertNotEmpty($actualWriteError->errmsg);
121121
unset($expected->writeErrors[$i]->errmsg);
122122
}

tests/SpecTests/ResultExpectation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function assert(TestCase $test, $actual)
216216
break;
217217

218218
case self::ASSERT_MATCHES_DOCUMENT:
219-
$test->assertInternalType('object', $expected);
219+
$test->assertIsObject($expected);
220220
$test->assertThat($actual, $test->logicalOr(
221221
$test->isType('array'),
222222
$test->isType('object')
@@ -236,7 +236,7 @@ public function assert(TestCase $test, $actual)
236236
break;
237237

238238
case self::ASSERT_SAME_DOCUMENT:
239-
$test->assertInternalType('object', $expected);
239+
$test->assertIsObject($expected);
240240
$test->assertThat($actual, $test->logicalOr(
241241
$test->isType('array'),
242242
$test->isType('object')

tests/SpecTests/TransactionsSpecTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public static function assertCommandMatches(stdClass $expected, stdClass $actual
7878

7979
if (isset($expected->recoveryToken) && $expected->recoveryToken === 42) {
8080
static::assertObjectHasAttribute('recoveryToken', $actual);
81-
static::assertInternalType('object', $actual->recoveryToken);
81+
static::assertIsObject($actual->recoveryToken);
8282
unset($expected->recoveryToken);
8383
}
8484

8585
if (isset($expected->readConcern->afterClusterTime) && $expected->readConcern->afterClusterTime === 42) {
8686
static::assertObjectHasAttribute('readConcern', $actual);
87-
static::assertInternalType('object', $actual->readConcern);
87+
static::assertIsObject($actual->readConcern);
8888
static::assertObjectHasAttribute('afterClusterTime', $actual->readConcern);
8989
static::assertInstanceOf(Timestamp::class, $actual->readConcern->afterClusterTime);
9090
unset($expected->readConcern->afterClusterTime);

0 commit comments

Comments
 (0)