From 71509e0514d0568d43cdfbb8c121197aabf552be Mon Sep 17 00:00:00 2001 From: Frank Naegler <frank.naegler@typo3.org> Date: Thu, 21 Sep 2017 12:09:19 +0200 Subject: [PATCH] [BUGFIX] Fix broken redis tests Resolves: #82533 Releases: master, 8.7, 7.6 Change-Id: Ia47f604b9cb7fa53d3707e6150554709cbfdb763 Reviewed-on: https://review.typo3.org/54197 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Unit/Cache/Backend/RedisBackendTest.php | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php index a9edc8a06a45..667d70a83fcb 100644 --- a/typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php +++ b/typo3/sysext/core/Tests/Unit/Cache/Backend/RedisBackendTest.php @@ -201,7 +201,12 @@ class RedisBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $this->setUpBackend(['database' => 1]); $identifier = $this->getUniqueId('identifier'); $this->backend->set($identifier, 'data'); - $this->assertTrue($this->redis->exists('identData:' . $identifier)); + $result = $this->redis->exists('identData:' . $identifier); + if (is_int($result)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $result = (bool)$result; + } + $this->assertTrue($result); } /** @@ -615,7 +620,12 @@ class RedisBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $tag = 'thisTag'; $this->backend->set($identifier, 'data', [$tag]); $this->backend->remove($identifier); - $this->assertFalse($this->redis->exists('identTags:' . $identifier)); + $result = $this->redis->exists('identTags:' . $identifier); + if (is_int($result)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $result = (bool)$result; + } + $this->assertFalse($result); } /** @@ -758,7 +768,12 @@ class RedisBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $tag = 'tag1'; $this->backend->set($identifier, 'data', [$tag]); $this->backend->flushByTag($tag); - $this->assertFalse($this->redis->exists('identTags:' . $identifier)); + $result = $this->redis->exists('identTags:' . $identifier); + if (is_int($result)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $result = (bool)$result; + } + $this->assertFalse($result); } /** @@ -789,7 +804,12 @@ class RedisBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $tag = 'tag1'; $this->backend->set($identifier, 'data', [$tag]); $this->backend->flushByTag($tag); - $this->assertFalse($this->redis->exists('tagIdents:' . $tag)); + $result = $this->redis->exists('tagIdents:' . $tag); + if (is_int($result)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $result = (bool)$result; + } + $this->assertFalse($result); } /** @@ -819,7 +839,12 @@ class RedisBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $this->backend->set($identifier . 'B', 'data', ['tag']); $this->redis->delete('identData:' . $identifier . 'A'); $this->backend->collectGarbage(); - $this->assertTrue($this->redis->exists('identData:' . $identifier . 'B')); + $result = $this->redis->exists('identData:' . $identifier . 'B'); + if (is_int($result)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $result = (bool)$result; + } + $this->assertTrue($result); } /** @@ -835,9 +860,19 @@ class RedisBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase $this->redis->delete('identData:' . $identifier . 'A'); $this->backend->collectGarbage(); $expectedResult = [false, true]; + $resultA = $this->redis->exists('identTags:' . $identifier . 'A'); + $resultB = $this->redis->exists('identTags:' . $identifier . 'B'); + if (is_int($resultA)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $resultA = (bool)$resultA; + } + if (is_int($resultB)) { + // Since 3.1.4 of phpredis/phpredis the return types has been changed + $resultB = (bool)$resultB; + } $actualResult = [ - $this->redis->exists('identTags:' . $identifier . 'A'), - $this->redis->exists('identTags:' . $identifier . 'B') + $resultA, + $resultB ]; $this->assertSame($expectedResult, $actualResult); } -- GitLab