From 1fbbe1fffe95aa3052dfc1263da6ab3dea6293ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 24 Feb 2023 13:16:02 -0800 Subject: [PATCH] loosen tests `assertSame()` is a strict comparison, while `assertEquals()` allows for these two to be pass: ``` ['test-bzmpop' => ['member3' => '3', 'member2' => '2']], ['test-bzmpop' => ['member3' => 3.0, 'member2' => 2.0]] ``` --- tests/Predis/Command/Redis/BZMPOP_Test.php | 3 +-- tests/Predis/Command/Redis/BZPOPMAX_Test.php | 3 +-- tests/Predis/Command/Redis/BZPOPMIN_Test.php | 3 +-- tests/Predis/Command/Redis/ZADD_Test.php | 9 ++++----- tests/Predis/Command/Redis/ZINCRBY_Test.php | 9 ++++----- tests/Predis/Command/Redis/ZMPOP_Test.php | 3 +-- tests/Predis/Command/Redis/ZMSCORE_Test.php | 3 +-- tests/Predis/Command/Redis/ZPOPMAX_Test.php | 4 ++-- tests/Predis/Command/Redis/ZPOPMIN_Test.php | 4 ++-- tests/Predis/Command/Redis/ZSCORE_Test.php | 7 +++---- 10 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/Predis/Command/Redis/BZMPOP_Test.php b/tests/Predis/Command/Redis/BZMPOP_Test.php index cfd06b197..27f110469 100644 --- a/tests/Predis/Command/Redis/BZMPOP_Test.php +++ b/tests/Predis/Command/Redis/BZMPOP_Test.php @@ -56,7 +56,6 @@ public function testParseResponse(array $actualResponse, array $expectedResponse /** * @group connected - * @group relay-float * @dataProvider sortedSetsProvider * @param int $timeout * @param array $sortedSetDictionary @@ -82,7 +81,7 @@ public function testReturnsPoppedElementsFromGivenSortedSet( $redis->zadd($key, ...$sortedSetDictionary); $actualResponse = $redis->bzmpop($timeout, [$key], $modifier, $count); - $this->assertSame($expectedResponse, $actualResponse); + $this->assertEquals($expectedResponse, $actualResponse); $this->assertSame($expectedModifiedSortedSet, $redis->zrange($key, 0, -1)); } diff --git a/tests/Predis/Command/Redis/BZPOPMAX_Test.php b/tests/Predis/Command/Redis/BZPOPMAX_Test.php index 6cffc5c42..d4d7b9aa7 100644 --- a/tests/Predis/Command/Redis/BZPOPMAX_Test.php +++ b/tests/Predis/Command/Redis/BZPOPMAX_Test.php @@ -35,7 +35,6 @@ protected function getExpectedId(): string /** * @group connected - * @group relay-float * @return void * @requiresRedisVersion >= 5.0.0 */ @@ -48,7 +47,7 @@ public function testReturnsPoppedMaxElementFromGivenNonEmptySortedSet(): void $redis->zadd('test-bzpopmax', ...$sortedSetDictionary); - $this->assertSame($expectedResponse, $redis->bzpopmax(['empty sorted set', 'test-bzpopmax'], 0)); + $this->assertEquals($expectedResponse, $redis->bzpopmax(['empty sorted set', 'test-bzpopmax'], 0)); $this->assertSame($expectedModifiedSortedSet, $redis->zrange('test-bzpopmax', 0, -1)); } diff --git a/tests/Predis/Command/Redis/BZPOPMIN_Test.php b/tests/Predis/Command/Redis/BZPOPMIN_Test.php index e89b33287..115506c81 100644 --- a/tests/Predis/Command/Redis/BZPOPMIN_Test.php +++ b/tests/Predis/Command/Redis/BZPOPMIN_Test.php @@ -35,7 +35,6 @@ protected function getExpectedId(): string /** * @group connected - * @group relay-float * @return void * @requiresRedisVersion >= 5.0.0 */ @@ -48,7 +47,7 @@ public function testReturnsPoppedMinElementFromGivenNonEmptySortedSet(): void $redis->zadd('test-bzpopmin', ...$sortedSetDictionary); - $this->assertSame($expectedResponse, $redis->bzpopmin(['empty sorted set', 'test-bzpopmin'], 0)); + $this->assertEquals($expectedResponse, $redis->bzpopmin(['empty sorted set', 'test-bzpopmin'], 0)); $this->assertSame($expectedModifiedSortedSet, $redis->zrange('test-bzpopmin', 0, -1)); } diff --git a/tests/Predis/Command/Redis/ZADD_Test.php b/tests/Predis/Command/Redis/ZADD_Test.php index 35b194758..9f4827afa 100644 --- a/tests/Predis/Command/Redis/ZADD_Test.php +++ b/tests/Predis/Command/Redis/ZADD_Test.php @@ -148,17 +148,16 @@ public function testReturnsNumberOfAddedAndUpdatedElementsWithModifierCH(): void /** * @group connected - * @group relay-float * @requiresRedisVersion >= 3.0.2 */ public function testActsLikeZINCRBYWithModifierINCR(): void { $redis = $this->getClient(); - $this->assertSame('1', $redis->zadd('letters', 'INCR', 1, 'a')); - $this->assertSame('0', $redis->zadd('letters', 'INCR', -1, 'a')); - $this->assertSame('0.5', $redis->zadd('letters', 'INCR', 0.5, 'a')); - $this->assertSame('-10', $redis->zadd('letters', 'INCR', -10.5, 'a')); + $this->assertEquals('1', $redis->zadd('letters', 'INCR', 1, 'a')); + $this->assertEquals('0', $redis->zadd('letters', 'INCR', -1, 'a')); + $this->assertEquals('0.5', $redis->zadd('letters', 'INCR', 0.5, 'a')); + $this->assertEquals('-10', $redis->zadd('letters', 'INCR', -10.5, 'a')); } /** diff --git a/tests/Predis/Command/Redis/ZINCRBY_Test.php b/tests/Predis/Command/Redis/ZINCRBY_Test.php index d068f77f5..74f1cd8b8 100644 --- a/tests/Predis/Command/Redis/ZINCRBY_Test.php +++ b/tests/Predis/Command/Redis/ZINCRBY_Test.php @@ -58,16 +58,15 @@ public function testParseResponse(): void /** * @group connected - * @group relay-float */ public function testIncrementsScoreOfMemberByFloat(): void { $redis = $this->getClient(); - $this->assertSame('1', $redis->zincrby('letters', 1, 'member')); - $this->assertSame('0', $redis->zincrby('letters', -1, 'member')); - $this->assertSame('0.5', $redis->zincrby('letters', 0.5, 'member')); - $this->assertSame('-10', $redis->zincrby('letters', -10.5, 'member')); + $this->assertEquals('1', $redis->zincrby('letters', 1, 'member')); + $this->assertEquals('0', $redis->zincrby('letters', -1, 'member')); + $this->assertEquals('0.5', $redis->zincrby('letters', 0.5, 'member')); + $this->assertEquals('-10', $redis->zincrby('letters', -10.5, 'member')); } /** diff --git a/tests/Predis/Command/Redis/ZMPOP_Test.php b/tests/Predis/Command/Redis/ZMPOP_Test.php index f3f1e93ce..6d52005fd 100644 --- a/tests/Predis/Command/Redis/ZMPOP_Test.php +++ b/tests/Predis/Command/Redis/ZMPOP_Test.php @@ -56,7 +56,6 @@ public function testParseResponse(array $actualResponse, array $expectedResponse /** * @group connected - * @group relay-float * @dataProvider sortedSetsProvider * @param array $sortedSetDictionary * @param string $key @@ -80,7 +79,7 @@ public function testReturnsPoppedElementsFromGivenSortedSet( $redis->zadd($key, ...$sortedSetDictionary); $actualResponse = $redis->zmpop([$key], $modifier, $count); - $this->assertSame($expectedResponse, $actualResponse); + $this->assertEquals($expectedResponse, $actualResponse); $this->assertSame($expectedModifiedSortedSet, $redis->zrange($key, 0, -1)); } diff --git a/tests/Predis/Command/Redis/ZMSCORE_Test.php b/tests/Predis/Command/Redis/ZMSCORE_Test.php index 2f358797c..db1d0941a 100644 --- a/tests/Predis/Command/Redis/ZMSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZMSCORE_Test.php @@ -60,7 +60,6 @@ public function testParseResponse(): void /** * @group connected - * @group relay-float * @dataProvider membersProvider * @requiresRedisVersion >= 6.2.0 */ @@ -79,7 +78,7 @@ public function testReturnsScoresAssociatedWithMembers( $redis->zadd($key, ...$membersDictionary); - $this->assertSame($expectedResponse, $redis->zmscore($key, ...$members)); + $this->assertEquals($expectedResponse, $redis->zmscore($key, ...$members)); $this->assertNull($redis->zmscore($key, $notExpectedMember)[0]); } diff --git a/tests/Predis/Command/Redis/ZPOPMAX_Test.php b/tests/Predis/Command/Redis/ZPOPMAX_Test.php index 15b3e5758..817a4adfb 100644 --- a/tests/Predis/Command/Redis/ZPOPMAX_Test.php +++ b/tests/Predis/Command/Redis/ZPOPMAX_Test.php @@ -67,7 +67,7 @@ public function testParseResponse(): void /** * @group connected - * @group relay-float + * @group relay-todo * @requiresRedisVersion >= 5.0.0 */ public function testReturnsElements(): void @@ -79,7 +79,7 @@ public function testReturnsElements(): void $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(['f' => '30'], $redis->zpopmax('letters')); + $this->assertEquals(['f' => '30'], $redis->zpopmax('letters')); $this->assertSame(['e' => '20', 'd' => '20', 'c' => '10'], $redis->zpopmax('letters', 3)); $this->assertSame(['b' => '0', 'a' => '-10'], $redis->zpopmax('letters', 3)); } diff --git a/tests/Predis/Command/Redis/ZPOPMIN_Test.php b/tests/Predis/Command/Redis/ZPOPMIN_Test.php index 51b54b88d..ec14cf271 100644 --- a/tests/Predis/Command/Redis/ZPOPMIN_Test.php +++ b/tests/Predis/Command/Redis/ZPOPMIN_Test.php @@ -67,7 +67,7 @@ public function testParseResponse(): void /** * @group connected - * @group relay-float + * @group relay-todo * @requiresRedisVersion >= 5.0.0 */ public function testReturnsElements(): void @@ -79,7 +79,7 @@ public function testReturnsElements(): void $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(['a' => '-10'], $redis->zpopmin('letters')); + $this->assertEquals(['a' => '-10'], $redis->zpopmin('letters')); $this->assertSame(['b' => '0', 'c' => '10', 'd' => '20'], $redis->zpopmin('letters', 3)); $this->assertSame(['e' => '20', 'f' => '30'], $redis->zpopmin('letters', 3)); } diff --git a/tests/Predis/Command/Redis/ZSCORE_Test.php b/tests/Predis/Command/Redis/ZSCORE_Test.php index 3c96e078a..680788d58 100644 --- a/tests/Predis/Command/Redis/ZSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZSCORE_Test.php @@ -58,7 +58,6 @@ public function testParseResponse(): void /** * @group connected - * @group relay-float */ public function testReturnsRank(): void { @@ -66,9 +65,9 @@ public function testReturnsRank(): void $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame('-10', $redis->zscore('letters', 'a')); - $this->assertSame('0', $redis->zscore('letters', 'b')); - $this->assertSame('20', $redis->zscore('letters', 'e')); + $this->assertEquals('-10', $redis->zscore('letters', 'a')); + $this->assertEquals('0', $redis->zscore('letters', 'b')); + $this->assertEquals('20', $redis->zscore('letters', 'e')); $this->assertNull($redis->zscore('unknown', 'a')); }