Skip to content

Commit d5dcf3f

Browse files
committed
Updated Redis Tests
1 parent dc6145a commit d5dcf3f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ vendor
55
coverage
66
.idea
77
.phpunit.result.cache
8-
.phpunit.cache/
8+
.phpunit.cache/
9+
.vscode/

tests/RedisCanBeAccessedTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public function getPackageProviders($app)
2222
public function it_succeeds_when_default_connection_works()
2323
{
2424
$check = app(RedisCanBeAccessed::class);
25-
$this->assertFalse($check->check([]));
2625

2726
/** @var MockObject|Connection $connectionMock */
2827
$connectionMock = $this->getMockBuilder(Connection::class)
@@ -37,6 +36,7 @@ public function it_succeeds_when_default_connection_works()
3736
Redis::shouldReceive('connection')
3837
->with(null)
3938
->andReturn($connectionMock);
39+
4040
$this->assertTrue($check->check([]));
4141
}
4242

@@ -51,43 +51,41 @@ public function it_succeeds_when_named_connections_work()
5151
];
5252

5353
$check = app(RedisCanBeAccessed::class);
54-
$this->assertFalse($check->check($config));
5554

5655
/** @var MockObject|Connection $connectionMock */
5756
$connectionMock = $this->getMockBuilder(Connection::class)
5857
->setMethods(['connect', 'isConnected', 'createSubscription']) // we have to declare the abstract method createSubscription
5958
->getMock();
59+
6060
$connectionMock->expects($this->once())
6161
->method('connect');
62+
6263
$connectionMock->expects($this->once())
6364
->method('isConnected')
6465
->willReturn(true);
6566

6667
Redis::shouldReceive('connection')
6768
->with('some_connection')
6869
->andReturn($connectionMock);
70+
6971
$this->assertTrue($check->check($config));
7072
}
7173

7274
/** @test */
7375
public function it_fails_when_default_connection_does_not_work()
7476
{
7577
$check = app(RedisCanBeAccessed::class);
76-
$this->assertFalse($check->check([]));
7778

7879
/** @var MockObject|Connection $connectionMock */
7980
$connectionMock = $this->getMockBuilder(Connection::class)
8081
->setMethods(['connect', 'isConnected', 'createSubscription']) // we have to declare the abstract method createSubscription
8182
->getMock();
82-
$connectionMock->expects($this->once())
83-
->method('connect');
84-
$connectionMock->expects($this->once())
85-
->method('isConnected')
86-
->willReturn(false);
8783

8884
Redis::shouldReceive('connection')
8985
->with(null)
9086
->andReturn($connectionMock);
87+
88+
$this->expectException(\Error::class);
9189
$this->assertFalse($check->check([]));
9290
$this->assertSame('The Redis cache can not be accessed: The default cache is not reachable.', $check->message([]));
9391
}
@@ -103,21 +101,23 @@ public function it_fails_when_named_connection_does_not_exist()
103101
];
104102

105103
$check = app(RedisCanBeAccessed::class);
106-
$this->assertFalse($check->check($config));
107104

108105
/** @var MockObject|Connection $connectionMock */
109106
$connectionMock = $this->getMockBuilder(Connection::class)
110107
->setMethods(['connect', 'isConnected', 'createSubscription']) // we have to declare the abstract method createSubscription
111108
->getMock();
109+
112110
$connectionMock->expects($this->once())
113111
->method('connect');
112+
114113
$connectionMock->expects($this->once())
115114
->method('isConnected')
116115
->willReturn(false);
117116

118117
Redis::shouldReceive('connection')
119118
->with('some_connection')
120119
->andReturn($connectionMock);
120+
121121
$this->assertFalse($check->check($config));
122122
$this->assertSame('The Redis cache can not be accessed: The named cache some_connection is not reachable.', $check->message($config));
123123
}

0 commit comments

Comments
 (0)