<commit_before><?php
/**
 * Created by PhpStorm.
 * User: stefan
 * Date: 27.07.15
 * Time: 12:41
 */

namespace TQ\Bundle\ExtDirectBundle\Tests\DependencyInjection;

use Symfony\Component\Config\Definition\Processor;
use TQ\Bundle\ExtDirectBundle\DependencyInjection\Configuration;

/**
 * Class ConfigurationTest
 *
 * @package TQ\Bundle\ExtDirectBundle\Tests\DependencyInjection
 */
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @param bool $debug
     * @return Configuration
     */
    protected function getConfiguration($debug)
    {
        return new Configuration($debug);
    }

    public function testConfigurationDefaults()
    {
        $configuration = $this->getConfiguration(false);
        $processor     = new Processor();
        $config        = $processor->processConfiguration($configuration, array(
            array(
                'endpoints' => array(
                    'api' => null
                )
            )
        ));

        $this->assertEquals(
            array(
                'debug'              => false,
                'cache'              => 'file',
                'file_cache_dir'     => '%kernel.cache_dir%/tq_ext_direct',
                'validate_arguments' => true,
                'strict_validation'  => true,
                'convert_arguments'  => true,
                'convert_result'     => true,
                'endpoints'          => array(
                    'api' => array(
                        'descriptor'    => 'Ext.app.REMOTING_API',
                        'namespace'     => 'Ext.global',
                        'auto_discover' => true,
                        'all_bundles'   => true,
                        'bundles'       => array(),
                        'directories'   => array()
                    )
                )
            ),
            $config
        );
    }

    public function testConfigurationDefaultsInDebug()
    {
        $configuration = $this->getConfiguration(true);
        $processor     = new Processor();
        $config        = $processor->processConfiguration($configuration, array(
            array(
                'endpoints' => array(
                    'api' => null
                )
            )
        ));

        $this->assertEquals(
            array(
                'debug'              => true,
                'cache'              => 'file',
                'file_cache_dir'     => '%kernel.cache_dir%/tq_ext_direct',
                'validate_arguments' => true,
                'strict_validation'  => true,
                'convert_arguments'  => true,
                'convert_result'     => true,
                'endpoints'          => array(
                    'api' => array(
                        'descriptor'    => 'Ext.app.REMOTING_API',
                        'namespace'     => 'Ext.global',
                        'auto_discover' => true,
                        'all_bundles'   => true,
                        'bundles'       => array(),
                        'directories'   => array()
                    )
                )
            ),
            $config
        );
    }
}<commit_msg>added two more tests<commit_after><?php
/**
 * Created by PhpStorm.
 * User: stefan
 * Date: 27.07.15
 * Time: 12:41
 */

namespace TQ\Bundle\ExtDirectBundle\Tests\DependencyInjection;

use Symfony\Component\Config\Definition\Processor;
use TQ\Bundle\ExtDirectBundle\DependencyInjection\Configuration;

/**
 * Class ConfigurationTest
 *
 * @package TQ\Bundle\ExtDirectBundle\Tests\DependencyInjection
 */
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @param bool $debug
     * @return Configuration
     */
    protected function getConfiguration($debug)
    {
        return new Configuration($debug);
    }

    public function testConfigurationDefaults()
    {
        $configuration = $this->getConfiguration(false);
        $processor     = new Processor();
        $config        = $processor->processConfiguration($configuration, array(
            array(
                'endpoints' => array(
                    'api' => null
                )
            )
        ));

        $this->assertEquals(
            array(
                'debug'              => false,
                'cache'              => 'file',
                'file_cache_dir'     => '%kernel.cache_dir%/tq_ext_direct',
                'validate_arguments' => true,
                'strict_validation'  => true,
                'convert_arguments'  => true,
                'convert_result'     => true,
                'endpoints'          => array(
                    'api' => array(
                        'descriptor'    => 'Ext.app.REMOTING_API',
                        'namespace'     => 'Ext.global',
                        'auto_discover' => true,
                        'all_bundles'   => true,
                        'bundles'       => array(),
                        'directories'   => array()
                    )
                )
            ),
            $config
        );
    }

    public function testConfigurationDefaultsInDebug()
    {
        $configuration = $this->getConfiguration(true);
        $processor     = new Processor();
        $config        = $processor->processConfiguration($configuration, array(
            array(
                'endpoints' => array(
                    'api' => null
                )
            )
        ));

        $this->assertEquals(
            array(
                'debug'              => true,
                'cache'              => 'file',
                'file_cache_dir'     => '%kernel.cache_dir%/tq_ext_direct',
                'validate_arguments' => true,
                'strict_validation'  => true,
                'convert_arguments'  => true,
                'convert_result'     => true,
                'endpoints'          => array(
                    'api' => array(
                        'descriptor'    => 'Ext.app.REMOTING_API',
                        'namespace'     => 'Ext.global',
                        'auto_discover' => true,
                        'all_bundles'   => true,
                        'bundles'       => array(),
                        'directories'   => array()
                    )
                )
            ),
            $config
        );
    }

    public function testConfigurationInvalidIfEndpointsIsMissing()
    {
        $configuration = $this->getConfiguration(false);
        $processor     = new Processor();

        $this->setExpectedException(
            'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException',
            'The child node "endpoints" at path "tq_ext_direct" must be configured.'
        );

        $processor->processConfiguration($configuration, array(array()));
    }

    public function testConfigurationInvalidIfEndpointsIsEmpty()
    {
        $configuration = $this->getConfiguration(false);
        $processor     = new Processor();

        $this->setExpectedException(
            'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException',
            'The path "tq_ext_direct.endpoints" should have at least 1 element(s) defined.'
        );

        $processor->processConfiguration($configuration, array(
            array(
                'endpoints' => array()

            )
        ));
    }
}
{'fraction_non_alphanumeric': 0.11227928292222672, 'fraction_numerical': 0.0028305701577031944, 'mean_word_length': 1.3173016864459712, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, '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': '4035379', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1778, 'n_words': 316}