Skip to content

Commit f8d7241

Browse files
committed
Throw exception when extension isn't loaded
1 parent e08d96e commit f8d7241

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Model/Datasource/RedisSource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ class RedisSource extends DataSource {
6363
*
6464
* @param array $config Array of configuration information for the Datasource
6565
* @return bool True if connecting to the DataSource succeeds, else false
66+
* @throws RedisSourceException
6667
*/
6768
public function __construct($config = array()) {
6869
parent::__construct($config);
6970

7071
if (!$this->enabled()) {
71-
return false;
72+
throw new RedisSourceException(__d('redis', 'Extension is not loaded.'));
7273
}
7374

7475
$this->_connection = new Redis();

Test/Case/Model/Datasource/RedisSourceTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function tearDown() {
9191
*
9292
* Tests that `connect` will never be called when redis extension is not loaded.
9393
*
94+
* @expectedException RedisSourceException
9495
* @return void
9596
*/
9697
public function testConstructExtensionNotLoaded() {

0 commit comments

Comments
 (0)