<commit_before><?php
/**
 * TjoAnnotationRouter library (https://github.com/tomphp/TjoAnnotationRouter)
 *
 * @link https://github.com/tomphp/TjoAnnotationRouter for the canonical source repository
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
 */

namespace TjoAnnotationRouter\Config;

/**
 * Tests for {@see Merger}.
 *
 * @author <NAME> <<EMAIL>>
 */
class MergerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * The instance we are going to test.
     *
     * @var Merger
     */
    protected $merger;

    /**
     * Prepare an instance to test.
     */
    protected function setUp()
    {
        $this->merger = new Merger();
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
     */
    public function testMerge2SeperateRoutes()
    {
        $config = array(
            'route1' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-one',
                ),
            ),
        );

        $newConfig = array(
            'route2' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-two',
                ),
            ),
        );

        $expected = array(
            'route1' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-one',
                ),
            ),
            'route2' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-two',
                ),
            ),
        );

        $this->merger->merge($newConfig, $config);

        $this->assertEquals($expected, $config);
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
     */
    public function testMergeDoesntOverwriteExisting()
    {
        $config = array(
            'route1' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-one',
                ),
            ),
        );

        $newConfig = array(
            'route1' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/route-xxx',
                ),
            ),
        );

        $expected = $config;

        $this->merger->merge($newConfig, $config);

        $this->assertEquals($expected, $config);
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
     */
    public function testMergeCreatesBranch()
    {
        $config = array();

        $newConfig = array(
            'new-branch' => array(
                'child_routes' => array(
                    'new-route' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/route-xxx',
                        ),
                    ),
                ),
            )
        );

        $expected = array(
            'new-branch' => array(
                'type' => 'Literal',
                'may_terminate' => false,
                'options' => array(
                    'route' => '/new-branch',
                ),
                'child_routes' => array(
                    'new-route' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/route-xxx',
                        ),
                    ),
                ),
            )
        );

        $this->merger->merge($newConfig, $config);

        $this->assertEquals($expected, $config);
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge<commit_msg>Fixed MergeTest<commit_after><?php
/**
 * TjoAnnotationRouter library (https://github.com/tomphp/TjoAnnotationRouter)
 *
 * @link https://github.com/tomphp/TjoAnnotationRouter for the canonical source repository
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
 */

namespace TjoAnnotationRouter\Config;

/**
 * Tests for {@see Merger}.
 *
 * @author <NAME> <<EMAIL>>
 */
class MergerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * The instance we are going to test.
     *
     * @var Merger
     */
    protected $merger;

    /**
     * Prepare an instance to test.
     */
    protected function setUp()
    {
        $this->merger = new Merger();
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
     */
    public function testMerge2SeperateRoutes()
    {
        $config = array(
            'route1' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-one',
                ),
            ),
        );

        $newConfig = array(
            'route2' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-two',
                ),
            ),
        );

        $expected = array(
            'route1' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-one',
                ),
            ),
            'route2' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-two',
                ),
            ),
        );

        $this->merger->merge($newConfig, $config);

        $this->assertEquals($expected, $config);
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
     */
    public function testMergeDoesntOverwriteExisting()
    {
        $config = array(
            'route1' => array(
                'type' => 'Literal',
                'options' => array(
                    'route' => '/route-one',
                ),
            ),
        );

        $newConfig = array(
            'route1' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/route-xxx',
                ),
            ),
        );

        $expected = $config;

        $this->merger->merge($newConfig, $config);

        $this->assertEquals($expected, $config);
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
     */
    public function testMergeCreatesBranch()
    {
        $config = array();

        $newConfig = array(
            'new-branch' => array(
                'child_routes' => array(
                    'new-route' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/route-xxx',
                        ),
                    ),
                ),
            )
        );

        $expected = array(
            'new-branch' => array(
                'type' => 'Literal',
                'may_terminate' => true,
                'options' => array(
                    'route' => '/new-branch',
                ),
                'child_routes' => array(
                    'new-route' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/route-xxx',
                        ),
                    ),
                ),
            )
        );

        $this->merger->merge($newConfig, $config);

        $this->assertEquals($expected, $config);
    }

    /**
     * @covers TjoAnnotationRouter\Config\Merger::merge
{'fraction_non_alphanumeric': 0.14588611814908656, 'fraction_numerical': 0.001866915588745166, 'mean_word_length': 1.1404109589041096, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 109, 'https://': 4, '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': '4734848', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1935, 'n_words': 358}