objectcache: Fix HashBagOStuffTest test in PHP 7.1
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 1 Dec 2017 21:28:36 +0000 (13:28 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 1 Dec 2017 21:28:36 +0000 (13:28 -0800)
> There was 1 error:
>
> 1) HashBagOStuffTest::testEvictionAdd
> A non-numeric value encountered
>
> tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php:106

This warning is new in PHP 7.1, however the behaviour is not new.
This code was already not behaving as it should have. Concatenation
preceeds addition/multiplication. As such, this was producing
(int)-10 each time instead of (str)"key0" through (str)"key10".

Change-Id: Ibb1a59e373740772f02dfec77ee7ebd9d181d852

tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php

index b2278c3..53d27c0 100644 (file)
@@ -103,7 +103,7 @@ class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
                for ( $i = 10; $i < 20; $i++ ) {
                        $cache->set( "key$i", 1 );
                        $this->assertEquals( 1, $cache->get( "key$i" ) );
-                       $this->assertEquals( false, $cache->get( "key" . $i - 10 ) );
+                       $this->assertEquals( false, $cache->get( "key" . ( $i - 10 ) ) );
                }
        }