<commit_before><?php

namespace Nobox\LazyStrings\Tests;

use Illuminate\Filesystem\Filesystem;
use Mockery;
use Nobox\LazyStrings\Helpers\Str;
use Nobox\LazyStrings\LazyStrings;
use Nobox\LazyStrings\Validators\LazyValidator;
use Orchestra\Testbench\TestCase;

class LazyStringsTest extends TestCase
{
    protected $lazyStrings;
    protected $filesystem;
    protected $validator;
    protected $str;
    protected $url = 'http://docs.google.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/export?format=csv';

    public function setUp()
    {
        parent::setUp();

        $this->filesystem = Mockery::mock('Illuminate\Filesystem\Filesystem');
        $this->validator = new LazyValidator;
        $this->str = new Str;
        $this->lazyStrings = new LazyStrings($this->filesystem, $this->validator, $this->str);
    }

    public function tearDown()
    {
        Mockery::close();
    }

    protected function getPackageProviders($app)
    {
        return ['Nobox\LazyStrings\LazyStringsServiceProvider'];
    }

    public function testStringsAreGeneratedFromGoogleDoc()
    {
        $this->lazyStrings->setCsvUrl($this->url);
        $this->lazyStrings->setSheets([
            'en' => 0,
            'es' => 1329731586,
            'pt' => 1443604037,
        ]);

        $this->setUpMocks();

        $expectedStrings = [
            'en' => [
                'foo' => 'Hello!',
                'lazy' => 'LazyStrings',
                'laravel' => 'PHP Framework',
                'something' => [
                    'else' => [
                        'here' => 'Yeah'
                    ]
                ]
            ],

            'es' => [
                'foo' => 'bar - es',
                'lazy' => 'LazyStrings (ES)',
                'laravel' => 'PHP Framework (ES)',
            ],

            'pt' => [
                'foo' => 'bar - pt',
                'lazy' => 'LazyStrings (PT)',
                'laravel' => 'PHP Framework (PT)',
            ],
        ];

        $strings = $this->lazyStrings->generate();

        $this->assertSame($strings, $expectedStrings);
        $this->assertArrayHasKey('en', $strings);
        $this->assertArrayHasKey('es', $strings);
        $this->assertArrayHasKey('pt', $strings);
        $this->assertArrayHasKey('foo', $strings['en']);
        $this->assertArrayHasKey('lazy', $strings['en']);
        $this->assertArrayHasKey('laravel', $strings['en']);
        $this->assertArrayHasKey('something', $strings['en']);
        $this->assertArrayHasKey('else', $strings['en']['something']);
        $this->assertArrayHasKey('here', $strings['en']['something']['else']);
        $this->assertArrayHasKey('foo', $strings['es']);
        $this->assertArrayHasKey('lazy', $strings['es']);
        $this->assertArrayHasKey('laravel', $strings['es']);
        $this->assertArrayHasKey('foo', $strings['pt']);
        $this->assertArrayHasKey('lazy', $strings['pt']);
        $this->assertArrayHasKey('laravel', $strings['pt']);
    }

    public function testStringsAreGeneratedWithAppendedSheet()
    {
        $this->lazyStrings->setCsvUrl($this->url);
        $this->lazyStrings->setSheets([
            'en' => [0, 1626663029],
            'es' => 1329731586,
            'pt' => 1443604037,
        ]);

        $this->setUpMocks();

        $expectedStrings = [
            'en' => [
                'foo' => 'Hello!',
                'lazy' => 'LazyStrings',
                'laravel' => 'PHP Framework',
                'something' => [
                    'else' => [
                        'here' => 'Yeah'
                    ]
                ],
                'another' => [
                    'thing' => 'extra value in EN',
                    'extra-thing' => 'This is an extra thing',
                    'in-english' => 'Another one in English',
                ],
            ]
        ];

        $a = [
            'another' => [
                'thing' => 'extra value in EN'
            ]
        ];

        $strings = $this->lazyStrings->generate();

        $this->assertSame($strings['en'], $expectedStrings['en']);<commit_msg>Remove leftover array.<commit_after><?php

namespace Nobox\LazyStrings\Tests;

use Illuminate\Filesystem\Filesystem;
use Mockery;
use Nobox\LazyStrings\Helpers\Str;
use Nobox\LazyStrings\LazyStrings;
use Nobox\LazyStrings\Validators\LazyValidator;
use Orchestra\Testbench\TestCase;

class LazyStringsTest extends TestCase
{
    protected $lazyStrings;
    protected $filesystem;
    protected $validator;
    protected $str;
    protected $url = 'http://docs.google.com/spreadsheets/d/1V_cHt5Fe4x9XwVepvlXB39sqKXD3xs_QbM-NppkrE4A/export?format=csv';

    public function setUp()
    {
        parent::setUp();

        $this->filesystem = Mockery::mock('Illuminate\Filesystem\Filesystem');
        $this->validator = new LazyValidator;
        $this->str = new Str;
        $this->lazyStrings = new LazyStrings($this->filesystem, $this->validator, $this->str);
    }

    public function tearDown()
    {
        Mockery::close();
    }

    protected function getPackageProviders($app)
    {
        return ['Nobox\LazyStrings\LazyStringsServiceProvider'];
    }

    public function testStringsAreGeneratedFromGoogleDoc()
    {
        $this->lazyStrings->setCsvUrl($this->url);
        $this->lazyStrings->setSheets([
            'en' => 0,
            'es' => 1329731586,
            'pt' => 1443604037,
        ]);

        $this->setUpMocks();

        $expectedStrings = [
            'en' => [
                'foo' => 'Hello!',
                'lazy' => 'LazyStrings',
                'laravel' => 'PHP Framework',
                'something' => [
                    'else' => [
                        'here' => 'Yeah'
                    ]
                ]
            ],

            'es' => [
                'foo' => 'bar - es',
                'lazy' => 'LazyStrings (ES)',
                'laravel' => 'PHP Framework (ES)',
            ],

            'pt' => [
                'foo' => 'bar - pt',
                'lazy' => 'LazyStrings (PT)',
                'laravel' => 'PHP Framework (PT)',
            ],
        ];

        $strings = $this->lazyStrings->generate();

        $this->assertSame($strings, $expectedStrings);
        $this->assertArrayHasKey('en', $strings);
        $this->assertArrayHasKey('es', $strings);
        $this->assertArrayHasKey('pt', $strings);
        $this->assertArrayHasKey('foo', $strings['en']);
        $this->assertArrayHasKey('lazy', $strings['en']);
        $this->assertArrayHasKey('laravel', $strings['en']);
        $this->assertArrayHasKey('something', $strings['en']);
        $this->assertArrayHasKey('else', $strings['en']['something']);
        $this->assertArrayHasKey('here', $strings['en']['something']['else']);
        $this->assertArrayHasKey('foo', $strings['es']);
        $this->assertArrayHasKey('lazy', $strings['es']);
        $this->assertArrayHasKey('laravel', $strings['es']);
        $this->assertArrayHasKey('foo', $strings['pt']);
        $this->assertArrayHasKey('lazy', $strings['pt']);
        $this->assertArrayHasKey('laravel', $strings['pt']);
    }

    public function testStringsAreGeneratedWithAppendedSheet()
    {
        $this->lazyStrings->setCsvUrl($this->url);
        $this->lazyStrings->setSheets([
            'en' => [0, 1626663029],
            'es' => 1329731586,
            'pt' => 1443604037,
        ]);

        $this->setUpMocks();

        $expectedStrings = [
            'en' => [
                'foo' => 'Hello!',
                'lazy' => 'LazyStrings',
                'laravel' => 'PHP Framework',
                'something' => [
                    'else' => [
                        'here' => 'Yeah'
                    ]
                ],
                'another' => [
                    'thing' => 'extra value in EN',
                    'extra-thing' => 'This is an extra thing',
                    'in-english' => 'Another one in English',
                ],
            ]
        ];

        $strings = $this->lazyStrings->generate();

        $this->assertSame($strings['en'], $expectedStrings['en']);
{'fraction_non_alphanumeric': 0.16658524670249145, 'fraction_numerical': 0.014655593551538837, 'mean_word_length': 1.9008147360963514, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 149, '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': '4500856', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2378, 'n_words': 376}