<commit_before><?php
namespace Gears\Cache;

use DateTime;
use InvalidArgumentException;

class FilesystemTest extends \PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        $cacheDir = self::getCachePath();

        @self::delTreeHelper($cacheDir);

        @mkdir($cacheDir);
    }

    public static function tearDownAfterClass()
    {
        self::delTreeHelper(self::getCachePath());
    }

    /**
     * @expectedException InvalidArgumentException
     */
    public function testConstructorBadPath()
    {
        $cache = new Filesystem(self::getCachePath() . 'BADPATH!?');

        $this->assertNotInstanceOf('\\Gears\\Cache\\Filesystem', $cache);
    }

    public function getConstructor()
    {
        $cache = new Filesystem(self::getCachePath());

        $this->assertInstanceOf('\\Gears\\Cache\\Filesystem', $cache);

        return $cache;
    }

    /**
     * @dataProvider providerCacheData
     */
    public function testStore($key, $value, $expectedFilename)
    {
        $cache = $this->getConstructor();

        $cache->store($key, $value);

        $this->assertFileExists(self::getCachePath() . $expectedFilename);
    }

    /**
     * @depends      testStore
     * @dataProvider providerCacheData
     */
    public function testGetModifiedTime($key, $value, $expectedFilename)
    {
        if ($value == $value) {
        } //Get rid of the IDE warning...
        
        $cache = $this->getConstructor();

        $modifiedDateTime = $cache->getLastModifiedTime($key);

        $this->assertNotEquals(0, $modifiedDateTime->format('U'));

        $this->assertEquals(
            DateTime::createFromFormat('U', time())->format('Y-m-d H:i'),
            $modifiedDateTime->format('Y-m-d H:i')
        );
        
        $this->assertEquals(filemtime(self::getCachePath() . $expectedFilename), $modifiedDateTime->format('U'));
    }

    /**
     * @depends      testStore
     * @dataProvider providerCacheData
     */
    public function testGet($key, $value, $expectedFilename)
    {
        $cache = $this->getConstructor();

        $this->assertFileExists(self::getCachePath() . $expectedFilename);

        $this->assertEquals($value, $cache->fetch($key));
    }<commit_msg>Removed test that didn't test much and could false-ly fail sometimes.<commit_after><?php
namespace Gears\Cache;

use DateTime;
use InvalidArgumentException;

class FilesystemTest extends \PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        $cacheDir = self::getCachePath();

        @self::delTreeHelper($cacheDir);

        @mkdir($cacheDir);
    }

    public static function tearDownAfterClass()
    {
        self::delTreeHelper(self::getCachePath());
    }

    /**
     * @expectedException InvalidArgumentException
     */
    public function testConstructorBadPath()
    {
        $cache = new Filesystem(self::getCachePath() . 'BADPATH!?');

        $this->assertNotInstanceOf('\\Gears\\Cache\\Filesystem', $cache);
    }

    public function getConstructor()
    {
        $cache = new Filesystem(self::getCachePath());

        $this->assertInstanceOf('\\Gears\\Cache\\Filesystem', $cache);

        return $cache;
    }

    /**
     * @dataProvider providerCacheData
     */
    public function testStore($key, $value, $expectedFilename)
    {
        $cache = $this->getConstructor();

        $cache->store($key, $value);

        $this->assertFileExists(self::getCachePath() . $expectedFilename);
    }

    /**
     * @depends      testStore
     * @dataProvider providerCacheData
     */
    public function testGetModifiedTime($key, $value, $expectedFilename)
    {
        if ($value == $value) {
        } //Get rid of the IDE warning...
        
        $cache = $this->getConstructor();

        $modifiedDateTime = $cache->getLastModifiedTime($key);

        $this->assertNotEquals(0, $modifiedDateTime->format('U'));
        
        $this->assertEquals(filemtime(self::getCachePath() . $expectedFilename), $modifiedDateTime->format('U'));
    }

    /**
     * @depends      testStore
     * @dataProvider providerCacheData
     */
    public function testGet($key, $value, $expectedFilename)
    {
        $cache = $this->getConstructor();

        $this->assertFileExists(self::getCachePath() . $expectedFilename);

        $this->assertEquals($value, $cache->fetch($key));
    }
{'fraction_non_alphanumeric': 0.14506593906321055, 'fraction_numerical': 0.00045475216007276033, 'mean_word_length': 2.7470187393526406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '7132439', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1206, 'n_words': 216}