Skip to content

Commit 7681bcf

Browse files
committed
improve tests skipping
1 parent 03faa65 commit 7681bcf

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ before_install:
130130

131131
install: travis_retry composer install --prefer-dist --no-interaction --no-suggest
132132

133-
before_script:
134-
- SUPERVISE=no travis_retry ./start-cluster.sh || { cat ./cluster/*.log; false; }
133+
before_script: SUPERVISE=no travis_retry ./start-cluster.sh || { cat ./cluster/*.log; false; }
135134

136135
script: vendor/bin/phpunit --exclude-group ${LUMEN_VERSION:+laravel-only},${HORIZON:-horizon}

tests/Integration/Connections/PhpRedisConnectionTest.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public function setUp()
2929
parent::setUp();
3030

3131
if (! extension_loaded('redis')) {
32-
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
33-
3432
return;
3533
}
3634

@@ -39,13 +37,25 @@ public function setUp()
3937

4038
public function testAllowsTransactionsOnAggregateConnection()
4139
{
40+
if (! extension_loaded('redis')) {
41+
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
42+
43+
return;
44+
}
45+
4246
$transaction = $this->subject->transaction();
4347

4448
$this->assertInstanceOf(Redis::class, $transaction);
4549
}
4650

4751
public function testExecutesCommandsInTransaction()
4852
{
53+
if (! extension_loaded('redis')) {
54+
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
55+
56+
return;
57+
}
58+
4959
$result = $this->subject->transaction(function ($trans) {
5060
$trans->set('test-key', 'test value');
5161
$trans->get('test-key');
@@ -59,6 +69,12 @@ public function testExecutesCommandsInTransaction()
5969

6070
public function testExecutesTransactionsOnMaster()
6171
{
72+
if (! extension_loaded('redis')) {
73+
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
74+
75+
return;
76+
}
77+
6278
$expectedSubset = ['role' => 'master'];
6379

6480
$info = $this->subject->transaction(function ($transaction) {
@@ -70,6 +86,12 @@ public function testExecutesTransactionsOnMaster()
7086

7187
public function testAbortsTransactionOnException()
7288
{
89+
if (! extension_loaded('redis')) {
90+
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
91+
92+
return;
93+
}
94+
7395
$exception = null;
7496

7597
try {
@@ -88,6 +110,12 @@ public function testAbortsTransactionOnException()
88110

89111
public function testRetriesTransactionWhenConnectionFails()
90112
{
113+
if (! extension_loaded('redis')) {
114+
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
115+
116+
return;
117+
}
118+
91119
$this->expectException(RedisRetryException::class);
92120

93121
$this->subject = $this->makeConnection(1, 0); // retry once and immediately
@@ -99,6 +127,12 @@ public function testRetriesTransactionWhenConnectionFails()
99127

100128
public function testCanReconnectWhenConnectionFails()
101129
{
130+
if (! extension_loaded('redis')) {
131+
$this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__);
132+
133+
return;
134+
}
135+
102136
$retries = 3;
103137
$attempts = 0;
104138

0 commit comments

Comments
 (0)