<commit_before><?php
namespace Cachet\Test\Backend;

use Cachet\Backend;
use Cachet\Cache;
use Cachet\Item;

class PHPRedisTest extends \BackendTestCase
{
    public function getBackend()
    {
        if (!extension_loaded('redis'))
            $this->markTestSkipped("phpredis extension not found");
        
        if (!isset($GLOBALS['settings']['redis']) || !$GLOBALS['settings']['redis']['server'])
            $this->markTestSkipped("Please supply a redis server in .cachettestrc");
        
        $redis = new \Redis();
        $redis->connect(
            $GLOBALS['settings']['redis']['server'], 
            isset($GLOBALS['settings']['redis']['port']) ? $GLOBALS['settings']['redis']['port'] : 6379
        );
        return new \Cachet\Backend\PHPRedis($redis);
    }
}<commit_msg>fixed phpredis purging on setup<commit_after><?php
namespace Cachet\Test\Backend;

use Cachet\Backend;
use Cachet\Cache;
use Cachet\Item;

class PHPRedisTest extends \BackendTestCase
{
    public function setUp()
    {
        $redis = $this->getRedis();
        $redis->flushDb();
        $count = $redis->dbSize();
        if ($count != 0)
            throw new \Exception();
    }
    
    public function getBackend()
    {
        $redis = $this->getRedis();
        return new \Cachet\Backend\PHPRedis($redis);
    }
    
    protected function getRedis()
    {
        if (!extension_loaded('redis'))
            $this->markTestSkipped("phpredis extension not found");
        
        if (!isset($GLOBALS['settings']['redis']) || !$GLOBALS['settings']['redis']['server'])
            $this->markTestSkipped("Please supply a redis server in .cachettestrc");
        
        $redis = new \Redis();
        $redis->connect(
            $GLOBALS['settings']['redis']['server'], 
            isset($GLOBALS['settings']['redis']['port']) ? $GLOBALS['settings']['redis']['port'] : 6379
        );
        $redis->select($GLOBALS['settings']['redis']['database']);
        return $redis;
    }
}
{'fraction_non_alphanumeric': 0.1726041144004014, 'fraction_numerical': 0.004515805318615153, 'mean_word_length': 2.7551789077212807, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6939787', 'n_tokens_mistral': 602, 'n_tokens_neox': 606, 'n_words': 112}