Skip to content

Commit

Permalink
Use dedicated PHPUnit assertions (#1331)
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel authored and dwsupplee committed Oct 2, 2018
1 parent b12ca01 commit 85b6d8e
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion BigQuery/tests/System/LoadDataAndQueryTest.php
Expand Up @@ -76,7 +76,7 @@ public function testInsertRowToTable()
$actualRow = $rows[0];

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

$expectedRow = $this->row;
$expectedBytes = $expectedRow['Spells'][0]['Icon'];
Expand Down
2 changes: 1 addition & 1 deletion Datastore/tests/Unit/EntityMapperTest.php
Expand Up @@ -250,7 +250,7 @@ public function testResponseToPropertiesEntityValueCustomTypeNestedPropertyUsesD
$res = $this->mapper->responseToEntityProperties($data, SampleEntity::class)['properties'];

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

public function testResponseToPropertiesEntityNestedValueCustomType()
Expand Down
16 changes: 8 additions & 8 deletions Debugger/tests/Unit/AgentTest.php
Expand Up @@ -119,7 +119,7 @@ public function testDefaultMaxStringLength()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(1, count($stackframes[0]->locals()));
$this->assertCount(1, $stackframes[0]->locals());
$variable = $stackframes[0]->locals()[0];
$this->assertEquals(500, strlen($variable->info()['value']));
return true;
Expand All @@ -145,7 +145,7 @@ public function testSetsMaxStringLength()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(1, count($stackframes[0]->locals()));
$this->assertCount(1, $stackframes[0]->locals());
$variable = $stackframes[0]->locals()[0];
$this->assertEquals(1000, strlen($variable->info()['value']));
return true;
Expand Down Expand Up @@ -173,7 +173,7 @@ public function testDefaultMaxPayloadSize()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(245, count($stackframes[0]->locals()));
$this->assertCount(245, $stackframes[0]->locals());
return true;
};
$agent = $this->setupAgent($itemMatcher, []);
Expand All @@ -200,7 +200,7 @@ public function testSetsMaxPayloadSize()
// Each entry takes 6 + 3 + 10 bytes = 19 bytes
// We stop after 900 bytes (1000 - 100 buffer)
// 19 bytes * 48 = 912 bytes
$this->assertEquals(48, count($stackframes[0]->locals()));
$this->assertCount(48, $stackframes[0]->locals());
return true;
};
$agent = $this->setupAgent($itemMatcher, [
Expand Down Expand Up @@ -249,7 +249,7 @@ public function testDefaultMaxMemberDepth()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(1, count($stackframes[0]->locals()));
$this->assertCount(1, $stackframes[0]->locals());

$data = $stackframes[0]->locals()[0]->info();
$depth = 5;
Expand Down Expand Up @@ -299,7 +299,7 @@ public function testSetsMaxMemberDepth()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(1, count($stackframes[0]->locals()));
$this->assertCount(1, $stackframes[0]->locals());

$data = $stackframes[0]->locals()[0]->info();
$depth = 3;
Expand Down Expand Up @@ -351,7 +351,7 @@ public function testDefaultMaxMembers()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(1, count($stackframes[0]->locals()));
$this->assertCount(1, $stackframes[0]->locals());
$variable = $stackframes[0]->locals()[0];
$this->assertCount(1000, $variable->info()['members']);
return true;
Expand All @@ -377,7 +377,7 @@ public function testSetsMaxMembers()
$this->assertInstanceOf(Breakpoint::class, $item[1]);
$stackframes = $item[1]->stackFrames();
$this->assertCount(1, $stackframes);
$this->assertEquals(1, count($stackframes[0]->locals()));
$this->assertCount(1, $stackframes[0]->locals());
$variable = $stackframes[0]->locals()[0];
$this->assertCount(5, $variable->info()['members']);
return true;
Expand Down
2 changes: 1 addition & 1 deletion Debugger/tests/Unit/VariableTableTest.php
Expand Up @@ -281,7 +281,7 @@ public function testLimitsTotalSize()
$this->assertTrue($exceptionThrown);
$variables = $variableTable->variables();
$this->assertNotEmpty($variables);
$this->assertTrue(count($variableTable->variables()) < 1000);
$this->assertLessThan(1000, count($variableTable->variables()));

$bufferFullReference = $variableTable->bufferFullVariable();
$index = $bufferFullReference->info()['varTableIndex'];
Expand Down
4 changes: 2 additions & 2 deletions Storage/tests/System/ManageBucketsTest.php
Expand Up @@ -161,7 +161,7 @@ public function testIam()
return ($binding['role'] === $role);
});

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

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

$bucket->reload();

$this->assertFalse(isset($bucket->info()['labels']['foo']));
$this->assertArrayNotHasKey('foo', $bucket->info()['labels']);
}
}
4 changes: 2 additions & 2 deletions Storage/tests/System/ManageNotificationsTest.php
Expand Up @@ -46,13 +46,13 @@ public function testCreateAndListNotifications()
}

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

foreach ($created as $cNotification) {
$cNotification->delete();
}

$notifications = iterator_to_array(self::$bucket->notifications());
$this->assertEquals(0, count($notifications));
$this->assertCount(0, $notifications);
}
}
2 changes: 1 addition & 1 deletion Storage/tests/System/UploadObjectsTest.php
Expand Up @@ -118,7 +118,7 @@ public function onStoredFileChunk($storedBytes)
{
$this->totalStoredBytes += $storedBytes;

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

if ($this->testFileSize == $this->totalStoredBytes) {
$this->assertEquals(filesize(__DIR__ . '/data/5mb.txt'), $this->totalStoredBytes);
Expand Down
2 changes: 1 addition & 1 deletion Vision/tests/System/AnnotationsTest.php
Expand Up @@ -78,7 +78,7 @@ public function testAnnotate()

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

Expand Down
2 changes: 1 addition & 1 deletion Vision/tests/Unit/ImageTest.php
Expand Up @@ -157,6 +157,6 @@ public function testUrlSchemes()
$this->assertEquals($urls[0], $images[0]->requestObject()['image']['source']['imageUri']);
$this->assertEquals($urls[1], $images[1]->requestObject()['image']['source']['imageUri']);
$this->assertEquals($urls[2], $images[2]->requestObject()['image']['source']['imageUri']);
$this->assertFalse(isset($images[3]->requestObject()['image']['source']['imageUri']));
$this->assertArrayNotHasKey('source', $images[3]->requestObject()['image']);
}
}
4 changes: 2 additions & 2 deletions Vision/tests/Unit/VisionHelpersTraitTest.php
Expand Up @@ -60,7 +60,7 @@ public function testAnnotateImageHelper()
// Test that imageContext key is correctly stripped
$this->assertArrayNotHasKey('imageContext', $optionalArgs);

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

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

/**
Expand Down

0 comments on commit 85b6d8e

Please sign in to comment.