<commit_before><?php

namespace Kitpages\FileSystemBundle\Test;

// external service
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\DoctrineBundle\Registry;

use Kitpages\FileSystemBundle\ValueObject\AdapterFile;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;


abstract class AbstractAdapterTest extends WebTestCase{ // extends \PHPUnit_Framework_TestCase{

    protected $adapterClass = null;
    protected $adapterList = array();
    protected $pathFileLocal = null;
    protected $pathFileAmazon = null;
    protected $pathFileAmazon2 = null;
    protected $fileAmazon = null;
    protected $fileAmazon2 = null;

    public function setUp()
    {
        $client = static::createClient();
        $container = $client->getContainer();
        $fileSystemList = $container->get('kitpages_file_system.filesystem_map')->getAdapterList();
        foreach($fileSystemList as $fileSystem) {
            if (get_class($fileSystem) == "Kitpages\FileSystemBundle\Service\Adapter\\".$this->adapterClass) {
                $this->adapterList[] = $fileSystem;
            }
        }


        $this->pathFileLocal = dirname(__FILE__).'/../Tests/tmp/testAmazon.txt';
        $this->pathFileAdapter = 'test/testAmazon.txt';
        $this->pathFileAdapter2 = 'test/testAmazon2.txt';
        $this->fileAdapter = new AdapterFile($this->pathFileAdapter, false);
        $this->fileAdapter2 = new AdapterFile($this->pathFileAdapter2, false);
        $fNew = fopen($this->pathFileLocal, 'w');
        fputs ($fNew, 'fichier de test');
        fclose($fNew);
    }

    public function tearDown()
    {
        if (is_file($this->pathFileLocal)) {
            unlink($this->pathFileLocal);
        }
        foreach($this->adapterList as $adapter) {
            $adapter->unlink($this->fileAdapter);
            $adapter->unlink($this->fileAdapter2);
        }
    }

    public function testCopyAndMove()<commit_msg>add automatic generation for the temp directory for unit test<commit_after><?php

namespace Kitpages\FileSystemBundle\Test;

// external service
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Bundle\DoctrineBundle\Registry;

use Kitpages\FileSystemBundle\ValueObject\AdapterFile;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;


abstract class AbstractAdapterTest extends WebTestCase{ // extends \PHPUnit_Framework_TestCase{

    protected $adapterClass = null;
    protected $adapterList = array();
    protected $pathFileLocal = null;
    protected $pathFileAmazon = null;
    protected $pathFileAmazon2 = null;
    protected $fileAmazon = null;
    protected $fileAmazon2 = null;

    public function setUp()
    {
        $client = static::createClient();
        $container = $client->getContainer();
        $fileSystemList = $container->get('kitpages_file_system.filesystem_map')->getAdapterList();
        foreach($fileSystemList as $fileSystem) {
            if (get_class($fileSystem) == "Kitpages\FileSystemBundle\Service\Adapter\\".$this->adapterClass) {
                $this->adapterList[] = $fileSystem;
            }
        }

        if (!is_dir(dirname(__FILE__).'/../Tests/tmp')) {
            mkdir(dirname(__FILE__).'/../Tests/tmp');
        }


        $this->pathFileLocal = dirname(__FILE__).'/../Tests/tmp/testAmazon.txt';
        $this->pathFileAdapter = 'test/testAmazon.txt';
        $this->pathFileAdapter2 = 'test/testAmazon2.txt';
        $this->fileAdapter = new AdapterFile($this->pathFileAdapter, false);
        $this->fileAdapter2 = new AdapterFile($this->pathFileAdapter2, false);
        $fNew = fopen($this->pathFileLocal, 'w');
        fputs ($fNew, 'fichier de test');
        fclose($fNew);
    }

    public function tearDown()
    {
        if (is_file($this->pathFileLocal)) {
            unlink($this->pathFileLocal);
        }
        foreach($this->adapterList as $adapter) {
            $adapter->unlink($this->fileAdapter);
            $adapter->unlink($this->fileAdapter2);
        }
    }

    public function testCopyAndMove()
{'fraction_non_alphanumeric': 0.13008130081300814, 'fraction_numerical': 0.0034491254003449125, 'mean_word_length': 3.1260162601626016, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '3801085', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1131, 'n_words': 201}