Skip to content

Commit

Permalink
chore: rename the ThrowsException tests to ReturnsError (#239)
Browse files Browse the repository at this point in the history
Rename the tests that are named ThrowsException to ReturnsError, since
none of them test a condition that throws an exception.
  • Loading branch information
nand4011 authored Oct 21, 2024
1 parent a8cfed8 commit 6e21636
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions tests/Cache/CacheClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ public function testDictionaryIncrementToString_HappyPath()
$this->assertEquals("$response", get_class($response) . ": 12");
}

public function testSetAddElementWithEmptyCacheName_ThrowsException()
public function testSetAddElementWithEmptyCacheName_ReturnsError()
{
$setName = uniqid();
$element = uniqid();
Expand All @@ -2283,23 +2283,23 @@ public function testSetAddElementWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetAddElementWithEmptySetName_ThrowsException()
public function testSetAddElementWithEmptySetName_ReturnsError()
{
$element = uniqid();
$response = $this->client->setAddElement($this->TEST_CACHE_NAME, "", $element, CollectionTtl::fromCacheTtl()->withNoRefreshTtlOnUpdates());
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetAddElementWithEmptyElement_ThrowsException()
public function testSetAddElementWithEmptyElement_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setAddElement($this->TEST_CACHE_NAME, $setName, "", CollectionTtl::fromCacheTtl()->withNoRefreshTtlOnUpdates());
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetAddElementsWithEmptyCacheName_ThrowsException()
public function testSetAddElementsWithEmptyCacheName_ReturnsError()
{
$setName = uniqid();
$elements = [uniqid(), uniqid()];
Expand All @@ -2308,31 +2308,31 @@ public function testSetAddElementsWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetAddElementsWithEmptySetName_ThrowsException()
public function testSetAddElementsWithEmptySetName_ReturnsError()
{
$elements = [uniqid(), uniqid()];
$response = $this->client->setAddElements($this->TEST_CACHE_NAME, "", $elements, CollectionTtl::fromCacheTtl()->withNoRefreshTtlOnUpdates());
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetAddElementsWithNoElements_ThrowsException()
public function testSetAddElementsWithNoElements_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setAddElements($this->TEST_CACHE_NAME, $setName, [], CollectionTtl::fromCacheTtl()->withNoRefreshTtlOnUpdates());
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetAddElementsWithEmptyElement_ThrowsException()
public function testSetAddElementsWithEmptyElement_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setAddElements($this->TEST_CACHE_NAME, $setName, [''], CollectionTtl::fromCacheTtl()->withNoRefreshTtlOnUpdates());
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetContainsElementsWithEmptyCacheName_ThrowsException()
public function testSetContainsElementsWithEmptyCacheName_ReturnsError()
{
$setName = uniqid();
$elements = [uniqid(), uniqid()];
Expand All @@ -2341,39 +2341,39 @@ public function testSetContainsElementsWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetContainsElementsWithEmptySetName_ThrowsException()
public function testSetContainsElementsWithEmptySetName_ReturnsError()
{
$elements = [uniqid(), uniqid()];
$response = $this->client->setContainsElements($this->TEST_CACHE_NAME, "", $elements);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetContainsElementsWithNoElements_ThrowsException()
public function testSetContainsElementsWithNoElements_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setContainsElements($this->TEST_CACHE_NAME, $setName, []);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetContainsElementsWithEmptyElement_ThrowsException()
public function testSetContainsElementsWithEmptyElement_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setContainsElements($this->TEST_CACHE_NAME, $setName, ['']);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetFetchWithEmptyCacheName_ThrowsException()
public function testSetFetchWithEmptyCacheName_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setFetch("", $setName);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetFetchWithEmptySetName_ThrowsException()
public function testSetFetchWithEmptySetName_ReturnsError()
{
$response = $this->client->setFetch($this->TEST_CACHE_NAME, "");
$this->assertNotNull($response->asError(), "Expected error but got: $response");
Expand Down Expand Up @@ -2638,7 +2638,7 @@ public function testSetContainsElements_ExistingSetIsEmpty()
$this->assertNotNull($response->asMiss(), "Expected a miss but got: $response");
}

public function testSetRemoveElementWithEmptyCacheName_ThrowsException()
public function testSetRemoveElementWithEmptyCacheName_ReturnsError()
{
$setName = uniqid();
$element = uniqid();
Expand All @@ -2647,15 +2647,15 @@ public function testSetRemoveElementWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetRemoveElementWithEmptySetName_ThrowsException()
public function testSetRemoveElementWithEmptySetName_ReturnsError()
{
$element = uniqid();
$response = $this->client->setRemoveElement($this->TEST_CACHE_NAME, "", $element);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSetRemoveElementWithEmptyElement_ThrowsException()
public function testSetRemoveElementWithEmptyElement_ReturnsError()
{
$setName = uniqid();
$response = $this->client->setRemoveElement($this->TEST_CACHE_NAME, $setName, "");
Expand Down Expand Up @@ -2746,7 +2746,7 @@ public function testSortedSetPutElement_HappyPath()
$this->assertEquals($score, $valuesArray[$value], "The score for value '$value' does not match the expected score.");
}

public function testSortedSetPutElementWithNonexistentCache_ThrowsException()
public function testSortedSetPutElementWithNonexistentCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -2757,7 +2757,7 @@ public function testSortedSetPutElementWithNonexistentCache_ThrowsException()
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetPutElementWithEmptyCacheName_ThrowsException()
public function testSortedSetPutElementWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$value = uniqid();
Expand All @@ -2767,7 +2767,7 @@ public function testSortedSetPutElementWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetPutElementWithEmptyValue_ThrowsException()
public function testSortedSetPutElementWithEmptyValue_ReturnsError()
{
$sortedSetName = uniqid();
$score = 1.0;
Expand Down Expand Up @@ -2822,7 +2822,7 @@ public function testSortedSetPutElements_HappyPath()
$this->assertSame($expectedElements, $fetchedElements, "The fetched elements did not match the expected elements.");
}

public function testSortedSetPutElementsWithNonexistentCache_ThrowsException()
public function testSortedSetPutElementsWithNonexistentCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -2834,7 +2834,7 @@ public function testSortedSetPutElementsWithNonexistentCache_ThrowsException()
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetPutElementsWithEmptyCacheName_ThrowsException()
public function testSortedSetPutElementsWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$elements = [
Expand All @@ -2845,7 +2845,7 @@ public function testSortedSetPutElementsWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetPutElementsWithEmptyValue_ThrowsException()
public function testSortedSetPutElementsWithEmptyValue_ReturnsError()
{
$sortedSetName = uniqid();
$elements = [
Expand Down Expand Up @@ -2950,7 +2950,7 @@ public function testSortedSetIncrementScore_InvalidArguments()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetIncrementScore_NonexistentCache_ThrowsException()
public function testSortedSetIncrementScore_NonexistentCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand Down Expand Up @@ -3060,7 +3060,7 @@ public function testSortedSetFetchByRank_HappyPath()
$this->assertSame($expectedElements, $fetchedElements, "The fetched elements did not match the expected elements.");
}

public function testSortedSetFetchByRankWithNonexistantCache_ThrowsException()
public function testSortedSetFetchByRankWithNonexistantCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -3069,15 +3069,15 @@ public function testSortedSetFetchByRankWithNonexistantCache_ThrowsException()
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByRankWithEmptyCacheName_ThrowsException()
public function testSortedSetFetchByRankWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$response = $this->client->sortedSetFetchByRank("", $sortedSetName);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByRankWithStartRankGreaterThanEndRank_ThrowsException()
public function testSortedSetFetchByRankWithStartRankGreaterThanEndRank_ReturnsError()
{
$sortedSetName = uniqid();
$startRank = 100;
Expand All @@ -3087,7 +3087,7 @@ public function testSortedSetFetchByRankWithStartRankGreaterThanEndRank_ThrowsEx
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByRankWithNegativeStartRankLessThanEndRank_ThrowsException()
public function testSortedSetFetchByRankWithNegativeStartRankLessThanEndRank_ReturnsError()
{
$sortedSetName = uniqid();
$startRank = -1;
Expand All @@ -3097,7 +3097,7 @@ public function testSortedSetFetchByRankWithNegativeStartRankLessThanEndRank_Thr
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByRankWithBadOrder_ThrowsException()
public function testSortedSetFetchByRankWithBadOrder_ReturnsError()
{
$sortedSetName = uniqid();
$response = $this->client->sortedSetFetchByRank($this->TEST_CACHE_NAME, $sortedSetName, null, null, 1234);
Expand Down Expand Up @@ -3288,7 +3288,7 @@ public function testSortedSetFetchByScore_HappyPath()
$this->assertSame($expectedElements, $fetchedElements, "The fetched elements did not match the expected elements.");
}

public function testSortedSetFetchByScoreWithNonexistantCache_ThrowsException()
public function testSortedSetFetchByScoreWithNonexistantCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -3297,15 +3297,15 @@ public function testSortedSetFetchByScoreWithNonexistantCache_ThrowsException()
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByScoreWithEmptyCacheName_ThrowsException()
public function testSortedSetFetchByScoreWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$response = $this->client->sortedSetFetchByScore("", $sortedSetName);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByScoreWithMinScoreLargerThanMaxScore_ThrowsException()
public function testSortedSetFetchByScoreWithMinScoreLargerThanMaxScore_ReturnsError()
{
$sortedSetName = uniqid();
$minScore = 100.0;
Expand All @@ -3315,7 +3315,7 @@ public function testSortedSetFetchByScoreWithMinScoreLargerThanMaxScore_ThrowsEx
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetFetchByScoreWithBadOrder_ThrowsException()
public function testSortedSetFetchByScoreWithBadOrder_ReturnsError()
{
$sortedSetName = uniqid();
$response = $this->client->sortedSetFetchByScore($this->TEST_CACHE_NAME, $sortedSetName, null, true, null, true, 1234);
Expand Down Expand Up @@ -3370,7 +3370,7 @@ public function testSortedSetRemoveElement_HappyPath()
$this->assertNotNull($response->asMiss(), "Expected a miss but got: $response");
}

public function testSortedSetRemoveElementWithNonexistentCache_ThrowsException()
public function testSortedSetRemoveElementWithNonexistentCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -3381,7 +3381,7 @@ public function testSortedSetRemoveElementWithNonexistentCache_ThrowsException()
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetRemoveElementWithEmptyCacheName_ThrowsException()
public function testSortedSetRemoveElementWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$value = uniqid();
Expand All @@ -3391,7 +3391,7 @@ public function testSortedSetRemoveElementWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetRemoveElementWithEmptyValue_ThrowsException()
public function testSortedSetRemoveElementWithEmptyValue_ReturnsError()
{
$sortedSetName = uniqid();

Expand Down Expand Up @@ -3455,7 +3455,7 @@ public function testSortedSetRemoveElements_HappyPath()
$this->assertNotNull($response->asMiss(), "Expected a miss but got: $response");
}

public function testSortedSetRemoveElementsWithNonexistentCache_ThrowsException()
public function testSortedSetRemoveElementsWithNonexistentCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -3466,7 +3466,7 @@ public function testSortedSetRemoveElementsWithNonexistentCache_ThrowsException(
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetRemoveElementsWithEmptyCacheName_ThrowsException()
public function testSortedSetRemoveElementsWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$values = [uniqid(), uniqid()];
Expand All @@ -3476,7 +3476,7 @@ public function testSortedSetRemoveElementsWithEmptyCacheName_ThrowsException()
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetRemoveElementsWithEmptyValuesArray_ThrowsException()
public function testSortedSetRemoveElementsWithEmptyValuesArray_ReturnsError()
{
$sortedSetName = uniqid();
$values = [];
Expand All @@ -3486,7 +3486,7 @@ public function testSortedSetRemoveElementsWithEmptyValuesArray_ThrowsException(
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetRemoveElementsWithNullValuesArray_ThrowsException()
public function testSortedSetRemoveElementsWithNullValuesArray_ReturnsError()
{
$sortedSetName = uniqid();

Expand Down Expand Up @@ -3664,7 +3664,7 @@ public function testSortedSetLengthByScore_HappyPath()
$this->assertEquals($expectedLength, $fetchedLength, "expected length of non-existent sorted set to be $expectedLength, not $fetchedLength");
}

public function testSortedSetLengthByScoreWithNonexistantCache_ThrowsException()
public function testSortedSetLengthByScoreWithNonexistantCache_ReturnsError()
{
$cacheName = uniqid();
$sortedSetName = uniqid();
Expand All @@ -3673,15 +3673,15 @@ public function testSortedSetLengthByScoreWithNonexistantCache_ThrowsException()
$this->assertEquals(MomentoErrorCode::CACHE_NOT_FOUND_ERROR, $response->asError()->errorCode());
}

public function testSortedSetLengthByScoreWithEmptyCacheName_ThrowsException()
public function testSortedSetLengthByScoreWithEmptyCacheName_ReturnsError()
{
$sortedSetName = uniqid();
$response = $this->client->sortedSetLengthByScore("", $sortedSetName);
$this->assertNotNull($response->asError(), "Expected error but got: $response");
$this->assertEquals(MomentoErrorCode::INVALID_ARGUMENT_ERROR, $response->asError()->errorCode());
}

public function testSortedSetLengthByScoreWithMinScoreLargerThanMaxScore_ThrowsException()
public function testSortedSetLengthByScoreWithMinScoreLargerThanMaxScore_ReturnsError()
{
$sortedSetName = uniqid();
$minScore = 100.0;
Expand Down

0 comments on commit 6e21636

Please sign in to comment.