<commit_before><?php

namespace Bjorvack\ImageStacker\Tests;

use Bjorvack\ImageStacker\Exporters\JsonExporter;
use Bjorvack\ImageStacker\Helpers\StringTransformer;
use Bjorvack\ImageStacker\Image;
use Bjorvack\ImageStacker\Stacker;

class JsonExporterTest extends BaseTest
{
    private $fileName;

    private $storagePath;

    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);

        $this->fileName = dirname(__FILE__) .'/bjorvack.png';
        $this->storagePath = dirname(__FILE__);
    }

    public function testCreateFromStacker()
    {
        $stacker = new Stacker('unitTest');
        $image = new Image($this->fileName, 'bjorvack');
        $stacker->addImage($image);
        $stacker->stack();

        JsonExporter::save($stacker, $this->storagePath);

        $packedImage = $this->storagePath.'/'.StringTransformer::slugify($stacker->getName()).'.png';
        $packedJson = $this->storagePath.'/'.StringTransformer::slugify($stacker->getName()).'.json';

        $this->assertTrue(file_exists($packedImage));
        $this->assertTrue(file_exists($packedJson));

        $this->assertEquals(
            file_get_contents($packedJson),
            '{"name":"unitTest","size":{"width":180,"height":180},"images":[{"name":"bjorvack","path":"' . $filename = str_replace('/', '\/', $this->fileName) . '","size":{"width":180,"height":180},"position":{"x":0,"y":0}}]}'
        );

        unlink($packedImage);
        unlink($packedJson);
    }
}<commit_msg>Add message for missing files to tests<commit_after><?php

namespace Bjorvack\ImageStacker\Tests;

use Bjorvack\ImageStacker\Exporters\JsonExporter;
use Bjorvack\ImageStacker\Helpers\StringTransformer;
use Bjorvack\ImageStacker\Image;
use Bjorvack\ImageStacker\Stacker;

class JsonExporterTest extends BaseTest
{
    private $fileName;

    private $storagePath;

    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);

        $this->fileName = dirname(__FILE__) .'/bjorvack.png';
        $this->storagePath = dirname(__FILE__);
    }

    public function testCreateFromStacker()
    {
        $stacker = new Stacker('unitTest');
        $image = new Image($this->fileName, 'bjorvack');
        $stacker->addImage($image);
        $stacker->stack();

        JsonExporter::save($stacker, $this->storagePath);

        $packedImage = $this->storagePath.'/'.StringTransformer::slugify($stacker->getName()).'.png';
        $packedJson = $this->storagePath.'/'.StringTransformer::slugify($stacker->getName()).'.json';

        $this->assertTrue(file_exists($packedImage), $packedImage . " doesn't exist");
        $this->assertTrue(file_exists($packedJson), $packedJson . " doesn't exist");

        $this->assertEquals(
            file_get_contents($packedJson),
            '{"name":"unitTest","size":{"width":180,"height":180},"images":[{"name":"bjorvack","path":"' . $filename = str_replace('/', '\/', $this->fileName) . '","size":{"width":180,"height":180},"position":{"x":0,"y":0}}]}'
        );

        unlink($packedImage);
        unlink($packedJson);
    }
}
{'fraction_non_alphanumeric': 0.1835718730553827, 'fraction_numerical': 0.008711885500933417, 'mean_word_length': 3.820089955022489, 'pattern_counts': {'":': 26, '<': 5, '<?xml version=': 0, '>': 31, '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': '2244477', 'n_tokens_mistral': 1017, 'n_tokens_neox': 989, 'n_words': 138}