Skip to content

Commit 85b6d8e

Browse files
carusogabrieldwsupplee
authored andcommitted
Use dedicated PHPUnit assertions (googleapis#1331)
1 parent b12ca01 commit 85b6d8e

10 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎BigQuery/tests/System/LoadDataAndQueryTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testInsertRowToTable()
7676
$actualRow = $rows[0];
7777

7878
$this->assertTrue($insertResponse->isSuccessful());
79-
$this->assertEquals(self::$expectedRows, count($rows));
79+
$this->assertCount(self::$expectedRows, $rows);
8080

8181
$expectedRow = $this->row;
8282
$expectedBytes = $expectedRow['Spells'][0]['Icon'];

‎Datastore/tests/Unit/EntityMapperTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function testResponseToPropertiesEntityValueCustomTypeNestedPropertyUsesD
250250
$res = $this->mapper->responseToEntityProperties($data, SampleEntity::class)['properties'];
251251

252252
$this->assertInstanceOf(SampleEntity::class, $res['foo']);
253-
$this->assertTrue(is_array($res['foo']['bar']));
253+
$this->assertInternalType('array', $res['foo']['bar']);
254254
}
255255

256256
public function testResponseToPropertiesEntityNestedValueCustomType()

‎Debugger/tests/Unit/AgentTest.php‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testDefaultMaxStringLength()
119119
$this->assertInstanceOf(Breakpoint::class, $item[1]);
120120
$stackframes = $item[1]->stackFrames();
121121
$this->assertCount(1, $stackframes);
122-
$this->assertEquals(1, count($stackframes[0]->locals()));
122+
$this->assertCount(1, $stackframes[0]->locals());
123123
$variable = $stackframes[0]->locals()[0];
124124
$this->assertEquals(500, strlen($variable->info()['value']));
125125
return true;
@@ -145,7 +145,7 @@ public function testSetsMaxStringLength()
145145
$this->assertInstanceOf(Breakpoint::class, $item[1]);
146146
$stackframes = $item[1]->stackFrames();
147147
$this->assertCount(1, $stackframes);
148-
$this->assertEquals(1, count($stackframes[0]->locals()));
148+
$this->assertCount(1, $stackframes[0]->locals());
149149
$variable = $stackframes[0]->locals()[0];
150150
$this->assertEquals(1000, strlen($variable->info()['value']));
151151
return true;
@@ -173,7 +173,7 @@ public function testDefaultMaxPayloadSize()
173173
$this->assertInstanceOf(Breakpoint::class, $item[1]);
174174
$stackframes = $item[1]->stackFrames();
175175
$this->assertCount(1, $stackframes);
176-
$this->assertEquals(245, count($stackframes[0]->locals()));
176+
$this->assertCount(245, $stackframes[0]->locals());
177177
return true;
178178
};
179179
$agent = $this->setupAgent($itemMatcher, []);
@@ -200,7 +200,7 @@ public function testSetsMaxPayloadSize()
200200
// Each entry takes 6 + 3 + 10 bytes = 19 bytes
201201
// We stop after 900 bytes (1000 - 100 buffer)
202202
// 19 bytes * 48 = 912 bytes
203-
$this->assertEquals(48, count($stackframes[0]->locals()));
203+
$this->assertCount(48, $stackframes[0]->locals());
204204
return true;
205205
};
206206
$agent = $this->setupAgent($itemMatcher, [
@@ -249,7 +249,7 @@ public function testDefaultMaxMemberDepth()
249249
$this->assertInstanceOf(Breakpoint::class, $item[1]);
250250
$stackframes = $item[1]->stackFrames();
251251
$this->assertCount(1, $stackframes);
252-
$this->assertEquals(1, count($stackframes[0]->locals()));
252+
$this->assertCount(1, $stackframes[0]->locals());
253253

254254
$data = $stackframes[0]->locals()[0]->info();
255255
$depth = 5;
@@ -299,7 +299,7 @@ public function testSetsMaxMemberDepth()
299299
$this->assertInstanceOf(Breakpoint::class, $item[1]);
300300
$stackframes = $item[1]->stackFrames();
301301
$this->assertCount(1, $stackframes);
302-
$this->assertEquals(1, count($stackframes[0]->locals()));
302+
$this->assertCount(1, $stackframes[0]->locals());
303303

304304
$data = $stackframes[0]->locals()[0]->info();
305305
$depth = 3;
@@ -351,7 +351,7 @@ public function testDefaultMaxMembers()
351351
$this->assertInstanceOf(Breakpoint::class, $item[1]);
352352
$stackframes = $item[1]->stackFrames();
353353
$this->assertCount(1, $stackframes);
354-
$this->assertEquals(1, count($stackframes[0]->locals()));
354+
$this->assertCount(1, $stackframes[0]->locals());
355355
$variable = $stackframes[0]->locals()[0];
356356
$this->assertCount(1000, $variable->info()['members']);
357357
return true;
@@ -377,7 +377,7 @@ public function testSetsMaxMembers()
377377
$this->assertInstanceOf(Breakpoint::class, $item[1]);
378378
$stackframes = $item[1]->stackFrames();
379379
$this->assertCount(1, $stackframes);
380-
$this->assertEquals(1, count($stackframes[0]->locals()));
380+
$this->assertCount(1, $stackframes[0]->locals());
381381
$variable = $stackframes[0]->locals()[0];
382382
$this->assertCount(5, $variable->info()['members']);
383383
return true;

‎Debugger/tests/Unit/VariableTableTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function testLimitsTotalSize()
281281
$this->assertTrue($exceptionThrown);
282282
$variables = $variableTable->variables();
283283
$this->assertNotEmpty($variables);
284-
$this->assertTrue(count($variableTable->variables()) < 1000);
284+
$this->assertLessThan(1000, count($variableTable->variables()));
285285

286286
$bufferFullReference = $variableTable->bufferFullVariable();
287287
$index = $bufferFullReference->info()['varTableIndex'];

‎Storage/tests/System/ManageBucketsTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testIam()
161161
return ($binding['role'] === $role);
162162
});
163163

164-
$this->assertEquals(1, count($newBinding));
164+
$this->assertCount(1, $newBinding);
165165

166166
$permissions = ['storage.buckets.get'];
167167
$test = $iam->testPermissions($permissions);
@@ -200,6 +200,6 @@ public function testLabels()
200200

201201
$bucket->reload();
202202

203-
$this->assertFalse(isset($bucket->info()['labels']['foo']));
203+
$this->assertArrayNotHasKey('foo', $bucket->info()['labels']);
204204
}
205205
}

‎Storage/tests/System/ManageNotificationsTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ public function testCreateAndListNotifications()
4646
}
4747

4848
$notifications = iterator_to_array(self::$bucket->notifications());
49-
$this->assertEquals(count($created), count($notifications));
49+
$this->assertCount(count($created), $notifications);
5050

5151
foreach ($created as $cNotification) {
5252
$cNotification->delete();
5353
}
5454

5555
$notifications = iterator_to_array(self::$bucket->notifications());
56-
$this->assertEquals(0, count($notifications));
56+
$this->assertCount(0, $notifications);
5757
}
5858
}

‎Storage/tests/System/UploadObjectsTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function onStoredFileChunk($storedBytes)
118118
{
119119
$this->totalStoredBytes += $storedBytes;
120120

121-
$this->assertFalse($this->testFileSize < $this->totalStoredBytes);
121+
$this->assertGreaterThan($this->totalStoredBytes, $this->testFileSize);
122122

123123
if ($this->testFileSize == $this->totalStoredBytes) {
124124
$this->assertEquals(filesize(__DIR__ . '/data/5mb.txt'), $this->totalStoredBytes);

‎Vision/tests/System/AnnotationsTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testAnnotate()
7878

7979
// Crop Hints
8080
$this->assertInstanceOf(CropHint::class, $res->cropHints()[0]);
81-
$this->assertTrue(isset($res->cropHints()[0]->boundingPoly()['vertices']));
81+
$this->assertArrayHasKey('vertices', $res->cropHints()[0]->boundingPoly());
8282
$this->assertInternalType('float', $res->cropHints()[0]->confidence());
8383
$this->assertNotNull($res->cropHints()[0]->importanceFraction());
8484

‎Vision/tests/Unit/ImageTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ public function testUrlSchemes()
157157
$this->assertEquals($urls[0], $images[0]->requestObject()['image']['source']['imageUri']);
158158
$this->assertEquals($urls[1], $images[1]->requestObject()['image']['source']['imageUri']);
159159
$this->assertEquals($urls[2], $images[2]->requestObject()['image']['source']['imageUri']);
160-
$this->assertFalse(isset($images[3]->requestObject()['image']['source']['imageUri']));
160+
$this->assertArrayNotHasKey('source', $images[3]->requestObject()['image']);
161161
}
162162
}

‎Vision/tests/Unit/VisionHelpersTraitTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testAnnotateImageHelper()
6060
// Test that imageContext key is correctly stripped
6161
$this->assertArrayNotHasKey('imageContext', $optionalArgs);
6262

63-
$this->assertSame(1, count($requests));
63+
$this->assertCount(1, $requests);
6464
$request = $requests[0];
6565
$this->assertEquals($image, $request->getImage());
6666
// Use iterator_to_array to convert protobuf Repeated Field object to array for comparison
@@ -80,7 +80,7 @@ public function testAnnotateImageHelper()
8080
['imageContext' => $imageContext]
8181
]);
8282

83-
$this->assertEquals(AnnotateImageResponse::class, get_class($response));
83+
$this->assertInstanceOf(AnnotateImageResponse::class, $response);
8484
}
8585

8686
/**

0 commit comments

Comments
 (0)