<commit_before><?php

/**
 * (c) FSi sp. z o.o. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace FSi\Component\DataSource\Tests\Extension\Symfony;

use FSi\Component\DataSource\Extension\Symfony\Form\Field\FormFieldExtension;
use ReflectionMethod;

class FormFieldExtensionTest extends \PHPUnit_Framework_TestCase
{
    public function testBuildBooleanForm()
    {
        $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactory')
            ->disableOriginalConstructor()
            ->getMock();

        $formFielExtension = new FormFieldExtension($formFactory);

        $method = new ReflectionMethod(
            'FSi\Component\DataSource\Extension\Symfony\Form\Field\FormFieldExtension',
            'buildBooleanForm'
        );
        $method->setAccessible(true);

        $field = $this->getMock('FSi\Component\DataSource\Driver\Collection\Extension\Core\Field\Boolean');

        $field->expects($this->once())
            ->method('getname')
            ->will($this->returnValue('name'));

        $form = $this->getMockBuilder('Symfony\Component\Form\Form')
            ->disableOriginalConstructor()
            ->getMock();

        $form->expects($this->exactly(1))->method('add')
            ->with(
                $this->equalTo('name'),
                $this->equalTo('choice'),
                $this->equalTo(
                    array(
                        'choices' => array(
                            '1' => 'tak',
                            '0' => 'nie',
                        ),
                        'multiple' => false,
                        'empty_value' => ''
                    )
                )
            );

        $options =  array(
            'choices' => array(
                '1' => 'tak',
                '0' => 'nie'
            )
        );

        $method->invoke(
            $formFielExtension,
            $form,
            $field,
            $options
        );
    }
}<commit_msg>Test case: Build form when options not provided<commit_after><?php

/**
 * (c) FSi sp. z o.o. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace FSi\Component\DataSource\Tests\Extension\Symfony;

use FSi\Component\DataSource\Extension\Symfony\Form\Field\FormFieldExtension;
use ReflectionMethod;

class FormFieldExtensionTest extends \PHPUnit_Framework_TestCase
{
    public function testBuildBooleanFormWhenOptionsProvided()
    {
        $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactory')
            ->disableOriginalConstructor()
            ->getMock();

        $formFielExtension = new FormFieldExtension($formFactory);

        $method = new ReflectionMethod(
            'FSi\Component\DataSource\Extension\Symfony\Form\Field\FormFieldExtension',
            'buildBooleanForm'
        );
        $method->setAccessible(true);

        $field = $this->getMock('FSi\Component\DataSource\Driver\Collection\Extension\Core\Field\Boolean');

        $field->expects($this->once())
            ->method('getname')
            ->will($this->returnValue('name'));

        $form = $this->getMockBuilder('Symfony\Component\Form\Form')
            ->disableOriginalConstructor()
            ->getMock();

        $form->expects($this->exactly(1))->method('add')
            ->with(
                $this->equalTo('name'),
                $this->equalTo('choice'),
                $this->equalTo(
                    array(
                        'choices' => array(
                            '1' => 'tak',
                            '0' => 'nie',
                        ),
                        'multiple' => false,
                        'empty_value' => ''
                    )
                )
            );

        $options =  array(
            'choices' => array(
                '1' => 'tak',
                '0' => 'nie'
            )
        );

        $method->invoke(
            $formFielExtension,
            $form,
            $field,
            $options
        );
    }

    public function testBuildBooleanFormWhenOptionsNotProvided()
    {
        $formFactory = $this->getMockBuilder('Symfony\Component\Form\FormFactory')
            ->disableOriginalConstructor()
            ->getMock();
git s
        $formFielExtension = new FormFieldExtension($formFactory);

        $method = new ReflectionMethod(
            'FSi\Component\DataSource\Extension\Symfony\Form\Field\FormFieldExtension',
            'buildBooleanForm'
        );
        $method->setAccessible(true);

        $field = $this->getMock('FSi\Component\DataSource\Driver\Collection\Extension\Core\Field\Boolean');

        $field->expects($this->once())
            ->method('getname')
            ->will($this->returnValue('name'));

        $form = $this->getMockBuilder('Symfony\Component\Form\Form')
            ->disableOriginalConstructor()
            ->getMock();

        $form->expects($this->exactly(1))->method('add')
            ->with(
                $this->equalTo('name'),
                $this->equalTo('choice'),
                $this->equalTo(
                    array(
                        'choices' => array(
                            '1' => 'yes',
                            '0' => 'no',
                        ),
                        'multiple' => false,
                        'empty_value' => ''
                    )
                )
            );

        $options =  array();

        $method->invoke(
            $formFielExtension,
            $form,
            $field,
            $options
        );
    }
}
{'fraction_non_alphanumeric': 0.13370376801528044, 'fraction_numerical': 0.002257336343115124, 'mean_word_length': 1.5577264653641207, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 91, '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': '986175', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1458, 'n_words': 234}