<commit_before><?php

namespace RcRouter\Tests\Utilities;

use PHPUnit\Framework\TestCase;
use RcRouter\Utilities\Parser;

/**
 * Class ParserTest
 *
 * @package RcRouter\Tests\Utilities
 */
class ParserTest extends TestCase
{
    /**
     * Tests the simple route matching of the parser.
     */
    public function testSimpleRoutes()
    {
        $parser = new Parser('/');
        $route  = $parser->parse('/', function () {
            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests the query string matching on simple routes
     */
    public function testQueryStringRoute()
    {
        $parser = new Parser('/');
        $route  = $parser->parse('/?test=this-test-is-awesome', function () {
            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests integer regex parsing
     */
    public function testIntegerRegexRoute()
    {
        $parser = new Parser('/1/32');
        $route  = $parser->parse('/{id:i}/{post:i}', function ($mapped) {
            $this->assertEquals($mapped['int']['id'], 1);
            $this->assertEquals($mapped['int']['post'], 32);

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests string regex parsing
     */
    public function testStringRegexRoute()
    {
        $parser = new Parser('/help/me');
        $route  = $parser->parse('/{first}/{second}', function ($mapped) {
            $this->assertEquals($mapped['string']['first'], 'help');
            $this->assertEquals($mapped['string']['second'], 'me');

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests mixed regex parsing
     */
    public function testMixedRegexRoute()
    {
        $parser = new Parser('/1/32/best-post-ever');
        $route  = $parser->parse('/{id:i}/{post:i}/{postName}', function ($mapped) {
            $this->assertEquals($mapped['int']['id'], 1);
            $this->assertEquals($mapped['int']['post'], 32);
            $this->assertEquals($mapped['string']['postName'], 'best-post-ever');

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests integer regex parsing with query string
     */
    public function testIntegerRegexRouteWithQueryString()
    {
        $parser = new Parser('/1/32?test=this-is-a-test');
        $route  = $parser->parse('/{id:i}/{post:i}', function ($mapped) {
            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests string regex parsing with query string
     */
    public function testStringRegexRouteWithQueryString()
    {
        $parser = new Parser('/1/32?test=this-is-a-test');
        $route  = $parser->parse('/{id}/{post}', function ($mapped) {
            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests mixed regex parsing
     */
    public function testMixedRegexRouteWithQueryString()
    {
        $parser = new Parser('/1/32/best-post-ever?test=this-is-a-test');
        $route  = $parser->parse('/{id:i}/{post:i}/{postName}', function ($mapped) {
            return true;
        });

        $this->assertEquals($route, true);
    }
}<commit_msg>Added Additional Assertions For Parser Test<commit_after><?php

namespace RcRouter\Tests\Utilities;

use PHPUnit\Framework\TestCase;
use RcRouter\Utilities\Parser;

/**
 * Class ParserTest
 *
 * @package RcRouter\Tests\Utilities
 */
class ParserTest extends TestCase
{
    /**
     * Tests the simple route matching of the parser.
     */
    public function testSimpleRoutes()
    {
        $parser = new Parser('/');
        $route  = $parser->parse('/', function () {
            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests the query string matching on simple routes
     */
    public function testQueryStringRoute()
    {
        $parser = new Parser('/');
        $route  = $parser->parse('/?test=this-test-is-awesome', function () {
            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests integer regex parsing
     */
    public function testIntegerRegexRoute()
    {
        $parser = new Parser('/1/32');
        $route  = $parser->parse('/{id:i}/{post:i}', function ($mapped) {
            $this->assertEquals($mapped['int']['id'], 1);
            $this->assertEquals($mapped['int']['post'], 32);

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests string regex parsing
     */
    public function testStringRegexRoute()
    {
        $parser = new Parser('/help/me');
        $route  = $parser->parse('/{first}/{second}', function ($mapped) {
            $this->assertEquals($mapped['string']['first'], 'help');
            $this->assertEquals($mapped['string']['second'], 'me');

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests mixed regex parsing
     */
    public function testMixedRegexRoute()
    {
        $parser = new Parser('/1/32/best-post-ever');
        $route  = $parser->parse('/{id:i}/{post:i}/{postName}', function ($mapped) {
            $this->assertEquals($mapped['int']['id'], 1);
            $this->assertEquals($mapped['int']['post'], 32);
            $this->assertEquals($mapped['string']['postName'], 'best-post-ever');

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests integer regex parsing with query string
     */
    public function testIntegerRegexRouteWithQueryString()
    {
        $parser = new Parser('/1/32?test=this-is-a-test');
        $route  = $parser->parse('/{id:i}/{post:i}', function ($mapped) {
            $this->assertEquals($mapped['int']['id'], 1);
            $this->assertEquals($mapped['int']['post'], 32);

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests string regex parsing with query string
     */
    public function testStringRegexRouteWithQueryString()
    {
        $parser = new Parser('/robert/developer?test=this-is-a-test');
        $route  = $parser->parse('/{name}/{position}', function ($mapped) {
            $this->assertEquals($mapped['string']['name'], 'robert');
            $this->assertEquals($mapped['string']['position'], 'developer');

            return true;
        });

        $this->assertEquals($route, true);
    }

    /**
     * Tests mixed regex parsing
     */
    public function testMixedRegexRouteWithQueryString()
    {
        $parser = new Parser('/1/32/best-post-ever?test=this-is-a-test');
        $route  = $parser->parse('/{id:i}/{post:i}/{postName}', function ($mapped) {
            $this->assertEquals($mapped['int']['id'], 1);
            $this->assertEquals($mapped['int']['post'], 32);
            $this->assertEquals($mapped['string']['postName'], 'best-post-ever');

            return true;
        });

        $this->assertEquals($route, true);
    }
}
{'fraction_non_alphanumeric': 0.1779399382542801, 'fraction_numerical': 0.006314903171484704, 'mean_word_length': 2.2395454545454547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '6121726', 'n_tokens_mistral': 2092, 'n_tokens_neox': 2030, 'n_words': 389}