PHPLIB-462: Replace assertInternalType with type-specific methods

parent 82418090
......@@ -67,7 +67,7 @@ class ClientTest extends TestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -90,7 +90,7 @@ class ClientTest extends TestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -129,7 +129,7 @@ class ClientTest extends TestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -152,7 +152,7 @@ class ClientTest extends TestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......
......@@ -262,7 +262,7 @@ class CollectionFunctionalTest extends FunctionalTestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -284,7 +284,7 @@ class CollectionFunctionalTest extends FunctionalTestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......
......@@ -300,7 +300,7 @@ class CrudSpecFunctionalTest extends FunctionalTestCase
break;
case 'bulkWrite':
$this->assertInternalType('array', $expectedResult);
$this->assertIsArray($expectedResult);
$this->assertInstanceOf(\MongoDB\BulkWriteResult::class, $actualResult);
if (isset($expectedResult['deletedCount'])) {
......@@ -357,7 +357,7 @@ class CrudSpecFunctionalTest extends FunctionalTestCase
case 'deleteMany':
case 'deleteOne':
$this->assertInternalType('array', $expectedResult);
$this->assertIsArray($expectedResult);
$this->assertInstanceOf(\MongoDB\DeleteResult::class, $actualResult);
if (isset($expectedResult['deletedCount'])) {
......@@ -375,7 +375,7 @@ class CrudSpecFunctionalTest extends FunctionalTestCase
break;
case 'insertMany':
$this->assertInternalType('array', $expectedResult);
$this->assertIsArray($expectedResult);
$this->assertInstanceOf(\MongoDB\InsertManyResult::class, $actualResult);
if (isset($expectedResult['insertedCount'])) {
......@@ -391,7 +391,7 @@ class CrudSpecFunctionalTest extends FunctionalTestCase
break;
case 'insertOne':
$this->assertInternalType('array', $expectedResult);
$this->assertIsArray($expectedResult);
$this->assertInstanceOf(\MongoDB\InsertOneResult::class, $actualResult);
if (isset($expectedResult['insertedCount'])) {
......@@ -409,7 +409,7 @@ class CrudSpecFunctionalTest extends FunctionalTestCase
case 'replaceOne':
case 'updateMany':
case 'updateOne':
$this->assertInternalType('array', $expectedResult);
$this->assertIsArray($expectedResult);
$this->assertInstanceOf(\MongoDB\UpdateResult::class, $actualResult);
if (isset($expectedResult['matchedCount'])) {
......
......@@ -111,7 +111,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
$commandResult = current($cursor->toArray());
$this->assertCommandSucceeded($commandResult);
$this->assertInternalType('array', $commandResult);
$this->assertIsArray($commandResult);
$this->assertArrayHasKey('ismaster', $commandResult);
$this->assertTrue($commandResult['ismaster']);
}
......@@ -207,7 +207,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -229,7 +229,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -303,7 +303,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......@@ -325,7 +325,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
$this->assertSame(ReadConcern::LOCAL, $debug['readConcern']->getLevel());
$this->assertInstanceOf(\MongoDB\Driver\ReadPreference::class, $debug['readPreference']);
$this->assertSame(ReadPreference::RP_SECONDARY_PREFERRED, $debug['readPreference']->getMode());
$this->assertInternalType('array', $debug['typeMap']);
$this->assertIsArray($debug['typeMap']);
$this->assertSame(['root' => 'array'], $debug['typeMap']);
$this->assertInstanceOf(\MongoDB\Driver\WriteConcern::class, $debug['writeConcern']);
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
......
......@@ -498,7 +498,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertSame(2, $insertManyResult->getInsertedCount());
foreach ($insertManyResult->getInsertedIds() as $id) {
$this->assertInternalType('int', $id);
$this->assertIsInt($id);
}
$this->assertInventoryCount(2);
......
......@@ -502,7 +502,7 @@ class BucketFunctionalTest extends FunctionalTestCase
$expectedReadLength = min(4096, strlen($input) - strlen($buffer));
$buffer .= $read = fread($stream, 4096);
$this->assertInternalType('string', $read);
$this->assertIsString($read);
$this->assertEquals($expectedReadLength, strlen($read));
}
......
......@@ -39,7 +39,7 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
*/
protected function assertStreamContents($expectedContents, $stream)
{
$this->assertInternalType('resource', $stream);
$this->assertIsResource($stream);
$this->assertSame('stream', get_resource_type($stream));
$this->assertEquals($expectedContents, stream_get_contents($stream, -1, 0));
}
......
......@@ -277,7 +277,7 @@ class WatchFunctionalTest extends FunctionalTestCase
private function assertResumeAfter($expectedResumeToken, stdClass $command)
{
$this->assertObjectHasAttribute('pipeline', $command);
$this->assertInternalType('array', $command->pipeline);
$this->assertIsArray($command->pipeline);
$this->assertArrayHasKey(0, $command->pipeline);
$this->assertObjectHasAttribute('$changeStream', $command->pipeline[0]);
$this->assertObjectHasAttribute('resumeAfter', $command->pipeline[0]->{'$changeStream'});
......@@ -354,7 +354,7 @@ class WatchFunctionalTest extends FunctionalTestCase
private function assertStartAtOperationTime(TimestampInterface $expectedOperationTime, stdClass $command)
{
$this->assertObjectHasAttribute('pipeline', $command);
$this->assertInternalType('array', $command->pipeline);
$this->assertIsArray($command->pipeline);
$this->assertArrayHasKey(0, $command->pipeline);
$this->assertObjectHasAttribute('$changeStream', $command->pipeline[0]);
$this->assertObjectHasAttribute('startAtOperationTime', $command->pipeline[0]->{'$changeStream'});
......@@ -1183,7 +1183,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$rp = $rc->getProperty('resumeCallable');
$rp->setAccessible(true);
$this->assertInternalType('callable', $rp->getValue($changeStream));
$this->assertIsCallable($rp->getValue($changeStream));
// Invalidate the cursor to verify that resumeCallable is unset when the cursor is exhausted.
$this->dropCollection();
......@@ -1210,9 +1210,9 @@ class WatchFunctionalTest extends FunctionalTestCase
private function getPostBatchResumeTokenFromReply(stdClass $reply)
{
$this->assertObjectHasAttribute('cursor', $reply);
$this->assertInternalType('object', $reply->cursor);
$this->assertIsObject($reply->cursor);
$this->assertObjectHasAttribute('postBatchResumeToken', $reply->cursor);
$this->assertInternalType('object', $reply->cursor->postBatchResumeToken);
$this->assertIsObject($reply->cursor->postBatchResumeToken);
return $reply->cursor->postBatchResumeToken;
}
......
......@@ -32,7 +32,7 @@ class CommandMonitoringSpecTest extends FunctionalTestCase
if (isset($expected->killCursors) && isset($expected->cursors) && is_array($expected->cursors)) {
static::assertObjectHasAttribute('cursors', $actual);
static::assertInternalType('array', $actual->cursors);
static::assertIsArray($actual->cursors);
foreach ($expected->cursors as $i => $cursorId) {
static::assertArrayHasKey($i, $actual->cursors);
......@@ -63,7 +63,7 @@ class CommandMonitoringSpecTest extends FunctionalTestCase
{
if (isset($expected->cursor->id) && $expected->cursor->id === 42) {
static::assertObjectHasAttribute('cursor', $actual);
static::assertInternalType('object', $actual->cursor);
static::assertIsObject($actual->cursor);
static::assertObjectHasAttribute('id', $actual->cursor);
static::assertThat($actual->cursor->id, static::logicalOr(
static::isInstanceOf(Int64::class),
......@@ -74,7 +74,7 @@ class CommandMonitoringSpecTest extends FunctionalTestCase
if (isset($expected->cursorsUnknown) && is_array($expected->cursorsUnknown)) {
static::assertObjectHasAttribute('cursorsUnknown', $actual);
static::assertInternalType('array', $actual->cursorsUnknown);
static::assertIsArray($actual->cursorsUnknown);
foreach ($expected->cursorsUnknown as $i => $cursorId) {
static::assertArrayHasKey($i, $actual->cursorsUnknown);
......@@ -92,14 +92,14 @@ class CommandMonitoringSpecTest extends FunctionalTestCase
if (isset($expected->ok) && is_numeric($expected->ok)) {
static::assertObjectHasAttribute('ok', $actual);
static::assertInternalType('numeric', $actual->ok);
static::assertIsNumeric($actual->ok);
static::assertEquals($expected->ok, $actual->ok);
unset($expected->ok);
}
if (isset($expected->writeErrors) && is_array($expected->writeErrors)) {
static::assertObjectHasAttribute('writeErrors', $actual);
static::assertInternalType('array', $actual->writeErrors);
static::assertIsArray($actual->writeErrors);
foreach ($expected->writeErrors as $i => $expectedWriteError) {
static::assertArrayHasKey($i, $actual->writeErrors);
......@@ -116,7 +116,7 @@ class CommandMonitoringSpecTest extends FunctionalTestCase
if (isset($expectedWriteError->errmsg) && $expectedWriteError->errmsg === '') {
static::assertObjectHasAttribute('errmsg', $actualWriteError);
static::assertInternalType('string', $actualWriteError->errmsg);
static::assertIsString($actualWriteError->errmsg);
static::assertNotEmpty($actualWriteError->errmsg);
unset($expected->writeErrors[$i]->errmsg);
}
......
......@@ -216,7 +216,7 @@ final class ResultExpectation
break;
case self::ASSERT_MATCHES_DOCUMENT:
$test->assertInternalType('object', $expected);
$test->assertIsObject($expected);
$test->assertThat($actual, $test->logicalOr(
$test->isType('array'),
$test->isType('object')
......@@ -236,7 +236,7 @@ final class ResultExpectation
break;
case self::ASSERT_SAME_DOCUMENT:
$test->assertInternalType('object', $expected);
$test->assertIsObject($expected);
$test->assertThat($actual, $test->logicalOr(
$test->isType('array'),
$test->isType('object')
......
......@@ -78,13 +78,13 @@ class TransactionsSpecTest extends FunctionalTestCase
if (isset($expected->recoveryToken) && $expected->recoveryToken === 42) {
static::assertObjectHasAttribute('recoveryToken', $actual);
static::assertInternalType('object', $actual->recoveryToken);
static::assertIsObject($actual->recoveryToken);
unset($expected->recoveryToken);
}
if (isset($expected->readConcern->afterClusterTime) && $expected->readConcern->afterClusterTime === 42) {
static::assertObjectHasAttribute('readConcern', $actual);
static::assertInternalType('object', $actual->readConcern);
static::assertIsObject($actual->readConcern);
static::assertObjectHasAttribute('afterClusterTime', $actual->readConcern);
static::assertInstanceOf(Timestamp::class, $actual->readConcern->afterClusterTime);
unset($expected->readConcern->afterClusterTime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment