diff --git a/tests/snippets/Core/Iam/PolicyBuilderTest.php b/tests/snippets/Core/Iam/PolicyBuilderTest.php index 546d128f94e..1928836b3ef 100644 --- a/tests/snippets/Core/Iam/PolicyBuilderTest.php +++ b/tests/snippets/Core/Iam/PolicyBuilderTest.php @@ -39,7 +39,7 @@ public function testClass() $snippet = $this->snippetFromClass(PolicyBuilder::class); $res = $snippet->invoke('result'); - $this->assertTrue(is_array($res->returnVal())); + $this->assertInternalType('array', $res->returnVal()); } public function testSetBindings() @@ -97,6 +97,6 @@ public function testResult() $snippet->addLocal('builder', $this->pb); $res = $snippet->invoke('policy'); - $this->assertTrue(is_array($res->returnVal())); + $this->assertInternalType('array', $res->returnVal()); } } diff --git a/tests/snippets/Datastore/DatastoreClientTest.php b/tests/snippets/Datastore/DatastoreClientTest.php index e12caf10c27..a7f560aecf3 100644 --- a/tests/snippets/Datastore/DatastoreClientTest.php +++ b/tests/snippets/Datastore/DatastoreClientTest.php @@ -131,7 +131,7 @@ public function testKeys() $snippet->addLocal('datastore', $this->client); $res = $snippet->invoke('keys'); - $this->assertTrue(is_array($res->returnVal())); + $this->assertInternalType('array', $res->returnVal()); $this->assertEquals(10, count($res->returnVal())); $this->assertInstanceOf(Key::class, $res->returnVal()[0]); $this->assertEquals('Person', $res->returnVal()[0]->keyObject()['path'][0]['kind']); @@ -144,7 +144,7 @@ public function testKeysWithAncestors() $res = $snippet->invoke('keys'); - $this->assertTrue(is_array($res->returnVal())); + $this->assertInternalType('array', $res->returnVal()); $this->assertEquals(3, count($res->returnVal())); $this->assertInstanceOf(Key::class, $res->returnVal()[0]); diff --git a/tests/snippets/PubSub/MessageTest.php b/tests/snippets/PubSub/MessageTest.php index 4b8fdeda287..0a256e5e313 100644 --- a/tests/snippets/PubSub/MessageTest.php +++ b/tests/snippets/PubSub/MessageTest.php @@ -158,6 +158,6 @@ public function testInfo() $snippet->addLocal('message', $this->message); $res = $snippet->invoke('info'); - $this->assertTrue(is_array($res->returnVal())); + $this->assertInternalType('array', $res->returnVal()); } } diff --git a/tests/snippets/Spanner/KeySetTest.php b/tests/snippets/Spanner/KeySetTest.php index c46b5aebe78..4c092728778 100644 --- a/tests/snippets/Spanner/KeySetTest.php +++ b/tests/snippets/Spanner/KeySetTest.php @@ -99,7 +99,7 @@ public function testAddKey() $this->assertEmpty($this->keyset->keys()); $res = $snippet->invoke(); - $this->assertEquals(1, count($this->keyset->keys())); + $this->assertCount(1, $this->keyset->keys()); } public function testSetKeys() @@ -110,7 +110,7 @@ public function testSetKeys() $this->assertEmpty($this->keyset->keys()); $res = $snippet->invoke(); - $this->assertEquals(2, count($this->keyset->keys())); + $this->assertCount(2, $this->keyset->keys()); } public function testMatchAll() diff --git a/tests/snippets/Storage/StorageObjectTest.php b/tests/snippets/Storage/StorageObjectTest.php index c14c9b5ef2f..41f31db7def 100644 --- a/tests/snippets/Storage/StorageObjectTest.php +++ b/tests/snippets/Storage/StorageObjectTest.php @@ -388,9 +388,9 @@ public function testSignedUrl() $this->object->___setProperty('connection', $conn->reveal()); $res = $snippet->invoke('url'); - $this->assertTrue(strpos($res->returnVal(), 'https://storage.googleapis.com/my-bucket/my-object') !== false); - $this->assertTrue(strpos($res->returnVal(), 'Expires=') !== false); - $this->assertTrue(strpos($res->returnVal(), 'Signature=') !== false); + $this->assertContains('https://storage.googleapis.com/my-bucket/my-object', $res->returnVal()); + $this->assertContains('Expires=', $res->returnVal()); + $this->assertContains('Signature=', $res->returnVal()); } public function testSignedUrlUpdate() @@ -414,9 +414,9 @@ public function testSignedUrlUpdate() $this->object->___setProperty('connection', $conn->reveal()); $res = $snippet->invoke('url'); - $this->assertTrue(strpos($res->returnVal(), 'https://storage.googleapis.com/my-bucket/my-object') !== false); - $this->assertTrue(strpos($res->returnVal(), 'Expires=') !== false); - $this->assertTrue(strpos($res->returnVal(), 'Signature=') !== false); + $this->assertContains('https://storage.googleapis.com/my-bucket/my-object', $res->returnVal()); + $this->assertContains('Expires=', $res->returnVal()); + $this->assertContains('Signature=', $res->returnVal()); } public function testSignedUploadUrl() @@ -440,9 +440,9 @@ public function testSignedUploadUrl() $this->object->___setProperty('connection', $conn->reveal()); $res = $snippet->invoke('url'); - $this->assertTrue(strpos($res->returnVal(), 'https://storage.googleapis.com/my-bucket/my-object') !== false); - $this->assertTrue(strpos($res->returnVal(), 'Expires=') !== false); - $this->assertTrue(strpos($res->returnVal(), 'Signature=') !== false); + $this->assertContains('https://storage.googleapis.com/my-bucket/my-object', $res->returnVal()); + $this->assertContains('Expires=', $res->returnVal()); + $this->assertContains('Signature=', $res->returnVal()); } public function testBeginSignedUploadSession() diff --git a/tests/snippets/Vision/AnnotationTest.php b/tests/snippets/Vision/AnnotationTest.php index 16f9dd15845..63d4c825a50 100644 --- a/tests/snippets/Vision/AnnotationTest.php +++ b/tests/snippets/Vision/AnnotationTest.php @@ -198,6 +198,6 @@ public function testError() ])); $res = $snippet->invoke('error'); - $this->assertTrue(is_array($res->returnVal())); + $this->assertInternalType('array', $res->returnVal()); } } diff --git a/tests/system/Datastore/AllocateKeyTest.php b/tests/system/Datastore/AllocateKeyTest.php index a74dfc007bc..495e640591f 100644 --- a/tests/system/Datastore/AllocateKeyTest.php +++ b/tests/system/Datastore/AllocateKeyTest.php @@ -29,7 +29,7 @@ public function testAllocateId() $key = self::$client->key($kind); $path = self::$client->allocateId($key)->path()[0]; - $this->assertTrue(is_numeric($path['id'])); + $this->assertInternalType('numeric', $path['id']); $this->assertEquals($kind, $path['kind']); } @@ -41,7 +41,7 @@ public function testAllocateIds() foreach ($allocatedKeys as $key) { $path = $key->path()[0]; - $this->assertTrue(is_numeric($path['id'])); + $this->assertInternalType('numeric', $path['id']); $this->assertEquals($kind, $path['kind']); } } diff --git a/tests/system/ServiceWhitelist/WhitelistTest.php b/tests/system/ServiceWhitelist/WhitelistTest.php index 9f7b73c8ec3..a221f9f16d5 100644 --- a/tests/system/ServiceWhitelist/WhitelistTest.php +++ b/tests/system/ServiceWhitelist/WhitelistTest.php @@ -150,6 +150,6 @@ private function checkException(callable $call) $this->assertTrue($thrown); $this->assertInstanceOf(NotFoundException::class, $ex); - $this->assertTrue(strpos($ex->getMessage(), self::MESSAGE) !== false); + $this->assertContains(self::MESSAGE, $ex->getMessage()); } } diff --git a/tests/system/Spanner/ReadTest.php b/tests/system/Spanner/ReadTest.php index efcd3e002fa..ef2df252352 100644 --- a/tests/system/Spanner/ReadTest.php +++ b/tests/system/Spanner/ReadTest.php @@ -84,8 +84,8 @@ public function testRangeReadSingleKeyOpen() $res = $db->read(self::$rangeTableName, $keyset, array_keys(self::$dataset[0])); $rows = iterator_to_array($res->rows()); - $this->assertFalse(in_array(self::$dataset[0], $rows)); - $this->assertFalse(in_array(self::$dataset[10], $rows)); + $this->assertNotContains(self::$dataset[0], $rows); + $this->assertNotContains(self::$dataset[10], $rows); } /** @@ -106,8 +106,8 @@ public function testRangeReadSingleKeyClosed() $res = $db->read(self::$rangeTableName, $keyset, array_keys(self::$dataset[0])); $rows = iterator_to_array($res->rows()); - $this->assertTrue(in_array(self::$dataset[0], $rows)); - $this->assertTrue(in_array(self::$dataset[10], $rows)); + $this->assertContains(self::$dataset[0], $rows); + $this->assertContains(self::$dataset[10], $rows); } /** @@ -127,8 +127,8 @@ public function testRangeReadSingleKeyOpenClosed() $res = $db->read(self::$rangeTableName, $keyset, array_keys(self::$dataset[0])); $rows = iterator_to_array($res->rows()); - $this->assertFalse(in_array(self::$dataset[0], $rows)); - $this->assertTrue(in_array(self::$dataset[10], $rows)); + $this->assertNotContains(self::$dataset[0], $rows); + $this->assertContains(self::$dataset[10], $rows); } /** @@ -148,8 +148,8 @@ public function testRangeReadSingleKeyClosedOpen() $res = $db->read(self::$rangeTableName, $keyset, array_keys(self::$dataset[0])); $rows = iterator_to_array($res->rows()); - $this->assertTrue(in_array(self::$dataset[0], $rows)); - $this->assertFalse(in_array(self::$dataset[10], $rows)); + $this->assertContains(self::$dataset[0], $rows); + $this->assertNotContains(self::$dataset[10], $rows); } /** @@ -168,8 +168,8 @@ public function testRangeReadPartialKeyOpen() $res = $db->read(self::$rangeTableName, $keyset, array_keys(self::$dataset[0])); $rows = iterator_to_array($res->rows()); - $this->assertFalse(in_array(self::$dataset[0], $rows)); - $this->assertFalse(in_array(self::$dataset[10], $rows)); + $this->assertNotContains(self::$dataset[0], $rows); + $this->assertNotContains(self::$dataset[10], $rows); } /** @@ -190,8 +190,8 @@ public function testRangeReadPartialKeyClosed() $res = $db->read(self::$rangeTableName, $keyset, array_keys(self::$dataset[0])); $rows = iterator_to_array($res->rows()); - $this->assertTrue(in_array(self::$dataset[0], $rows)); - $this->assertTrue(in_array(self::$dataset[10], $rows)); + $this->assertContains(self::$dataset[0], $rows); + $this->assertContains(self::$dataset[10], $rows); } /** @@ -212,8 +212,8 @@ public function testRangeReadIndexSingleKeyOpen() 'index' => $this->getIndexName(self::$rangeTableName, 'complex') ]); $rows = iterator_to_array($res->rows()); - $this->assertFalse(in_array(self::$dataset[0], $rows)); - $this->assertFalse(in_array(self::$dataset[10], $rows)); + $this->assertNotContains(self::$dataset[0], $rows); + $this->assertNotContains(self::$dataset[10], $rows); } /** @@ -236,8 +236,8 @@ public function testRangeReadIndexSingleKeyClosed() 'index' => $this->getIndexName(self::$rangeTableName, 'complex') ]); $rows = iterator_to_array($res->rows()); - $this->assertTrue(in_array(self::$dataset[0], $rows)); - $this->assertTrue(in_array(self::$dataset[10], $rows)); + $this->assertContains(self::$dataset[0], $rows); + $this->assertContains(self::$dataset[10], $rows); } /** @@ -259,8 +259,8 @@ public function testRangeReadIndexSingleKeyOpenClosed() 'index' => $this->getIndexName(self::$rangeTableName, 'complex') ]); $rows = iterator_to_array($res->rows()); - $this->assertFalse(in_array(self::$dataset[0], $rows)); - $this->assertTrue(in_array(self::$dataset[10], $rows)); + $this->assertNotContains(self::$dataset[0], $rows); + $this->assertContains(self::$dataset[10], $rows); } /** @@ -282,8 +282,8 @@ public function testRangeReadIndexSingleKeyClosedOpen() 'index' => $this->getIndexName(self::$rangeTableName, 'complex') ]); $rows = iterator_to_array($res->rows()); - $this->assertTrue(in_array(self::$dataset[0], $rows)); - $this->assertFalse(in_array(self::$dataset[10], $rows)); + $this->assertContains(self::$dataset[0], $rows); + $this->assertNotContains(self::$dataset[10], $rows); } /** @@ -304,8 +304,8 @@ public function testRangeReadIndexPartialKeyOpen() 'index' => $this->getIndexName(self::$rangeTableName, 'complex') ]); $rows = iterator_to_array($res->rows()); - $this->assertFalse(in_array(self::$dataset[0], $rows)); - $this->assertFalse(in_array(self::$dataset[10], $rows)); + $this->assertNotContains(self::$dataset[0], $rows); + $this->assertNotContains(self::$dataset[10], $rows); } /** @@ -328,8 +328,8 @@ public function testRangeReadIndexPartialKeyClosed() 'index' => $this->getIndexName(self::$rangeTableName, 'complex') ]); $rows = iterator_to_array($res->rows()); - $this->assertTrue(in_array(self::$dataset[0], $rows)); - $this->assertTrue(in_array(self::$dataset[10], $rows)); + $this->assertContains(self::$dataset[0], $rows); + $this->assertContains(self::$dataset[10], $rows); } /** @@ -398,8 +398,8 @@ public function testReadPoint() $res = $db->read(self::$readTableName, $keyset, array_keys($dataset[0])); $rows = $res->rows(); foreach ($rows as $index => $row) { - $this->assertTrue(in_array($row, $dataset)); - $this->assertTrue(in_array($row, $points)); + $this->assertContains($row, $dataset); + $this->assertContains($row, $points); } } @@ -428,8 +428,8 @@ public function testReadPointOverIndex() ]); $rows = $res->rows(); foreach ($rows as $index => $row) { - $this->assertTrue(in_array($row, $dataset)); - $this->assertTrue(in_array($row, $points)); + $this->assertContains($row, $dataset); + $this->assertContains($row, $points); } } diff --git a/tests/system/Spanner/TransactionTest.php b/tests/system/Spanner/TransactionTest.php index ecd62d51bc2..8a525b16089 100644 --- a/tests/system/Spanner/TransactionTest.php +++ b/tests/system/Spanner/TransactionTest.php @@ -107,7 +107,7 @@ public function testConcurrentTransactionsIncrementValueWithRead() ])->rows()->current(); $this->assertEquals(2, $row['number']); - $this->assertTrue($iterations > 2); + $this->assertGreaterThan(2, $iterations); } /** @@ -194,7 +194,7 @@ public function testConcurrentTransactionsIncrementValueWithExecute() ])->rows()->current(); $this->assertEquals(2, $row['number']); - $this->assertTrue($iterations > 2); + $this->assertGreaterThan(2, $iterations); } public function testStrongRead() diff --git a/tests/system/Storage/ManageObjectsTest.php b/tests/system/Storage/ManageObjectsTest.php index 6a3ea654db2..dd4fd3e518d 100644 --- a/tests/system/Storage/ManageObjectsTest.php +++ b/tests/system/Storage/ManageObjectsTest.php @@ -141,7 +141,7 @@ public function testDownloadsAsString() { $content = self::$object->downloadAsString(); - $this->assertTrue(is_string($content)); + $this->assertInternalType('string', $content); } public function testDownloadsAsStream() diff --git a/tests/system/Storage/StreamWrapper/DirectoryTest.php b/tests/system/Storage/StreamWrapper/DirectoryTest.php index a7e1883430a..50055513133 100644 --- a/tests/system/Storage/StreamWrapper/DirectoryTest.php +++ b/tests/system/Storage/StreamWrapper/DirectoryTest.php @@ -37,7 +37,7 @@ public function testMkDir() { $dir = self::generateUrl('test_directory'); $this->assertTrue(mkdir($dir)); - $this->assertTrue(file_exists($dir . '/')); + $this->assertFileExists($dir . '/'); $this->assertTrue(is_dir($dir . '/')); } @@ -45,7 +45,7 @@ public function testRmDir() { $dir = self::generateUrl('test_directory/'); $this->assertTrue(rmdir($dir)); - $this->assertFalse(file_exists($dir . '/')); + $this->assertFileNotExists($dir . '/'); } public function testMkDirCreatesBucket() diff --git a/tests/system/Storage/StreamWrapper/ImageTest.php b/tests/system/Storage/StreamWrapper/ImageTest.php index 9ea0769db23..9e47a81c170 100644 --- a/tests/system/Storage/StreamWrapper/ImageTest.php +++ b/tests/system/Storage/StreamWrapper/ImageTest.php @@ -65,7 +65,7 @@ public function testGetImageSizeWithInfo($image, $width, $height) $size = getimagesize($url, $info); $this->assertEquals($width, $size[0]); $this->assertEquals($height, $size[1]); - $this->assertTrue(count(array_keys($info)) > 1); + $this->assertGreaterThan(1, array_keys($info)); } public function imageProvider() diff --git a/tests/system/Storage/StreamWrapper/ReadTest.php b/tests/system/Storage/StreamWrapper/ReadTest.php index 6f9dbd619ae..a5db6655d17 100644 --- a/tests/system/Storage/StreamWrapper/ReadTest.php +++ b/tests/system/Storage/StreamWrapper/ReadTest.php @@ -40,7 +40,7 @@ public function testFread() public function testFileGetContents() { - $this->assertEquals('somedata', file_get_contents($this->file)); + $this->assertStringEqualsFile($this->file, 'somedata'); } public function testGetLines() diff --git a/tests/system/Storage/StreamWrapper/RenameTest.php b/tests/system/Storage/StreamWrapper/RenameTest.php index 9ea898393fd..000d025f643 100644 --- a/tests/system/Storage/StreamWrapper/RenameTest.php +++ b/tests/system/Storage/StreamWrapper/RenameTest.php @@ -39,7 +39,7 @@ public function testRenameFile() $oldFile = self::generateUrl(self::TEST_FILE); $newFile = self::generateUrl(self::NEW_TEST_FILE); $this->assertTrue(rename($oldFile, $newFile)); - $this->assertTrue(file_exists($newFile)); + $this->assertFileExists($newFile); } public function testRenameDirectory() @@ -48,7 +48,7 @@ public function testRenameDirectory() $newFolder = self::generateUrl('new_folder'); $newFile = $newFolder . '/bar.txt'; $this->assertTrue(rename($oldFolder, $newFolder)); - $this->assertTrue(file_exists($newFile)); + $this->assertFileExists($newFile); } } diff --git a/tests/system/Storage/StreamWrapper/UrlStatTest.php b/tests/system/Storage/StreamWrapper/UrlStatTest.php index aefa2d8bc6c..5373d870014 100644 --- a/tests/system/Storage/StreamWrapper/UrlStatTest.php +++ b/tests/system/Storage/StreamWrapper/UrlStatTest.php @@ -74,8 +74,8 @@ public function testIsReadable() public function testFileExists() { - $this->assertTrue(file_exists(self::$dirUrl)); - $this->assertTrue(file_exists(self::$fileUrl)); + $this->assertFileExists(self::$dirUrl); + $this->assertFileExists(self::$fileUrl); } public function testIsLink() diff --git a/tests/system/Storage/StreamWrapper/WriteTest.php b/tests/system/Storage/StreamWrapper/WriteTest.php index 74d3bb45c6f..a3930e65ebf 100644 --- a/tests/system/Storage/StreamWrapper/WriteTest.php +++ b/tests/system/Storage/StreamWrapper/WriteTest.php @@ -38,29 +38,29 @@ public function tearDown() public function testFilePutContents() { - $this->assertFalse(file_exists($this->fileUrl)); + $this->assertFileNotExists($this->fileUrl); $output = 'This is a test'; $this->assertEquals(strlen($output), file_put_contents($this->fileUrl, $output)); - $this->assertTrue(file_exists($this->fileUrl)); + $this->assertFileExists($this->fileUrl); } public function testFwrite() { - $this->assertFalse(file_exists($this->fileUrl)); + $this->assertFileNotExists($this->fileUrl); $output = 'This is a test'; $fd = fopen($this->fileUrl, 'w'); $this->assertEquals(strlen($output), fwrite($fd, $output)); $this->assertTrue(fclose($fd)); - $this->assertTrue(file_exists($this->fileUrl)); + $this->assertFileExists($this->fileUrl); } public function testStreamingWrite() { - $this->assertFalse(file_exists($this->fileUrl)); + $this->assertFileNotExists($this->fileUrl); $fp = fopen($this->fileUrl, 'w'); for($i = 0; $i < 20000; $i++) { @@ -68,6 +68,6 @@ public function testStreamingWrite() } fclose($fp); - $this->assertTrue(file_exists($this->fileUrl)); + $this->assertFileExists($this->fileUrl); } } diff --git a/tests/system/Translate/TranslateTest.php b/tests/system/Translate/TranslateTest.php index 03e8ddea68f..bbd053ee897 100644 --- a/tests/system/Translate/TranslateTest.php +++ b/tests/system/Translate/TranslateTest.php @@ -147,7 +147,7 @@ public function testDetectLanguage() $res = $client->detectLanguage(self::INPUT_STRING); $this->assertEquals(self::INPUT_LANGUAGE, $res['languageCode']); $this->assertEquals(self::INPUT_STRING, $res['input']); - $this->assertTrue(is_double($res['confidence'])); + $this->assertInternalType('double', $res['confidence']); } public function testDetectLanguageUndefined() @@ -166,7 +166,7 @@ public function testDetectLanguageBatch() $res = $client->detectLanguageBatch([self::INPUT_STRING]); $this->assertEquals(self::INPUT_LANGUAGE, $res[0]['languageCode']); $this->assertEquals(self::INPUT_STRING, $res[0]['input']); - $this->assertTrue(is_double($res[0]['confidence'])); + $this->assertInternalType('double', $res[0]['confidence']); } public function testDetectLanguageBatchUndefined() @@ -183,9 +183,9 @@ public function testDetectLanguages() $client = self::$client; $res = $client->languages(); - $this->assertTrue(is_array($res)); - $this->assertTrue(in_array('en', $res)); - $this->assertTrue(in_array('es', $res)); + $this->assertInternalType('array', $res); + $this->assertContains('en', $res); + $this->assertContains('es', $res); } public function testLocalizedLanguages() @@ -193,8 +193,8 @@ public function testLocalizedLanguages() $client = self::$client; $res = $client->localizedLanguages(); - $this->assertTrue(is_array($res)); - $this->assertTrue(in_array(['code' => 'es', 'name' => 'Spanish'], $res)); - $this->assertTrue(in_array(['code' => 'en', 'name' => 'English'], $res)); + $this->assertInternalType('array', $res); + $this->assertContains(['code' => 'es', 'name' => 'Spanish'], $res); + $this->assertContains(['code' => 'en', 'name' => 'English'], $res); } } diff --git a/tests/system/Vision/AnnotationsTest.php b/tests/system/Vision/AnnotationsTest.php index cd160140ade..2454ae05949 100644 --- a/tests/system/Vision/AnnotationsTest.php +++ b/tests/system/Vision/AnnotationsTest.php @@ -74,13 +74,13 @@ public function testAnnotate() // Image Properties $this->assertInstanceOf(ImageProperties::class, $res->imageProperties()); - $this->assertTrue(is_array($res->imageProperties()->colors())); + $this->assertInternalType('array', $res->imageProperties()->colors()); // Crop Hints $this->assertInstanceOf(CropHint::class, $res->cropHints()[0]); $this->assertTrue(isset($res->cropHints()[0]->boundingPoly()['vertices'])); - $this->assertTrue(is_float($res->cropHints()[0]->confidence())); - $this->assertTrue(!is_null($res->cropHints()[0]->importanceFraction())); + $this->assertInternalType('float', $res->cropHints()[0]->confidence()); + $this->assertNotNull($res->cropHints()[0]->importanceFraction()); // Web Annotation $this->assertInstanceOf(Web::class, $res->web()); @@ -89,7 +89,7 @@ public function testAnnotate() $desc = array_filter($res->web()->entities(), function ($e) { return ($e->description() === 'Eiffel Tower'); }); - $this->assertTrue(count($desc) > 0); + $this->assertGreaterThan(0, $desc); $this->assertInstanceOf(WebImage::class, $res->web()->matchingImages()[0]); $this->assertInstanceOf(WebImage::class, $res->web()->partialMatchingImages()[0]); diff --git a/tests/unit/BigQuery/JobConfigurationTraitTest.php b/tests/unit/BigQuery/JobConfigurationTraitTest.php index 62911627eeb..da7194f15e2 100644 --- a/tests/unit/BigQuery/JobConfigurationTraitTest.php +++ b/tests/unit/BigQuery/JobConfigurationTraitTest.php @@ -60,7 +60,7 @@ public function testJobConfigurationPropertiesSetsJobIDWhenNotProvided() ]); $jobId = $this->trait->call('toArray')['jobReference']['jobId']; - $this->assertTrue(is_string($jobId)); + $this->assertInternalType('string', $jobId); $this->assertTrue(Uuid::isValid($jobId)); } @@ -104,7 +104,7 @@ public function testLabels() public function testGenerateJobId() { $uuid = $this->trait->call('generateJobId'); - $this->assertTrue(is_string($uuid)); + $this->assertInternalType('string', $uuid); $this->assertTrue(Uuid::isValid($uuid)); } } diff --git a/tests/unit/Core/Batch/BatchConfigTest.php b/tests/unit/Core/Batch/BatchConfigTest.php index 3f3d1752b31..14a44f19f31 100644 --- a/tests/unit/Core/Batch/BatchConfigTest.php +++ b/tests/unit/Core/Batch/BatchConfigTest.php @@ -84,7 +84,7 @@ public function testGetjobs() [] ); $jobs = $this->config->getJobs(); - $this->assertEquals(count($jobs), 2); + $this->assertCount(2, $jobs); $this->assertEquals($this->idNum, $jobs[$this->identifier]->getIdNum()); $this->assertEquals(2, $jobs[$identifier]->getIdNum()); } diff --git a/tests/unit/Core/Batch/RetryTest.php b/tests/unit/Core/Batch/RetryTest.php index ce2b4c12ae9..d960a25be97 100644 --- a/tests/unit/Core/Batch/RetryTest.php +++ b/tests/unit/Core/Batch/RetryTest.php @@ -75,9 +75,9 @@ public function testRetryAll() ->shouldBeCalledTimes(1); $this->retry = new Retry($this->runner->reveal()); $this->retry->handleFailure(1, array('apple', 'orange')); - $this->assertEquals(1, count(glob(self::$testDir . '/failed-items*'))); + $this->assertCount(1, glob(self::$testDir . '/failed-items*')); $this->retry->retryAll(); - $this->assertEquals(0, count(glob(self::$testDir . '/failed-items*'))); + $this->assertCount(0, glob(self::$testDir . '/failed-items*')); } public function testRetryAllWithSingleFailure() @@ -91,8 +91,8 @@ public function testRetryAllWithSingleFailure() $this->retry = new Retry($this->runner->reveal()); $this->retry->handleFailure(1, array('apple', 'orange')); $this->retry->retryAll(); - $this->assertEquals(1, count(glob(self::$testDir . '/failed-items*'))); + $this->assertCount(1, glob(self::$testDir . '/failed-items*')); $this->retry->retryAll(); - $this->assertEquals(0, count(glob(self::$testDir . '/failed-items*'))); + $this->assertCount(0, glob(self::$testDir . '/failed-items*')); } } diff --git a/tests/unit/Core/GrpcTraitTest.php b/tests/unit/Core/GrpcTraitTest.php index 3a9da8ab422..78c9ff77259 100644 --- a/tests/unit/Core/GrpcTraitTest.php +++ b/tests/unit/Core/GrpcTraitTest.php @@ -114,7 +114,7 @@ public function testSendsRequestNotFoundWhitelisted() $msg = $e->getMessage(); } - $this->assertFalse(strpos($msg, 'NOTE: Error may be due to Whitelist Restriction.') === false); + $this->assertContains('NOTE: Error may be due to Whitelist Restriction.', $msg); } public function testSendsRequestNotFoundNotWhitelisted() @@ -137,7 +137,7 @@ public function testSendsRequestNotFoundNotWhitelisted() $msg = $e->getMessage(); } - $this->assertTrue(strpos($msg, 'NOTE: Error may be due to Whitelist Restriction.') === false); + $this->assertNotContains('NOTE: Error may be due to Whitelist Restriction.', $msg); } public function testGetsGaxConfig() diff --git a/tests/unit/Core/RequestWrapperTest.php b/tests/unit/Core/RequestWrapperTest.php index f16b01b495e..8a89b23cbaf 100644 --- a/tests/unit/Core/RequestWrapperTest.php +++ b/tests/unit/Core/RequestWrapperTest.php @@ -392,7 +392,7 @@ public function testDefaultToAnonymousCredentialsWhenNoOthersExist() $fetcher = $requestWrapper->getCredentialsFetcher(); $this->assertInstanceOf(FetchAuthTokenInterface::class, $fetcher); - $this->assertEquals(null, $fetcher->fetchAuthToken()['access_token']); + $this->assertNull($fetcher->fetchAuthToken()['access_token']); } } diff --git a/tests/unit/Core/RestTraitTest.php b/tests/unit/Core/RestTraitTest.php index 6a8f8693ead..81535592128 100644 --- a/tests/unit/Core/RestTraitTest.php +++ b/tests/unit/Core/RestTraitTest.php @@ -99,7 +99,7 @@ public function testSendsRequestNotFoundWhitelisted() $msg = $e->getMessage(); } - $this->assertFalse(strpos($msg, 'NOTE: Error may be due to Whitelist Restriction.') === false); + $this->assertContains('NOTE: Error may be due to Whitelist Restriction.', $msg); } public function testSendsRequestNotFoundNotWhitelisted() @@ -119,6 +119,6 @@ public function testSendsRequestNotFoundNotWhitelisted() $msg = $e->getMessage(); } - $this->assertTrue(strpos($msg, 'NOTE: Error may be due to Whitelist Restriction.') === false); + $this->assertNotContains('NOTE: Error may be due to Whitelist Restriction.', $msg); } } diff --git a/tests/unit/Core/ValidateTraitTest.php b/tests/unit/Core/ValidateTraitTest.php index b94794a602b..351620cc34b 100644 --- a/tests/unit/Core/ValidateTraitTest.php +++ b/tests/unit/Core/ValidateTraitTest.php @@ -71,7 +71,7 @@ public function testAdditionalCheckCalled() $called++; }); - $this->assertEquals(count($input), $called); + $this->assertCount($called, $input); } } diff --git a/tests/unit/Datastore/DatastoreClientTest.php b/tests/unit/Datastore/DatastoreClientTest.php index 301503e0c08..76f2c5a14ab 100644 --- a/tests/unit/Datastore/DatastoreClientTest.php +++ b/tests/unit/Datastore/DatastoreClientTest.php @@ -98,7 +98,7 @@ public function testKeys() 'allocateIds' => false ]); - $this->assertTrue(is_array($keys)); + $this->assertInternalType('array', $keys); $this->assertInstanceOf(Key::class, $keys[0]); $this->assertEquals($keys[0]->keyObject()['path'][0]['kind'], 'Person'); } @@ -110,9 +110,9 @@ public function testKeysMultiple() 'number' => 5 ]); - $this->assertTrue(is_array($keys)); + $this->assertInternalType('array', $keys); $this->assertInstanceOf(Key::class, $keys[0]); - $this->assertEquals(5, count($keys)); + $this->assertCount(5, $keys); } public function testKeysAncestors() @@ -192,7 +192,7 @@ public function testAllocateIds() $res = $this->datastore->allocateIds($keys); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); } public function testTransaction() diff --git a/tests/unit/Datastore/DatastoreSessionHandlerTest.php b/tests/unit/Datastore/DatastoreSessionHandlerTest.php index b784631735d..3257172dd72 100644 --- a/tests/unit/Datastore/DatastoreSessionHandlerTest.php +++ b/tests/unit/Datastore/DatastoreSessionHandlerTest.php @@ -196,9 +196,9 @@ public function testWrite() $that->assertEquals($key, $args[0]); $that->assertEquals('sessiondata', $args[1]['data']); $that->assertInternalType('int', $args[1]['t']); - $that->assertTrue(time() >= $args[1]['t']); + $that->assertGreaterThanOrEqual($args[1]['t'], time()); // 2 seconds grace period should be enough - $that->assertTrue(time() - $args[1]['t'] <= 2); + $that->assertLessThanOrEqual(2, time() - $args[1]['t']); $that->assertEquals(['excludeFromIndexes' => ['data']], $args[2]); return $entity; }); @@ -208,7 +208,7 @@ public function testWrite() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->write('sessionid', $data); - $this->assertEquals(true, $ret); + $this->assertTrue($ret); } /** @@ -241,9 +241,9 @@ public function testWriteWithException() $that->assertEquals($key, $args[0]); $that->assertEquals('sessiondata', $args[1]['data']); $that->assertInternalType('int', $args[1]['t']); - $that->assertTrue(time() >= $args[1]['t']); + $that->assertGreaterThanOrEqual($args[1]['t'], time()); // 2 seconds grace period should be enough - $that->assertTrue(time() - $args[1]['t'] <= 2); + $that->assertLessThanOrEqual(2, time() - $args[1]['t']); $that->assertEquals(['excludeFromIndexes' => ['data']], $args[2]); return $entity; }); @@ -254,7 +254,7 @@ public function testWriteWithException() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->write('sessionid', $data); - $this->assertEquals(false, $ret); + $this->assertFalse($ret); } public function testWriteWithEntityOptions() @@ -286,9 +286,9 @@ public function testWriteWithEntityOptions() $that->assertEquals($key, $args[0]); $that->assertEquals('sessiondata', $args[1]['data']); $that->assertInternalType('int', $args[1]['t']); - $that->assertTrue(time() >= $args[1]['t']); + $that->assertGreaterThanOrEqual($args[1]['t'], time()); // 2 seconds grace period should be enough - $that->assertTrue(time() - $args[1]['t'] <= 2); + $that->assertLessThanOrEqual(2, time() - $args[1]['t']); $that->assertEquals(['excludeFromIndexes' => ['data', 'additional']], $args[2]); return $entity; }); @@ -300,7 +300,7 @@ public function testWriteWithEntityOptions() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->write('sessionid', $data); - $this->assertEquals(true, $ret); + $this->assertTrue($ret); } public function testWriteWithEmptyEntityOptions() @@ -332,9 +332,9 @@ public function testWriteWithEmptyEntityOptions() $that->assertEquals($key, $args[0]); $that->assertEquals('sessiondata', $args[1]['data']); $that->assertInternalType('int', $args[1]['t']); - $that->assertTrue(time() >= $args[1]['t']); + $that->assertGreaterThanOrEqual($args[1]['t'], time()); // 2 seconds grace period should be enough - $that->assertTrue(time() - $args[1]['t'] <= 2); + $that->assertLessThanOrEqual(2, time() - $args[1]['t']); $that->assertEquals([], $args[2]); return $entity; }); @@ -346,7 +346,7 @@ public function testWriteWithEmptyEntityOptions() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->write('sessionid', $data); - $this->assertEquals(true, $ret); + $this->assertTrue($ret); } /** @@ -399,7 +399,7 @@ public function testDestroy() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->destroy('sessionid'); - $this->assertEquals(true, $ret); + $this->assertTrue($ret); } /** @@ -431,7 +431,7 @@ public function testDestroyWithException() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->destroy('sessionid'); - $this->assertEquals(false, $ret); + $this->assertFalse($ret); } public function testDefaultGcDoesNothing() @@ -446,7 +446,7 @@ public function testDefaultGcDoesNothing() $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->gc(100); - $this->assertEquals(true, $ret); + $this->assertTrue($ret); } public function testGc() @@ -474,8 +474,8 @@ public function testGc() $that->assertInternalType('int', $args[2]); $diff = time() - $args[2]; // 2 seconds grace period should be enough - $that->assertTrue($diff <= 102); - $that->assertTrue($diff >= 100); + $that->assertLessThanOrEqual(102, $diff); + $that->assertGreaterThanOrEqual(100, $diff); return $query->reveal(); }); $query->order('t') @@ -519,7 +519,7 @@ function($args) $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->gc(100); - $this->assertEquals(true, $ret); + $this->assertTrue($ret); } /** @@ -550,8 +550,8 @@ public function testGcWithException() $that->assertInternalType('int', $args[2]); $diff = time() - $args[2]; // 2 seconds grace period should be enough - $that->assertTrue($diff <= 102); - $that->assertTrue($diff >= 100); + $that->assertLessThanOrEqual(102, $diff); + $that->assertGreaterThanOrEqual(100, $diff); return $query->reveal(); }); $query->order('t') @@ -596,6 +596,6 @@ function($args) $datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND); $ret = $datastoreSessionHandler->gc(100); - $this->assertEquals(false, $ret); + $this->assertFalse($ret); } } diff --git a/tests/unit/Datastore/DatastoreTraitTest.php b/tests/unit/Datastore/DatastoreTraitTest.php index ac3b1d5c623..305e7ca627a 100644 --- a/tests/unit/Datastore/DatastoreTraitTest.php +++ b/tests/unit/Datastore/DatastoreTraitTest.php @@ -41,7 +41,7 @@ public function testPartitionId() 'foo', 'bar' ]); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertEquals('foo', $res['projectId']); $this->assertEquals('bar', $res['namespaceId']); } diff --git a/tests/unit/Datastore/EntityMapperTest.php b/tests/unit/Datastore/EntityMapperTest.php index 4adc401f47d..e185bbdb869 100644 --- a/tests/unit/Datastore/EntityMapperTest.php +++ b/tests/unit/Datastore/EntityMapperTest.php @@ -361,7 +361,7 @@ public function testConvertValueEntityWithoutKey() ]; $res = $this->mapper->convertValue($type, $val); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertEquals('test', $res['prop']); } @@ -371,7 +371,7 @@ public function testConvertValueDouble() $val = 1.1; $res = $this->mapper->convertValue($type, $val); - $this->assertTrue(is_float($res)); + $this->assertInternalType('float', $res); $this->assertEquals(1.1, $res); } @@ -381,7 +381,7 @@ public function testConvertValueDoubleWithCast() $val = 1; $res = $this->mapper->convertValue($type, $val); - $this->assertTrue(is_float($res)); + $this->assertInternalType('float', $res); $this->assertEquals((float)1, $res); } @@ -437,7 +437,7 @@ public function testArrayValue() ]; $res = $this->mapper->convertValue($type, $val); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertEquals(['foo', 'bar'], $res); } @@ -447,7 +447,7 @@ public function testEmptyArrayValue() $val = []; $res = $this->mapper->convertValue($type, $val); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertEquals([], $res); } diff --git a/tests/unit/Datastore/KeyTest.php b/tests/unit/Datastore/KeyTest.php index 7d7a5ba4ddb..0e3ab71c6e0 100644 --- a/tests/unit/Datastore/KeyTest.php +++ b/tests/unit/Datastore/KeyTest.php @@ -56,7 +56,7 @@ public function testPathElement() $key->pathElement('foo', 'bar'); - $this->assertEquals(1, count($key->keyObject()['path'])); + $this->assertCount(1, $key->keyObject()['path']); $this->assertEquals(['kind' => 'foo', 'name' => 'bar'], $key->keyObject()['path'][0]); } diff --git a/tests/unit/Datastore/OperationTest.php b/tests/unit/Datastore/OperationTest.php index cdeff624fad..376ec9ed939 100644 --- a/tests/unit/Datastore/OperationTest.php +++ b/tests/unit/Datastore/OperationTest.php @@ -75,7 +75,7 @@ public function testKeyWithNamespaceIdOverride() public function testKeys() { $keys = $this->operation->keys('Foo'); - $this->assertEquals(1, count($keys)); + $this->assertCount(1, $keys); $this->assertInstanceOf(Key::class, $keys[0]); } @@ -85,7 +85,7 @@ public function testKeysNumber() 'number' => 10 ]); - $this->assertEquals(10, count($keys)); + $this->assertCount(10, $keys); } public function testKeysAncestors() @@ -218,7 +218,7 @@ public function testLookup() $res = $this->operation->lookup($keys); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); } public function testLookupFound() @@ -233,7 +233,7 @@ public function testLookupFound() $key = $this->operation->key('Kind', 'ID'); $res = $this->operation->lookup([$key]); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertTrue(isset($res['found']) && is_array($res['found'])); $this->assertInstanceOf(Entity::class, $res['found'][0]); @@ -256,7 +256,7 @@ public function testLookupMissing() $res = $this->operation->lookup([$key]); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertTrue(isset($res['missing']) && is_array($res['missing'])); $this->assertInstanceOf(Key::class, $res['missing'][0]); @@ -276,7 +276,7 @@ public function testLookupDeferred() $res = $this->operation->lookup([$key]); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertTrue(isset($res['deferred']) && is_array($res['deferred'])); $this->assertInstanceOf(Key::class, $res['deferred'][0]); } @@ -448,7 +448,7 @@ public function testRunQuery() $this->assertInstanceOf(EntityIterator::class, $res); $arr = iterator_to_array($res); - $this->assertEquals(count($arr), 2); + $this->assertCount(2, $arr); $this->assertInstanceOf(Entity::class, $arr[0]); } @@ -476,7 +476,7 @@ public function testRunQueryPaged() $this->assertInstanceOf(EntityIterator::class, $res); $arr = iterator_to_array($res); - $this->assertEquals(count($arr), 3); + $this->assertCount(3, $arr); $this->assertInstanceOf(Entity::class, $arr[0]); } @@ -498,7 +498,7 @@ public function testRunQueryNoResults() $this->assertInstanceOf(EntityIterator::class, $res); $arr = iterator_to_array($res); - $this->assertEquals(count($arr), 0); + $this->assertCount(0, $arr); } public function testRunQueryWithReadOptionsFromTransaction() diff --git a/tests/unit/Firestore/CollectionReferenceTest.php b/tests/unit/Firestore/CollectionReferenceTest.php index 8f1217713be..0e6a05474a4 100644 --- a/tests/unit/Firestore/CollectionReferenceTest.php +++ b/tests/unit/Firestore/CollectionReferenceTest.php @@ -116,7 +116,7 @@ public function testAdd() public function testExtends() { - $this->assertTrue($this->collection instanceof Query); + $this->assertInstanceOf(Query::class, $this->collection); } /** diff --git a/tests/unit/Firestore/DocumentReferenceTest.php b/tests/unit/Firestore/DocumentReferenceTest.php index f6d5f54771a..e34d842fc02 100644 --- a/tests/unit/Firestore/DocumentReferenceTest.php +++ b/tests/unit/Firestore/DocumentReferenceTest.php @@ -241,7 +241,7 @@ public function testCollections() $collections = iterator_to_array($this->document->collections()); $this->assertContainsOnlyInstancesOf(CollectionReference::class, $collections); - $this->assertTrue(count($collections) === 3); + $this->assertCount(3, $collections); $this->assertEquals(self::NAME .'/c', $collections[0]->name()); $this->assertEquals(self::NAME .'/d', $collections[1]->name()); $this->assertEquals(self::NAME .'/e', $collections[2]->name()); diff --git a/tests/unit/Firestore/FirestoreClientTest.php b/tests/unit/Firestore/FirestoreClientTest.php index db60acff85e..67431e90b51 100644 --- a/tests/unit/Firestore/FirestoreClientTest.php +++ b/tests/unit/Firestore/FirestoreClientTest.php @@ -130,7 +130,7 @@ public function testCollectionsPaged() if ($i == 6) break; } - $this->assertEquals(6, count($arr)); + $this->assertCount(6, $arr); } public function testDocument() diff --git a/tests/unit/Firestore/QueryTest.php b/tests/unit/Firestore/QueryTest.php index 8d9dac17e1d..bf29705ba95 100644 --- a/tests/unit/Firestore/QueryTest.php +++ b/tests/unit/Firestore/QueryTest.php @@ -98,7 +98,7 @@ public function testDocuments() $res = $this->query->documents(); $this->assertContainsOnlyInstancesOf(DocumentSnapshot::class, $res); - $this->assertEquals(1, count($res->rows())); + $this->assertCount(1, $res->rows()); $current = $res->rows()[0]; $this->assertEquals($name, $current->name()); diff --git a/tests/unit/PubSub/MessageTest.php b/tests/unit/PubSub/MessageTest.php index d78a765bf94..20ed4f0f903 100644 --- a/tests/unit/PubSub/MessageTest.php +++ b/tests/unit/PubSub/MessageTest.php @@ -88,8 +88,8 @@ public function testSubscription() public function testInfo() { - $this->assertTrue(is_array($this->message->info())); - $this->assertTrue(is_array($this->message->info()['message'])); + $this->assertInternalType('array', $this->message->info()); + $this->assertInternalType('array', $this->message->info()['message']); $this->assertInstanceOf(Subscription::class, $this->message->info()['subscription']); $this->assertEquals(1234, $this->message->info()['ackId']); } diff --git a/tests/unit/PubSub/PubSubClientTest.php b/tests/unit/PubSub/PubSubClientTest.php index cad99a49246..c43041bb515 100644 --- a/tests/unit/PubSub/PubSubClientTest.php +++ b/tests/unit/PubSub/PubSubClientTest.php @@ -175,7 +175,7 @@ public function testTopicsPaged() if ($i == 6) break; } - $this->assertEquals(6, count($arr)); + $this->assertCount(6, $arr); } public function testSubscribe() @@ -289,7 +289,7 @@ public function testSubscriptionsPaged() if ($i == 6) break; } - $this->assertEquals(6, count($arr)); + $this->assertCount(6, $arr); } public function testCreateSnapshot() @@ -385,7 +385,7 @@ public function testSnapshotsPaged() if ($i == 6) break; } - $this->assertEquals(6, count($arr)); + $this->assertCount(6, $arr); } public function testConsume() diff --git a/tests/unit/PubSub/TopicTest.php b/tests/unit/PubSub/TopicTest.php index 9a5dbd60ae2..9b85678043e 100644 --- a/tests/unit/PubSub/TopicTest.php +++ b/tests/unit/PubSub/TopicTest.php @@ -336,7 +336,7 @@ public function testSubscriptionsPaged() if ($i == 6) break; } - $this->assertEquals(6, count($arr)); + $this->assertCount(6, $arr); } public function testIam() diff --git a/tests/unit/Spanner/BytesTest.php b/tests/unit/Spanner/BytesTest.php index 97f6d43dc80..527bf3082c0 100644 --- a/tests/unit/Spanner/BytesTest.php +++ b/tests/unit/Spanner/BytesTest.php @@ -56,6 +56,6 @@ public function testCast() public function testType() { $bytes = new Bytes($this->content); - $this->assertTrue(is_integer($bytes->type())); + $this->assertInternalType('int', $bytes->type()); } } diff --git a/tests/unit/Spanner/DateTest.php b/tests/unit/Spanner/DateTest.php index 27e90542d50..2ac456b4a0d 100644 --- a/tests/unit/Spanner/DateTest.php +++ b/tests/unit/Spanner/DateTest.php @@ -62,6 +62,6 @@ public function testCast() public function testType() { - $this->assertTrue(is_integer($this->date->type())); + $this->assertInternalType('int', $this->date->type()); } } diff --git a/tests/unit/Spanner/InstanceTest.php b/tests/unit/Spanner/InstanceTest.php index 6b3f9076699..16216de0b5f 100644 --- a/tests/unit/Spanner/InstanceTest.php +++ b/tests/unit/Spanner/InstanceTest.php @@ -269,7 +269,7 @@ public function testDatabases() $dbs = iterator_to_array($dbs); - $this->assertEquals(2, count($dbs)); + $this->assertCount(2, $dbs); $this->assertEquals('database1', DatabaseAdminClient::parseName($dbs[0]->name())['database']); $this->assertEquals('database2', DatabaseAdminClient::parseName($dbs[1]->name())['database']); } @@ -294,7 +294,7 @@ public function testDatabasesPaged() $dbs = iterator_to_array($dbs); - $this->assertEquals(2, count($dbs)); + $this->assertCount(2, $dbs); $this->assertEquals('database1', DatabaseAdminClient::parseName($dbs[0]->name())['database']); $this->assertEquals('database2', DatabaseAdminClient::parseName($dbs[1]->name())['database']); } diff --git a/tests/unit/Spanner/SpannerClientTest.php b/tests/unit/Spanner/SpannerClientTest.php index 993103132c0..571604982eb 100644 --- a/tests/unit/Spanner/SpannerClientTest.php +++ b/tests/unit/Spanner/SpannerClientTest.php @@ -87,7 +87,7 @@ public function testInstanceConfigurations() $this->assertInstanceOf(ItemIterator::class, $configs); $configs = iterator_to_array($configs); - $this->assertEquals(2, count($configs)); + $this->assertCount(2, $configs); $this->assertInstanceOf(InstanceConfiguration::class, $configs[0]); $this->assertInstanceOf(InstanceConfiguration::class, $configs[1]); } @@ -127,7 +127,7 @@ public function testPagedInstanceConfigurations() $this->assertInstanceOf(ItemIterator::class, $configs); $configs = iterator_to_array($configs); - $this->assertEquals(2, count($configs)); + $this->assertCount(2, $configs); $this->assertInstanceOf(InstanceConfiguration::class, $configs[0]); $this->assertInstanceOf(InstanceConfiguration::class, $configs[1]); } @@ -208,7 +208,7 @@ public function testInstances() $this->assertInstanceOf(ItemIterator::class, $instances); $instances = iterator_to_array($instances); - $this->assertEquals(2, count($instances)); + $this->assertCount(2, $instances); $this->assertEquals('foo', InstanceAdminClient::parseName($instances[0]->name())['instance']); $this->assertEquals('bar', InstanceAdminClient::parseName($instances[1]->name())['instance']); } diff --git a/tests/unit/Spanner/TimestampTest.php b/tests/unit/Spanner/TimestampTest.php index 3349cf125a8..fbef39e87f5 100644 --- a/tests/unit/Spanner/TimestampTest.php +++ b/tests/unit/Spanner/TimestampTest.php @@ -62,6 +62,6 @@ public function testCast() public function testType() { - $this->assertTrue(is_integer($this->ts->type())); + $this->assertInternalType('int', $this->ts->type()); } } diff --git a/tests/unit/Spanner/ValueMapperTest.php b/tests/unit/Spanner/ValueMapperTest.php index 5c8ce430704..3baa565287f 100644 --- a/tests/unit/Spanner/ValueMapperTest.php +++ b/tests/unit/Spanner/ValueMapperTest.php @@ -33,7 +33,7 @@ class ValueMapperTest extends TestCase { use GrpcTestTrait; - + const FORMAT_TEST_VALUE = 'abc'; private $mapper; @@ -238,7 +238,7 @@ public function testDecodeValuesBool() $this->createRow(false), Result::RETURN_ASSOCIATIVE ); - $this->assertEquals(false, $res['rowName']); + $this->assertFalse($res['rowName']); } public function testDecodeValuesInt() diff --git a/tests/unit/Storage/StorageClientTest.php b/tests/unit/Storage/StorageClientTest.php index 7e3cab52f98..fb54e2b9db5 100644 --- a/tests/unit/Storage/StorageClientTest.php +++ b/tests/unit/Storage/StorageClientTest.php @@ -136,7 +136,7 @@ public function testRegisteringStreamWrapper() { $this->assertTrue($this->client->registerStreamWrapper()); $this->assertEquals($this->client, StreamWrapper::getClient()); - $this->assertTrue(in_array('gs', stream_get_wrappers())); + $this->assertContains('gs', stream_get_wrappers()); $this->client->unregisterStreamWrapper(); } diff --git a/tests/unit/Storage/StorageObjectTest.php b/tests/unit/Storage/StorageObjectTest.php index 6d4c0361032..6e932004c16 100644 --- a/tests/unit/Storage/StorageObjectTest.php +++ b/tests/unit/Storage/StorageObjectTest.php @@ -572,10 +572,10 @@ public function testSignedUrl() $this->assertTrue($object->___signatureIsCorrect($signature)); $this->assertEquals($object->input, $input); - $this->assertTrue(in_array('generation=foo', $pieces)); - $this->assertTrue(in_array('response-content-type='. urlencode($contentType), $pieces)); - $this->assertTrue(in_array('response-content-disposition=foo', $pieces)); - $this->assertTrue(in_array('response-content-type='. urlencode($responseType), $pieces)); + $this->assertContains('generation=foo', $pieces); + $this->assertContains('response-content-type='. urlencode($contentType), $pieces); + $this->assertContains('response-content-disposition=foo', $pieces); + $this->assertContains('response-content-type='. urlencode($responseType), $pieces); } public function testSignedUrlWithSaveAsName() @@ -605,7 +605,7 @@ public function testSignedUrlWithSaveAsName() $this->assertTrue($object->___signatureIsCorrect($signature)); $this->assertEquals($object->input, $input); - $this->assertTrue(in_array('response-content-disposition=attachment;filename="foo"', $pieces)); + $this->assertContains('response-content-disposition=attachment;filename="foo"', $pieces); } public function testSignedUrlConnectionKeyfile() @@ -686,10 +686,10 @@ public function testSignedUrlWithSpace() $this->assertTrue($object->___signatureIsCorrect($signature)); $this->assertEquals($object->input, $input); - $this->assertTrue(in_array('generation=foo', $pieces)); - $this->assertTrue(in_array('response-content-type='. urlencode($contentType), $pieces)); - $this->assertTrue(in_array('response-content-disposition=foo', $pieces)); - $this->assertTrue(in_array('response-content-type='. urlencode($responseType), $pieces)); + $this->assertContains('generation=foo', $pieces); + $this->assertContains('response-content-type='. urlencode($contentType), $pieces); + $this->assertContains('response-content-disposition=foo', $pieces); + $this->assertContains('response-content-type='. urlencode($responseType), $pieces); } public function testSignedUploadUrl() diff --git a/tests/unit/Trace/TraceClientTest.php b/tests/unit/Trace/TraceClientTest.php index 1d976dcfb4d..199177f33be 100644 --- a/tests/unit/Trace/TraceClientTest.php +++ b/tests/unit/Trace/TraceClientTest.php @@ -50,7 +50,7 @@ public function testListsTraces() $this->client->setConnection($this->connection->reveal()); $traces = iterator_to_array($this->client->traces()); - $this->assertEquals(3, count($traces)); + $this->assertCount(3, $traces); $this->assertEquals('1', $traces[0]->traceId()); $this->assertEquals('2', $traces[1]->traceId()); $this->assertEquals('3', $traces[2]->traceId()); @@ -80,7 +80,7 @@ public function testGetSingleTrace() $trace = $this->client->trace('1'); $trace->reload(); $this->assertEquals('1', $trace->traceId()); - $this->assertEquals(1, count($trace->spans())); + $this->assertCount(1, $trace->spans()); } /** diff --git a/tests/unit/Trace/TraceTest.php b/tests/unit/Trace/TraceTest.php index 6e1663aafc7..1556c726789 100644 --- a/tests/unit/Trace/TraceTest.php +++ b/tests/unit/Trace/TraceTest.php @@ -52,7 +52,7 @@ public function testLoadFromArray() ] ); $this->assertEquals('1234abcd', $trace->traceId()); - $this->assertEquals(1, count($trace->spans())); + $this->assertCount(1, $trace->spans()); foreach($trace->spans() as $span) { $this->assertInstanceOf(TraceSpan::class, $span); } diff --git a/tests/unit/Vision/VisionClientTest.php b/tests/unit/Vision/VisionClientTest.php index f91789c188a..8484ec5793d 100644 --- a/tests/unit/Vision/VisionClientTest.php +++ b/tests/unit/Vision/VisionClientTest.php @@ -87,7 +87,7 @@ public function testAnnotateBatch() $res = $this->client->annotateBatch([$image]); - $this->assertTrue(is_array($res)); + $this->assertInternalType('array', $res); $this->assertInstanceOf(Annotation::class, $res[0]); $this->assertInstanceOf(Annotation::class, $res[1]);