Skip to content

Commit 049ccfb

Browse files
WIP: Add unit tests for PHP 5.5 (#95)
* Add unit tests for PHP 5.5
1 parent 696f224 commit 049ccfb

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: php
22

33
php:
4+
- 5.5
45
- 5.6
56
- 7.0
67
- 7.1

tests/CredisClusterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testMasterSlave()
9292
$this->waitForSlaveReplication();
9393
$this->assertEquals('value',$this->cluster->client('slave')->get('key'));
9494
$this->assertEquals('value',$this->cluster->get('key'));
95-
$this->expectException('CredisException','read-only slaves should not be writeable');
95+
$this->expectException('CredisException');
9696
$this->assertFalse($this->cluster->client('slave')->set('key2','value'));
9797
}
9898
public function testMasterWithoutSlavesAndWriteOnlyFlag()

tests/CredisTestCommon.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
// backward compatibility (https://stackoverflow.com/a/42828632/187780)
33
if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) {
4-
//class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
4+
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
55
}
66

77
class CredisTestCommon extends \PHPUnit\Framework\TestCase
@@ -150,4 +150,34 @@ public static function tearDownAfterClass()
150150
@copy('redis-sentinel.conf.bak','redis-sentinel.conf');
151151
}
152152
}
153+
154+
/**
155+
* Polyfill for older PHPUnit
156+
*/
157+
public function createMock($class)
158+
{
159+
if (method_exists($this, 'getMock')) {
160+
return $this->getMock($class);
161+
} else {
162+
return parent::createMock($class);
163+
}
164+
}
165+
166+
/**
167+
* Polyfill for older PHPUnit
168+
*/
169+
public function expectException($class, $message = NULL, $code = NULL)
170+
{
171+
if (method_exists($this, 'setExpectedException')) {
172+
$this->setExpectedException($class, $message, $code);
173+
} else {
174+
parent::expectException($class);
175+
if ($message !== null) {
176+
$this->expectExceptionMessage($message);
177+
}
178+
if ($code !== null) {
179+
$this->expectExceptionCode($code);
180+
}
181+
}
182+
}
153183
}

0 commit comments

Comments
 (0)