<commit_before><?php

namespace XhProf\Storage;

class FileStorageTest extends \PHPUnit_Framework_TestCase
{
    protected function setUp()
    {

    }

    protected function tearDown()
    {
        $this->trace = null;
    }

    public function testPersisterCanWriteFile()
    {
        $data = unserialize(file_get_contents(__DIR__.'/../../fixtures/example.trace'));
        $token = '03a208c1140e2dd9ad953bfe5db9e7835e7a035a';
        $trace = $this->getTraceMock($data, $token);
        $expectedFile = sprintf('%s/xhprof/%s.trace', sys_get_temp_dir(), $token);

        $storage = new FileStorage();
        $this->assertNull($storage->store($trace));
        $this->assertFileExists($expectedFile);
        unlink($expectedFile);
        rmdir(dirname($expectedFile));
    }
<commit_msg>Fixed issue with error in test if the trace directory already contains traces<commit_after><?php

namespace XhProf\Storage;

class FileStorageTest extends \PHPUnit_Framework_TestCase
{
    protected function setUp()
    {

    }

    protected function tearDown()
    {
        $this->trace = null;
    }

    public function testPersisterCanWriteFile()
    {
        $data = unserialize(file_get_contents(__DIR__.'/../../fixtures/example.trace'));
        $token = '03a208c1140e2dd9ad953bfe5db9e7835e7a035a';
        $trace = $this->getTraceMock($data, $token);
        $expectedFile = sprintf('%s/xhprof/%s.trace', sys_get_temp_dir(), $token);
        $dir = dirname($expectedFile);
        $directoryExists = file_exists($dir);

        $storage = new FileStorage();
        $this->assertNull($storage->store($trace));
        $this->assertFileExists($expectedFile);
        unlink($expectedFile);
        if (!$directoryExists) {
            rmdir(dirname($expectedFile));
        }
    }

{'fraction_non_alphanumeric': 0.13519553072625698, 'fraction_numerical': 0.026815642458100558, 'mean_word_length': 3.061224489795918, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2221491', 'n_tokens_mistral': 571, 'n_tokens_neox': 541, 'n_words': 90}