Skip to content

Commit 00eb0b7

Browse files
authored
.travis.yml
* .travis.yml
1 parent 3a662c0 commit 00eb0b7

File tree

3 files changed

+65
-20
lines changed

3 files changed

+65
-20
lines changed

.travis.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
sudo: required
2+
3+
language: php
4+
php:
5+
- '5.5'
6+
- '5.6'
7+
- '7.0'
8+
- '7.1'
9+
- hhvm
10+
11+
matrix:
12+
allow_failures:
13+
- php: hhvm
14+
15+
services:
16+
- docker
17+
18+
before_install:
19+
- docker pull cheprasov/redis-for-tests:latest;
20+
- |
21+
docker run -i -t -d \
22+
-p 127.0.0.1:6381:6381 \
23+
-p 127.0.0.1:6382:6382 \
24+
-p 127.0.0.1:6383:6383 \
25+
-p 127.0.0.1:6384:6384 \
26+
-p 127.0.0.1:6385:6385 \
27+
-p 127.0.0.1:6386:6386 \
28+
-p 127.0.0.1:6387:6387 \
29+
-p 127.0.0.1:6388:6388 \
30+
cheprasov/redis-for-tests
31+
- docker ps;
32+
- sleep 2;
33+
34+
install:
35+
- composer install

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"php": ">=5.5"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "5.1.*"
23+
"phpunit/phpunit": "4.8.*"
2424
}
2525
}

tests/Unit/RedisProtocolTest.php

+29-19
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,35 @@ public function test_read() {
131131

132132
$Protocol = new RedisProtocol($ConnectionMock = $this->getConnectionMock());
133133

134-
$ConnectionMock->method('readLine')->willReturn(
135-
"*3\r\n", "$1\r\n", ":2\r\n", "$1\r\n",
136-
"+OK\r\n",
137-
"+PING-PONG\r\n",
138-
":100\r\n",
139-
":-42\r\n",
140-
":-1\r\n",
141-
"*3\r\n", "$3\r\n", "$3\r\n", "$3\r\n",
142-
"*3\r\n", "$3\r\n", "$0\r\n", "$-1\r\n",
143-
"$6\r\n",
144-
'-ERR SomeError'
145-
);
146-
147-
$ConnectionMock->method('read')->willReturn(
148-
"1\r\n", "3\r\n",
149-
"SET\r\n", "foo\r\n", "bar\r\n",
150-
"SET\r\n", "\r\n",
151-
"\r\n\xff\x0\r\n\r\n"
152-
);
134+
$ConnectionMock->method('readLine')->will($this->returnCallback(
135+
function() {
136+
static $return = [
137+
"*3\r\n", "$1\r\n", ":2\r\n", "$1\r\n",
138+
"+OK\r\n",
139+
"+PING-PONG\r\n",
140+
":100\r\n",
141+
":-42\r\n",
142+
":-1\r\n",
143+
"*3\r\n", "$3\r\n", "$3\r\n", "$3\r\n",
144+
"*3\r\n", "$3\r\n", "$0\r\n", "$-1\r\n",
145+
"$6\r\n",
146+
'-ERR SomeError'
147+
];
148+
return array_shift($return);
149+
}
150+
));
151+
152+
$ConnectionMock->method('read')->will($this->returnCallback(
153+
function() {
154+
static $return = [
155+
"1\r\n", "3\r\n",
156+
"SET\r\n", "foo\r\n", "bar\r\n",
157+
"SET\r\n", "\r\n",
158+
"\r\n\xff\x0\r\n\r\n"
159+
];
160+
return array_shift($return);
161+
}
162+
));
153163

154164
$this->assertSame(['1', 2, '3'], $Method->invoke($Protocol));
155165
$this->assertSame(true, $Method->invoke($Protocol));

0 commit comments

Comments
 (0)