Skip to content

Commit c651b72

Browse files
committed
MongoDb and Redis modules fixed
1 parent 0c4f073 commit c651b72

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/Codeception/Module/Redis.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
<?php
2-
/**
3-
* @author judgedim
4-
*/
52

63
namespace Codeception\Module;
74

5+
use Codeception\Exception\Module as ModuleException;
86
use \Codeception\Util\Driver\Redis as RedisDriver;
97

8+
/**
9+
* Works with Redis database.
10+
*
11+
* ## Configuration
12+
*
13+
* * host *required* - redis host to connect
14+
* * port *required* - redis port.
15+
* * database *required* - redis database.
16+
* * cleanup: true - defined data will be purged before running every test.
17+
*
18+
* ## Public Properties
19+
* * driver - contains Connection Driver
20+
*
21+
* @author judgedim
22+
*/
1023
class Redis extends \Codeception\Module
1124
{
12-
/**
13-
* @api
14-
* @var
15-
*/
16-
public $dbh;
17-
18-
protected $isDumpFileEmpty = false;
19-
2025
protected $config = array(
2126
'cleanup' => true
2227
);
2328

2429
/**
25-
* @var \Codeception\Util\Driver\Redis
30+
* @var RedisDriver
2631
*/
2732
public $driver;
2833

@@ -34,7 +39,7 @@ public function _initialize()
3439
$this->driver = new RedisDriver($this->config['host'], $this->config['port']);
3540
$this->driver->select_db($this->config['database']);
3641
} catch (\Exception $e) {
37-
throw new \Codeception\Exception\Module(__CLASS__, $e->getMessage());
42+
throw new ModuleException(__CLASS__, $e->getMessage());
3843
}
3944

4045
}
@@ -52,13 +57,19 @@ public function _after(\Codeception\TestCase $test)
5257
parent::_after($test);
5358
}
5459

60+
/**
61+
* Cleans up Redis database.
62+
*/
63+
public function cleanupRedis() {
64+
$this->cleanup();
65+
}
66+
5567
protected function cleanup()
5668
{
5769
try {
5870
$this->driver->flushdb();
59-
6071
} catch (\Exception $e) {
61-
throw new \Codeception\Exception\Module(__CLASS__, $e->getMessage());
72+
throw new ModuleException(__CLASS__, $e->getMessage());
6273
}
6374
}
6475

0 commit comments

Comments
 (0)