<commit_before><?php

use Mockery as m;
use Illuminate\Contracts\Container\Container;
use Rymanalu\LaravelSimpleUploader\UploaderManager;
use Rymanalu\LaravelSimpleUploader\Contracts\Provider;
use Rymanalu\LaravelSimpleUploader\Providers\LocalProvider;
use Illuminate\Contracts\Config\Repository as ConfigContract;
use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
use Illuminate\Contracts\Filesystem\Factory as FilesystemManagerContract;

class UploaderManagerTest extends PHPUnit_Framework_TestCase
{
    public function tearDown()
    {
        m::close();
    }

    public function testCreateUploaderInstanceByResolvingTheRequiredInstanceFromContainer()
    {
        $config = new Config([
            'local' => m::mock(Provider::class),
            'request' => m::mock(Provider::class),
        ]);

        $app = m::mock(Container::class);
        $app->shouldReceive('make')->with('config')->andReturn($config);
        $app->shouldReceive('make')->with('filesystem')->andReturn(new FilesystemManager);
        $app->shouldReceive('make')->with(LocalProvider::class)->andReturn($config->get('local'));

        $uploaderManager = new UploaderManager($app);
        $uploaderManager->from('local');
    }
}

class Config implements ConfigContract
{
    protected $items = [];

    public function __construct(array $items = [])
    {
        $this->items = $items;
    }

    public function has($key)
    {
        return isset($this->items[$key]);
    }

    public function get($key, $default = null)
    {
        if ($this->has($key)) {
            return $this->items[$key];
        }

        return $default;
    }

    public function all()
    {
        return $this->items;
    }

    public function set($key, $value = null)
    {
        $this->items[$key] = $value;
    }

    public function prepend($key, $value)
    {
        //
    }

    public function push($key, $value)
    {
        //
    }
}

class FilesystemManager implements FilesystemManagerContract
{
    public function disk($name = null)
    {
        return m::mock(FilesystemContract::class);
    }
}
<commit_msg>Add new assertion in UploaderManager test script.<commit_after><?php

use Mockery as m;
use Illuminate\Support\Arr;
use Illuminate\Contracts\Container\Container;
use Rymanalu\LaravelSimpleUploader\UploaderManager;
use Rymanalu\LaravelSimpleUploader\Contracts\Provider;
use Rymanalu\LaravelSimpleUploader\Providers\LocalProvider;
use Illuminate\Contracts\Config\Repository as ConfigContract;
use Illuminate\Contracts\Filesystem\Filesystem as FilesystemContract;
use Illuminate\Contracts\Filesystem\Factory as FilesystemManagerContract;
use Rymanalu\LaravelSimpleUploader\Contracts\Uploader as UploaderContract;

class UploaderManagerTest extends PHPUnit_Framework_TestCase
{
    public function tearDown()
    {
        m::close();
    }

    public function testCreateUploaderInstanceByResolvingTheRequiredInstanceFromContainer()
    {
        $config = new Config(['local' => m::mock(Provider::class)]);

        $app = m::mock(Container::class);
        $app->shouldReceive('make')->with('config')->andReturn($config);
        $app->shouldReceive('make')->with('filesystem')->andReturn(new FilesystemManager);
        $app->shouldReceive('make')->with(LocalProvider::class)->andReturn($config->get('local'));

        $uploaderManager = new UploaderManager($app);
        $this->assertInstanceOf(UploaderContract::class, $uploaderManager->from('local'));
    }
}

class Config implements ConfigContract
{
    protected $items = [];

    public function __construct(array $items = [])
    {
        $this->items = $items;
    }

    public function has($key)
    {
        return isset($this->items[$key]);
    }

    public function get($key, $default = null)
    {
        if ($this->has($key)) {
            return Arr::get($this->items, $key, $default);
        }

        return $default;
    }

    public function all()
    {
        return $this->items;
    }

    public function set($key, $value = null)
    {
        $this->items[$key] = $value;
    }

    public function prepend($key, $value)
    {
        //
    }

    public function push($key, $value)
    {
        //
    }
}

class FilesystemManager implements FilesystemManagerContract
{
    public function disk($name = null)
    {
        return m::mock(FilesystemContract::class);
    }
}

{'fraction_non_alphanumeric': 0.1304941926668185, 'fraction_numerical': 0.0, 'mean_word_length': 3.2475822050290137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '2949739', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1259, 'n_words': 234}