<commit_before><?php

namespace AppBundle\Service\File\Storage;

class S3StorageTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var S3Storage
     */
    private $object;

    public function setUp()
    {
        // connect to fakes3 (https://github.com/jubos/fake-s3)
        // see docker-composer.yml for params
        $awsClient = new \Aws\S3\S3Client([
            'version' => 'latest',
            'region'  => 'eu-west-1',
            'endpoint' =>  'http://fakes3:4569',
            'validate' => false,
            'credentials' => [
                'key'    => 'YOUR_ACCESS_KEY_ID',
                'secret' => 'YOUR_SECRET_ACCESS_KEY',
            ],
        ]);

        $this->object = new S3Storage($awsClient, 'unitTestBucket');
    }

    public function testUploadDownloadDeleteTextContent()
    {
        // create timestamped file and key to undo effects of potential previous executions
        $key = 'storagetest-upload-download-delete' . microtime(1);
        $fileContent = 'FILE-CONTENT-' . microtime(1);

        // store
        $ret = $this->object->store($key, $fileContent);
        $this->assertEquals(200, $ret->toArray()['@metadata']['statusCode']);

        // retrieve
        $this->assertEquals($fileContent, $this->object->retrieve($key));

        // delete<commit_msg>change unit test storage bucket<commit_after><?php

namespace AppBundle\Service\File\Storage;

class S3StorageTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var S3Storage
     */
    private $object;

    public function setUp()
    {
        // connect to fakes3 (https://github.com/jubos/fake-s3)
        // see docker-composer.yml for params
        $awsClient = new \Aws\S3\S3Client([
            'version' => 'latest',
            'region'  => 'eu-west-1',
            'endpoint' =>  'http://fakes3:4569',
            'validate' => false,
            'credentials' => [
                'key'    => 'YOUR_ACCESS_KEY_ID',
                'secret' => 'YOUR_SECRET_ACCESS_KEY',
            ],
        ]);

        $this->object = new S3Storage($awsClient, 'unit_test_bucket');
    }

    public function testUploadDownloadDeleteTextContent()
    {
        // create timestamped file and key to undo effects of potential previous executions
        $key = 'storagetest-upload-download-delete' . microtime(1);
        $fileContent = 'FILE-CONTENT-' . microtime(1);

        // store
        $ret = $this->object->store($key, $fileContent);
        $this->assertEquals(200, $ret->toArray()['@metadata']['statusCode']);

        // retrieve
        $this->assertEquals($fileContent, $this->object->retrieve($key));

        // delete
{'fraction_non_alphanumeric': 0.1463963963963964, 'fraction_numerical': 0.013513513513513514, 'mean_word_length': 2.176400476758045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3516833', 'n_tokens_mistral': 817, 'n_tokens_neox': 788, 'n_words': 149}