Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e4c7b3

Browse files
committed
Change version_compare usage in tests
1 parent 9ee94ca commit 7e4c7b3

1 file changed

Lines changed: 33 additions & 33 deletions

File tree

tests/RedisTest.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function setUp() {
4747
}
4848

4949
protected function minVersionCheck($version) {
50-
return version_compare($this->version, $version, "ge");
50+
return version_compare($this->version, $version) >= 0;
5151
}
5252

5353
protected function mstime() {
@@ -86,7 +86,7 @@ protected function havePipeline() {
8686
public function testMinimumVersion()
8787
{
8888
// Minimum server version required for tests
89-
$this->assertTrue(version_compare($this->version, "2.4.0", "ge"));
89+
$this->assertTrue(version_compare($this->version, "2.4.0") >= 0);
9090
}
9191

9292
public function testPing() {
@@ -119,7 +119,7 @@ public function testPipelinePublish() {
119119
// can't be sure what's going on in the instance, but we can do some things.
120120
public function testPubSub() {
121121
// Only available since 2.8.0
122-
if(version_compare($this->version, "2.8.0", "lt")) {
122+
if (version_compare($this->version, "2.8.0") < 0) {
123123
$this->markTestSkipped();
124124
return;
125125
}
@@ -199,7 +199,7 @@ public function testBitsets() {
199199
}
200200

201201
public function testBitPos() {
202-
if(version_compare($this->version, "2.8.7", "lt")) {
202+
if (version_compare($this->version, "2.8.7") < 0) {
203203
$this->MarkTestSkipped();
204204
return;
205205
}
@@ -311,7 +311,7 @@ public function testSet()
311311
/* Extended SET options for Redis >= 2.6.12 */
312312
public function testExtendedSet() {
313313
// Skip the test if we don't have a new enough version of Redis
314-
if(version_compare($this->version, '2.6.12', 'lt')) {
314+
if (version_compare($this->version, '2.6.12') < 0) {
315315
$this->markTestSkipped();
316316
return;
317317
}
@@ -556,7 +556,7 @@ public function testIncr()
556556
public function testIncrByFloat()
557557
{
558558
// incrbyfloat is new in 2.6.0
559-
if (version_compare($this->version, "2.5.0", "lt")) {
559+
if (version_compare($this->version, "2.5.0") < 0) {
560560
$this->markTestSkipped();
561561
}
562562

@@ -695,7 +695,7 @@ public function testDelete() {
695695
}
696696

697697
public function testUnlink() {
698-
if (version_compare($this->version, "4.0.0", "lt")) {
698+
if (version_compare($this->version, "4.0.0") < 0) {
699699
$this->markTestSkipped();
700700
return;
701701
}
@@ -1031,7 +1031,7 @@ public function testSortAsc() {
10311031
}
10321032

10331033
// SORT list → [ghi, def, abc]
1034-
if (version_compare($this->version, "2.5.0", "lt")) {
1034+
if (version_compare($this->version, "2.5.0") < 0) {
10351035
$this->assertEquals(array_reverse($list), $this->redis->sort('list'));
10361036
$this->assertEquals(array_reverse($list), $this->redis->sort('list', ['sort' => 'asc']));
10371037
} else {
@@ -1072,7 +1072,7 @@ public function testSortDesc() {
10721072
}
10731073

10741074
// SORT list → [ghi, abc, def]
1075-
if (version_compare($this->version, "2.5.0", "lt")) {
1075+
if (version_compare($this->version, "2.5.0") < 0) {
10761076
$this->assertEquals(array_reverse($list), $this->redis->sort('list', ['sort' => 'desc']));
10771077
} else {
10781078
// TODO rewrite, from 2.6.0 release notes:
@@ -1803,7 +1803,7 @@ public function testttl() {
18031803
$this->assertEquals($this->redis->ttl('x'), -1);
18041804

18051805
// A key that doesn't exist (> 2.8 will return -2)
1806-
if(version_compare($this->version, "2.8.0", "gte")) {
1806+
if(version_compare($this->version, "2.8.0") >= 0) {
18071807
$this->redis->del('x');
18081808
$this->assertEquals($this->redis->ttl('x'), -2);
18091809
}
@@ -1857,7 +1857,7 @@ public function testSlowlog() {
18571857

18581858
public function testWait() {
18591859
// Closest we can check based on redis commmit history
1860-
if(version_compare($this->version, '2.9.11', 'lt')) {
1860+
if(version_compare($this->version, '2.9.11') < 0) {
18611861
$this->markTestSkipped();
18621862
return;
18631863
}
@@ -1906,7 +1906,7 @@ public function testInfo() {
19061906
"total_commands_processed",
19071907
"role"
19081908
];
1909-
if (version_compare($this->version, "2.5.0", "lt")) {
1909+
if (version_compare($this->version, "2.5.0") < 0) {
19101910
array_push($keys,
19111911
"changes_since_last_save",
19121912
"bgsave_in_progress",
@@ -1929,7 +1929,7 @@ public function testInfo() {
19291929
public function testInfoCommandStats() {
19301930

19311931
// INFO COMMANDSTATS is new in 2.6.0
1932-
if (version_compare($this->version, "2.5.0", "lt")) {
1932+
if (version_compare($this->version, "2.5.0") < 0) {
19331933
$this->markTestSkipped();
19341934
}
19351935

@@ -1949,7 +1949,7 @@ public function testSelect() {
19491949
}
19501950

19511951
public function testSwapDB() {
1952-
if (version_compare($this->version, "4.0.0", "lt")) {
1952+
if (version_compare($this->version, "4.0.0") < 0) {
19531953
$this->markTestSkipped();
19541954
}
19551955

@@ -2063,7 +2063,7 @@ public function testZX() {
20632063
$this->assertTrue(1 === $this->redis->zAdd('key', 0, 'val0'));
20642064
$this->assertTrue(1 === $this->redis->zAdd('key', 2, 'val2'));
20652065
$this->assertTrue(2 === $this->redis->zAdd('key', 4, 'val4', 5, 'val5')); // multiple parameters
2066-
if (version_compare($this->version, "3.0.2", "lt")) {
2066+
if (version_compare($this->version, "3.0.2") < 0) {
20672067
$this->assertTrue(1 === $this->redis->zAdd('key', 1, 'val1'));
20682068
$this->assertTrue(1 === $this->redis->zAdd('key', 3, 'val3'));
20692069
} else {
@@ -2357,7 +2357,7 @@ public function testZRangeScoreArg() {
23572357

23582358
public function testZRangeByLex() {
23592359
/* ZRANGEBYLEX available on versions >= 2.8.9 */
2360-
if(version_compare($this->version, "2.8.9", "lt")) {
2360+
if(version_compare($this->version, "2.8.9") < 0) {
23612361
$this->MarkTestSkipped();
23622362
return;
23632363
}
@@ -2376,7 +2376,7 @@ public function testZRangeByLex() {
23762376
}
23772377

23782378
public function testZLexCount() {
2379-
if (version_compare($this->version, "2.8.9", "lt")) {
2379+
if (version_compare($this->version, "2.8.9") < 0) {
23802380
$this->MarkTestSkipped();
23812381
return;
23822382
}
@@ -2406,7 +2406,7 @@ public function testZLexCount() {
24062406
}
24072407

24082408
public function testZRemRangeByLex() {
2409-
if (version_compare($this->version, "2.8.9", "lt")) {
2409+
if (version_compare($this->version, "2.8.9") < 0) {
24102410
$this->MarkTestSkipped();
24112411
return;
24122412
}
@@ -2425,7 +2425,7 @@ public function testZRemRangeByLex() {
24252425
}
24262426

24272427
public function testBZPop() {
2428-
if (version_compare($this->version, "5.0.0", "lt")) {
2428+
if (version_compare($this->version, "5.0.0") < 0) {
24292429
$this->MarkTestSkipped();
24302430
return;
24312431
}
@@ -2447,7 +2447,7 @@ public function testBZPop() {
24472447
}
24482448

24492449
public function testZPop() {
2450-
if (version_compare($this->version, "5.0.0", "lt")) {
2450+
if (version_compare($this->version, "5.0.0") < 0) {
24512451
$this->MarkTestSkipped();
24522452
return;
24532453
}
@@ -2536,7 +2536,7 @@ public function testHashes() {
25362536
$this->redis->hSet('h', 'y', 'not-a-number');
25372537
$this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1));
25382538

2539-
if (version_compare($this->version, "2.5.0", "ge")) {
2539+
if (version_compare($this->version, "2.5.0") >= 0) {
25402540
// hIncrByFloat
25412541
$this->redis->del('h');
25422542
$this->assertTrue(1.5 === $this->redis->hIncrByFloat('h','x', 1.5));
@@ -2592,7 +2592,7 @@ public function testHashes() {
25922592
$this->assertTrue('' === $h1['t']);
25932593

25942594
// hstrlen
2595-
if (version_compare($this->version, '3.2.0', 'ge')) {
2595+
if (version_compare($this->version, '3.2.0') >= 0) {
25962596
$this->redis->del('h');
25972597
$this->assertTrue(0 === $this->redis->hStrLen('h', 'x')); // key doesn't exist
25982598
$this->redis->hSet('h', 'foo', 'bar');
@@ -2623,7 +2623,7 @@ public function testSetRange() {
26232623
public function testObject() {
26242624
/* Version 3.0.0 (represented as >= 2.9.0 in redis info) and moving
26252625
* forward uses "embstr" instead of "raw" for small string values */
2626-
if (version_compare($this->version, "2.9.0", "lt")) {
2626+
if (version_compare($this->version, "2.9.0") < 0) {
26272627
$str_small_encoding = "raw";
26282628
} else {
26292629
$str_small_encoding = "embstr";
@@ -4512,7 +4512,7 @@ private function checkCompression($mode, $level)
45124512

45134513
public function testDumpRestore() {
45144514

4515-
if (version_compare($this->version, "2.5.0", "lt")) {
4515+
if (version_compare($this->version, "2.5.0") < 0) {
45164516
$this->markTestSkipped();
45174517
}
45184518

@@ -4581,7 +4581,7 @@ private function array_diff_recursive($aArray1, $aArray2) {
45814581

45824582
public function testScript() {
45834583

4584-
if (version_compare($this->version, "2.5.0", "lt")) {
4584+
if (version_compare($this->version, "2.5.0") < 0) {
45854585
$this->markTestSkipped();
45864586
}
45874587

@@ -4613,7 +4613,7 @@ public function testScript() {
46134613

46144614
public function testEval() {
46154615

4616-
if (version_compare($this->version, "2.5.0", "lt")) {
4616+
if (version_compare($this->version, "2.5.0") < 0) {
46174617
$this->markTestSkipped();
46184618
}
46194619

@@ -4733,7 +4733,7 @@ public function testEval() {
47334733
}
47344734

47354735
public function testEvalSHA() {
4736-
if (version_compare($this->version, "2.5.0", "lt")) {
4736+
if (version_compare($this->version, "2.5.0") < 0) {
47374737
$this->markTestSkipped();
47384738
}
47394739

@@ -4893,7 +4893,7 @@ public function testReconnectSelect() {
48934893

48944894
public function testTime() {
48954895

4896-
if (version_compare($this->version, "2.5.0", "lt")) {
4896+
if (version_compare($this->version, "2.5.0") < 0) {
48974897
$this->markTestSkipped();
48984898
}
48994899

@@ -4935,7 +4935,7 @@ protected function get_keyspace_count($str_db) {
49354935
}
49364936

49374937
public function testScan() {
4938-
if(version_compare($this->version, "2.8.0", "lt")) {
4938+
if(version_compare($this->version, "2.8.0") < 0) {
49394939
$this->markTestSkipped();
49404940
return;
49414941
}
@@ -5004,7 +5004,7 @@ public function testScan() {
50045004
}
50055005

50065006
public function testHScan() {
5007-
if(version_compare($this->version, "2.8.0", "lt")) {
5007+
if (version_compare($this->version, "2.8.0") < 0) {
50085008
$this->markTestSkipped();
50095009
return;
50105010
}
@@ -5044,7 +5044,7 @@ public function testHScan() {
50445044
}
50455045

50465046
public function testSScan() {
5047-
if(version_compare($this->version, "2.8.0", "lt")) {
5047+
if (version_compare($this->version, "2.8.0") < 0) {
50485048
$this->markTestSkipped();
50495049
return;
50505050
}
@@ -5076,7 +5076,7 @@ public function testSScan() {
50765076
}
50775077

50785078
public function testZScan() {
5079-
if(version_compare($this->version, "2.8.0", "lt")) {
5079+
if (version_compare($this->version, "2.8.0") < 0) {
50805080
$this->markTestSkipped();
50815081
return;
50825082
}
@@ -5159,7 +5159,7 @@ protected function createPFKey($str_key, $i_count) {
51595159

51605160
public function testPFCommands() {
51615161
// Isn't available until 2.8.9
5162-
if(version_compare($this->version, "2.8.9", "lt")) {
5162+
if (version_compare($this->version, "2.8.9") < 0) {
51635163
$this->markTestSkipped();
51645164
return;
51655165
}

0 commit comments

Comments
 (0)