Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored tests #769

Merged
merged 7 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/snippets/Spanner/KeySetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Spanner/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testConcurrentTransactionsIncrementValueWithRead()
])->rows()->current();

$this->assertEquals(2, $row['number']);
$this->assertTrue($iterations > 2);
$this->assertGreaterThan(2, $iterations);
}

/**
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Storage/StreamWrapper/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ 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 . '/'));
}

public function testRmDir()
{
$dir = self::generateUrl('test_directory/');
$this->assertTrue(rmdir($dir));
$this->assertFalse(file_exists($dir . '/'));
$this->assertFileNotExists($dir . '/');
}

public function testMkDirCreatesBucket()
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Storage/StreamWrapper/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Storage/StreamWrapper/RenameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
}

}
4 changes: 2 additions & 2 deletions tests/system/Storage/StreamWrapper/UrlStatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions tests/system/Storage/StreamWrapper/WriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,36 @@ 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++) {
fwrite($fp, "Line Number: $i\n");
}
fclose($fp);

$this->assertTrue(file_exists($this->fileUrl));
$this->assertFileExists($this->fileUrl);
}
}
4 changes: 2 additions & 2 deletions tests/system/Vision/AnnotationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testAnnotate()
$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->assertNotNull($res->cropHints()[0]->importanceFraction());

// Web Annotation
$this->assertInstanceOf(Web::class, $res->web());
Expand All @@ -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, count($desc));

$this->assertInstanceOf(WebImage::class, $res->web()->matchingImages()[0]);
$this->assertInstanceOf(WebImage::class, $res->web()->partialMatchingImages()[0]);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Core/Batch/BatchConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Core/Batch/RetryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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*'));
}
}
2 changes: 1 addition & 1 deletion tests/unit/Core/RequestWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Core/ValidateTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testAdditionalCheckCalled()
$called++;
});

$this->assertEquals(count($input), $called);
$this->assertCount($called, $input);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Datastore/DatastoreClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testKeysMultiple()

$this->assertTrue(is_array($keys));
$this->assertInstanceOf(Key::class, $keys[0]);
$this->assertEquals(5, count($keys));
$this->assertCount(5, $keys);
}

public function testKeysAncestors()
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/Datastore/DatastoreSessionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -519,7 +519,7 @@ function($args)
$datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND);
$ret = $datastoreSessionHandler->gc(100);

$this->assertEquals(true, $ret);
$this->assertTrue($ret);
}

/**
Expand Down Expand Up @@ -596,6 +596,6 @@ function($args)
$datastoreSessionHandler->open(self::NAMESPACE_ID, self::KIND);
$ret = $datastoreSessionHandler->gc(100);

$this->assertEquals(false, $ret);
$this->assertFalse($ret);
}
}
2 changes: 1 addition & 1 deletion tests/unit/Datastore/KeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/Datastore/OperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand All @@ -85,7 +85,7 @@ public function testKeysNumber()
'number' => 10
]);

$this->assertEquals(10, count($keys));
$this->assertCount(10, $keys);
}

public function testKeysAncestors()
Expand Down Expand Up @@ -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]);
}

Expand Down Expand Up @@ -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]);
}

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Firestore/DocumentReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Firestore/FirestoreClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function testCollectionsPaged()
if ($i == 6) break;
}

$this->assertEquals(6, count($arr));
$this->assertCount(6, $arr);
}

public function testDocument()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Firestore/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/PubSub/PubSubClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function testTopicsPaged()
if ($i == 6) break;
}

$this->assertEquals(6, count($arr));
$this->assertCount(6, $arr);
}

public function testSubscribe()
Expand Down Expand Up @@ -289,7 +289,7 @@ public function testSubscriptionsPaged()
if ($i == 6) break;
}

$this->assertEquals(6, count($arr));
$this->assertCount(6, $arr);
}

public function testCreateSnapshot()
Expand Down Expand Up @@ -385,7 +385,7 @@ public function testSnapshotsPaged()
if ($i == 6) break;
}

$this->assertEquals(6, count($arr));
$this->assertCount(6, $arr);
}

public function testConsume()
Expand Down
Loading