<commit_before><?php

declare(strict_types=1);

namespace Orchid\Tests\Unit\Screen;

use Orchid\Screen\Builder;
use Orchid\Screen\Fields\Input;
use Orchid\Screen\Repository;
use Orchid\Tests\TestUnitCase;


/**
 * Class BuilderTest.
 */
class BuilderTest extends TestUnitCase
{

    /**
     * @throws \Throwable
     */
    public function testSimpleBuild()
    {
        $form = $this->getBuilder(['name' => 'Alexandr'])
            ->generateForm();

        $this->assertStringContainsString('name="name"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testPrefixBuild()
    {
        $form = $this->getBuilder(['profile' => ['name' => 'Alexandr']])
            ->setPrefix('profile')
            ->generateForm();

        $this->assertStringContainsString('name="profile[name]"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testLanguageBuild()
    {
        $form = $this->getBuilder([
            'profile' => [
                'en' => ['name' => 'Alexandr'],
            ],
        ])
            ->setLanguage('en')
            ->setPrefix('profile')
            ->generateForm();


        $this->assertStringContainsString('name="profile[en][name]', $form);
        $this->assertStringContainsString('lang="en"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testPrefixForFields()
    {

        $fields = [
            Input::make('name')->prefix('one'),
            Input::make('name')->prefix('two'),
            Input::make('name')->prefix('three'),
        ];

        $data = new Repository(['name' => 'Alexandr']);

        $builder = new Builder($fields, $data);


        $form = $builder->generateForm();

        $this->assertStringContainsString('name="one[name]"', $form);
        $this->assertStringContainsString('name="two[name]"', $form);
        $this->assertStringContainsString('name="three[name]"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testPrefixAndLanguageForFields()
    {

        $fields = [
            Input::make('name')->prefix('one'),
            Input::make('name')->prefix('two'),
            Input::make('name')->prefix('three'),
        ];

        $data = new Repository(['en' => ['name' => 'Alexandr']]);

        $builder = new Builder($fields, $data);

        $form = $builder
            ->setLanguage('en')
            ->generateForm();

        $this->assertStringContainsString('name="one[en][name]"', $form);
        $this->assertStringContainsString('name="two[en][name]"', $form);
        $this->assertStringContainsString('name="three[en][name]"', $form);
        $this->assertStringContainsString('lang="en"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }


    /**
     * @param array $value
     *
     * @return Builder
     */
    private function getBuilder($value = [])
    {
        $fields = [Input::make('name')];
        $data = new Repository($value);

        return new Builder($fields, $data);
    }

}<commit_msg>Apply fixes from StyleCI<commit_after><?php

declare(strict_types=1);

namespace Orchid\Tests\Unit\Screen;

use Orchid\Screen\Builder;
use Orchid\Screen\Repository;
use Orchid\Tests\TestUnitCase;
use Orchid\Screen\Fields\Input;

/**
 * Class BuilderTest.
 */
class BuilderTest extends TestUnitCase
{
    /**
     * @throws \Throwable
     */
    public function testSimpleBuild()
    {
        $form = $this->getBuilder(['name' => 'Alexandr'])
            ->generateForm();

        $this->assertStringContainsString('name="name"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testPrefixBuild()
    {
        $form = $this->getBuilder(['profile' => ['name' => 'Alexandr']])
            ->setPrefix('profile')
            ->generateForm();

        $this->assertStringContainsString('name="profile[name]"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testLanguageBuild()
    {
        $form = $this->getBuilder([
            'profile' => [
                'en' => ['name' => 'Alexandr'],
            ],
        ])
            ->setLanguage('en')
            ->setPrefix('profile')
            ->generateForm();

        $this->assertStringContainsString('name="profile[en][name]', $form);
        $this->assertStringContainsString('lang="en"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testPrefixForFields()
    {
        $fields = [
            Input::make('name')->prefix('one'),
            Input::make('name')->prefix('two'),
            Input::make('name')->prefix('three'),
        ];

        $data = new Repository(['name' => 'Alexandr']);

        $builder = new Builder($fields, $data);

        $form = $builder->generateForm();

        $this->assertStringContainsString('name="one[name]"', $form);
        $this->assertStringContainsString('name="two[name]"', $form);
        $this->assertStringContainsString('name="three[name]"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @throws \Throwable
     */
    public function testPrefixAndLanguageForFields()
    {
        $fields = [
            Input::make('name')->prefix('one'),
            Input::make('name')->prefix('two'),
            Input::make('name')->prefix('three'),
        ];

        $data = new Repository(['en' => ['name' => 'Alexandr']]);

        $builder = new Builder($fields, $data);

        $form = $builder
            ->setLanguage('en')
            ->generateForm();

        $this->assertStringContainsString('name="one[en][name]"', $form);
        $this->assertStringContainsString('name="two[en][name]"', $form);
        $this->assertStringContainsString('name="three[en][name]"', $form);
        $this->assertStringContainsString('lang="en"', $form);
        $this->assertStringContainsString('value="Alexandr"', $form);
    }

    /**
     * @param array $value
     *
     * @return Builder
     */
    private function getBuilder($value = [])
    {
        $fields = [Input::make('name')];
        $data = new Repository($value);

        return new Builder($fields, $data);
    }
}
{'fraction_non_alphanumeric': 0.18674248092174173, 'fraction_numerical': 0.0002992667963489451, 'mean_word_length': 2.5477707006369426, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 89, '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': '1666519', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1900, 'n_words': 287}