<commit_before><?php

namespace Doctrine\Tests\Common\Cache;

use Doctrine\Common\Cache\Cache;

abstract class CacheTest extends \Doctrine\Tests\DoctrineTestCase
{
    public function testBasics()
    {
        $cache = $this->_getCacheDriver();

        // Test save
        $cache->save('test_key', 'testing this out');

        // Test contains to test that save() worked
        $this->assertTrue($cache->contains('test_key'));

        // Test fetch
        $this->assertEquals('testing this out', $cache->fetch('test_key'));

        // Test delete
        $cache->save('test_key2', 'test2');
        $cache->delete('test_key2');
        $this->assertFalse($cache->contains('test_key2'));
    }

    public function testDeleteAll()
    {
        $cache = $this->_getCacheDriver();
        $cache->save('test_key1', '1');
        $cache->save('test_key2', '2');
        $cache->deleteAll();

        $this->assertFalse($cache->contains('test_key1'));
        $this->assertFalse($cache->contains('test_key2'));
    }
    
    public function testFlushAll()
    {
        $cache = $this->_getCacheDriver();
        $cache->save('test_key1', '1');
        $cache->save('test_key2', '2');
        $cache->flushAll();

        $this->assertFalse($cache->contains('test_key1'));
        $this->assertFalse($cache->contains('test_key2'));
    }

    public function testNamespace()
    {
        $cache = $this->_getCacheDriver();
        $cache->setNamespace('test_');
        $cache->save('key1', 'test');
        
        $this->assertTrue($cache->contains('key1'));
        
        $cache->setNamespace('test2_');
        
        $this->assertFalse($cache->contains('key1'));
    }
    
    /**
     * @group DCOM-43
     */
    public function testGetStats()
    {
        $cache = $this->_getCacheDriver();
        $stats = $cache->getStats();
        
        
        $this->assertTrue(array_key_exists(Cache::STATS_HITS,   $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_MISSES, $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_UPTIME, $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_MEMORY_USAGE, $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_MEMORY_AVAILIABLE, $stats));
    }
    
    /**<commit_msg>starts work with xcache<commit_after><?php

namespace Doctrine\Tests\Common\Cache;

use Doctrine\Common\Cache\Cache;

abstract class CacheTest extends \Doctrine\Tests\DoctrineTestCase
{
    public function testBasics()
    {
        $cache = $this->_getCacheDriver();

        // Test save
        $cache->save('test_key', '<PASSWORD> this <PASSWORD>');

        // Test contains to test that save() worked
        $this->assertTrue($cache->contains('test_key'));

        // Test fetch
        $this->assertEquals('testing this out', $cache->fetch('test_key'));

        // Test delete
        $cache->save('test_key2', 'test2');
        $cache->delete('test_key2');
        $this->assertFalse($cache->contains('test_key2'));
    }

    public function testDeleteAll()
    {
        $cache = $this->_getCacheDriver();
        $cache->save('test_key1', '1');
        $cache->save('test_key2', '2');
        $cache->deleteAll();

        $this->assertFalse($cache->contains('test_key1'));
        $this->assertFalse($cache->contains('test_key2'));
    }
    
    public function testFlushAll()
    {
        $cache = $this->_getCacheDriver();
        $cache->save('test_key1', '1');
        $cache->save('test_key2', '2');
        $cache->flushAll();

        $this->assertFalse($cache->contains('test_key1'));
        $this->assertFalse($cache->contains('test_key2'));
    }

    public function testNamespace()
    {
        $cache = $this->_getCacheDriver();
        $cache->setNamespace('test_');
        $cache->save('key1', 'test');
        
        $this->assertTrue($cache->contains('key1'));
        
        $cache->setNamespace('test2_');
        
        $this->assertFalse($cache->contains('key1'));
    }
    
    /**
     * @group DCOM-43
     */
    public function testGetStats()
    {
        if($this instanceof ArrayCacheTest){
            $this->markTestSkipped();
        }
        
        $cache = $this->_getCacheDriver();
        $stats = $cache->getStats();
        
        
        $this->assertTrue(array_key_exists(Cache::STATS_HITS,   $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_MISSES, $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_UPTIME, $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_MEMORY_USAGE, $stats));
        $this->assertTrue(array_key_exists(Cache::STATS_MEMORY_AVAILIABLE, $stats));
    }
    
    /**
{'fraction_non_alphanumeric': 0.17327365728900257, 'fraction_numerical': 0.00937766410912191, 'mean_word_length': 2.6464646464646466, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 88, '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': '4281155', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1426, 'n_words': 197}