objectcache: Disable RedisBagOStuff constructor in unit test
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 25 Jul 2016 15:53:03 +0000 (16:53 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 25 Jul 2016 15:55:36 +0000 (16:55 +0100)
Follows-up c4e698dc2. The tests are failing on Travis CI because
php5-redis isn't installed by default. These tests shouldn't need
that to be installed (and even then, we should skip gracefully as
it is an optional dependency).

> RedisBagOStuffTest::testUnserialize with data set #0
> Exception: RedisConnectionPool requires a Redis client library.
> ./mediawiki/includes/clientpool/RedisConnectionPool.php:86

Fixed by using a mock and disabling the original constructor.

Change-Id: Icced7c30a75516c2118489ad29eac2aa5cff80ad

tests/phpunit/includes/objectcache/RedisBagOStuffTest.php

index cf87a98..705a34a 100644 (file)
@@ -2,13 +2,16 @@
 /**
  * @group BagOStuff
  */
-class RedisBagOStuffTest extends MediaWikiTestCase {
+class RedisBagOStuffTest extends PHPUnit_Framework_TestCase {
        /** @var RedisBagOStuff */
        private $cache;
 
        protected function setUp() {
                parent::setUp();
-               $this->cache = TestingAccessWrapper::newFromObject( new RedisBagOStuff( [ 'servers' => [] ] ) );
+               $cache = $this->getMockBuilder( 'RedisBagOStuff' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $this->cache = TestingAccessWrapper::newFromObject( $cache );
        }
 
        /**