<commit_before><?php namespace Orchestra\Foundation\Http\Presenters\TestCase;

use Mockery as m;
use Illuminate\Support\Fluent;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Facade;
use Orchestra\Foundation\Http\Presenters\Setting;

class SettingTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Application instance.
     *
     * @var \Illuminate\Foundation\Application
     */
    protected $app;

    /**
     * Setup the test environment.
     */
    public function setUp()
    {
        $this->app = new Container();

        $this->app['orchestra.app'] = m::mock('\Orchestra\Contracts\Foundation\Foundation');
        $this->app['translator'] = m::mock('\Illuminate\Translation\Translator')->makePartial();

        $this->app['orchestra.app']->shouldReceive('handles');
        $this->app['translator']->shouldReceive('trans');

        Facade::clearResolvedInstances();
        Container::setInstance($this->app);
    }

    /**
     * Teardown the test environment.
     */
    public function tearDown()
    {
        unset($this->app);

        m::close();
    }

    /**
     * Test Orchestra\Foundation\Http\Presenters\Setting::form()
     * method.
     *
     * @test
     */
    public function testFormMethod()
    {
        $app = $this->app;
        $model = new Fluent([
            'email_password' => <PASSWORD>,
        ]);

        $app['Illuminate\Contracts\View\Factory'] = m::mock('\Illuminate\Contracts\View\Factory');

        $form = m::mock('\Orchestra\Contracts\Html\Form\Factory');
        $encrypter = m::mock('\Illuminate\Contracts\Encryption\Encrypter');
        $grid = m::mock('\Orchestra\Contracts\Html\Form\Grid');

        $siteFieldset = m::mock('\Orchestra\Contracts\Html\Form\Fieldset');
        $siteControl = m::mock('\Orchestra\Contracts\Html\Form\Control');

        $emailFieldset = m::mock('\Orchestra\Contracts\Html\Form\Fieldset');
        $emailControl = m::mock('\Orchestra\Contracts\Html\Form\Control');

        $stub = new Setting($form, $encrypter);

        $siteFieldset->shouldReceive('control')->times(3)->andReturn($siteControl);
        $siteControl->shouldReceive('label')->times(3)->andReturnSelf()
            ->shouldReceive('attributes')->twice()->andReturnSelf()
            ->shouldReceive('options')->once()->andReturnSelf();

        $emailFieldset->shouldReceive('control')->times(13)
                ->with(m::any(), m::any())->andReturn($emailControl);
        $emailControl->shouldReceive('label')->times(13)->andReturnSelf()
            ->shouldReceive('attributes')->once()->andReturnSelf()
            ->shouldReceive('options')->times(3)->andReturnSelf()
            ->shouldReceive('value')->times(2)->andReturnSelf()
            ->shouldReceive('help')->twice()->with('email.password.help');

        $grid->shouldReceive('setup')->once()
                ->with($stub, 'orchestra::settings', $model)->andReturnNull()
            ->shouldReceive('fieldset')->once()
                ->with(trans('orchestra/foundation::label.settings.application'), m::type('Closure'))
                ->andReturnUsing(function ($t, $c) use ($siteFieldset) {
                    $c($siteFieldset);
                })
            ->shouldReceive('fieldset')->once()
                ->with(trans('orchestra/foundation::label.settings.mail'), m::type('Closure'))
                ->andReturnUsing(function ($t, $c) use ($emailFieldset) {
                    $c($emailFieldset);
                });

        $form->shouldReceive('of')->once()
                ->with('orchestra.settings', m::type('Closure'))
                ->andReturnUsing(function ($n, $c) use ($grid) {
                    $c($grid);

                    return 'foo';
                });

        $app['Illuminate\Contracts\View\Factory']->shouldReceive('make')->twice()<commit_msg>Fixes test.<commit_after><?php namespace Orchestra\Foundation\Http\Presenters\TestCase;

use Mockery as m;
use Illuminate\Support\Fluent;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Facade;
use Orchestra\Foundation\Http\Presenters\Setting;

class SettingTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Application instance.
     *
     * @var \Illuminate\Foundation\Application
     */
    protected $app;

    /**
     * Setup the test environment.
     */
    public function setUp()
    {
        $this->app = new Container();

        $this->app['orchestra.app'] = m::mock('\Orchestra\Contracts\Foundation\Foundation');
        $this->app['translator'] = m::mock('\Illuminate\Translation\Translator')->makePartial();

        $this->app['orchestra.app']->shouldReceive('handles');
        $this->app['translator']->shouldReceive('trans');

        Facade::clearResolvedInstances();
        Container::setInstance($this->app);
    }

    /**
     * Teardown the test environment.
     */
    public function tearDown()
    {
        unset($this->app);

        m::close();
    }

    /**
     * Test Orchestra\Foundation\Http\Presenters\Setting::form()
     * method.
     *
     * @test
     */
    public function testFormMethod()
    {
        $app = $this->app;
        $model = new Fluent([
            'email_password' => <PASSWORD>,
        ]);

        $app['Illuminate\Contracts\View\Factory'] = m::mock('\Illuminate\Contracts\View\Factory');

        $form = m::mock('\Orchestra\Contracts\Html\Form\Factory');
        $encrypter = m::mock('\Illuminate\Contracts\Encryption\Encrypter');
        $grid = m::mock('\Orchestra\Contracts\Html\Form\Grid');

        $siteFieldset = m::mock('\Orchestra\Contracts\Html\Form\Fieldset');
        $siteControl = m::mock('\Orchestra\Contracts\Html\Form\Control');

        $emailFieldset = m::mock('\Orchestra\Contracts\Html\Form\Fieldset');
        $emailControl = m::mock('\Orchestra\Contracts\Html\Form\Control');

        $stub = new Setting($form, $encrypter);

        $siteFieldset->shouldReceive('control')->times(3)->andReturn($siteControl);
        $siteControl->shouldReceive('label')->times(3)->andReturnSelf()
            ->shouldReceive('attributes')->twice()->andReturnSelf()
            ->shouldReceive('options')->once()->andReturnSelf();

        $emailFieldset->shouldReceive('control')->times(13)
                ->with(m::any(), m::any())->andReturn($emailControl);
        $emailControl->shouldReceive('label')->times(13)->andReturnSelf()
            ->shouldReceive('attributes')->once()->andReturnSelf()
            ->shouldReceive('options')->times(3)->andReturnSelf()
            ->shouldReceive('help')->twice()->with('email.password.help');

        $grid->shouldReceive('setup')->once()
                ->with($stub, 'orchestra::settings', $model)->andReturnNull()
            ->shouldReceive('fieldset')->once()
                ->with(trans('orchestra/foundation::label.settings.application'), m::type('Closure'))
                ->andReturnUsing(function ($t, $c) use ($siteFieldset) {
                    $c($siteFieldset);
                })
            ->shouldReceive('fieldset')->once()
                ->with(trans('orchestra/foundation::label.settings.mail'), m::type('Closure'))
                ->andReturnUsing(function ($t, $c) use ($emailFieldset) {
                    $c($emailFieldset);
                });

        $form->shouldReceive('of')->once()
                ->with('orchestra.settings', m::type('Closure'))
                ->andReturnUsing(function ($n, $c) use ($grid) {
                    $c($grid);

                    return 'foo';
                });

        $app['Illuminate\Contracts\View\Factory']->shouldReceive('make')->twice()
{'fraction_non_alphanumeric': 0.18018372703412072, 'fraction_numerical': 0.001968503937007874, 'mean_word_length': 2.6238706609605327, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 124, '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': '7313725', 'n_tokens_mistral': 2178, 'n_tokens_neox': 2158, 'n_words': 263}