<commit_before><?php

use Mendo\Translator\Translator;
use Mendo\Http\Request\StringHttpRequest;
use Mendo\Http\Request\Resolver\LanguageSubdirectoryResolver;
use Mendo\Mvc\Router\DefaultRouter;
use Mendo\Router\RequestMatcher;
use Mendo\Router\UrlMaker;
use Mendo\Router\RouterCollection;
use Mendo\Router\RouteData;

class DefaultRouterTest extends PHPUnit_Framework_TestCase
{
    public function testDefaultRouter()
    {
        $routers = new RouterCollection();

        $routers->add(new DefaultRouter(['index', 'users']));

        $requestMatcher = new RequestMatcher($routers);
        $urlMaker = new UrlMaker($routers);

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/profile'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
        $this->assertEquals(['_module' => 'index', '_controller' => 'profile', '_action' => 'index'], $routeData->getParams());
        $this->assertSame('/profile', $urlMaker->makeUrl(new RouteData('default', ['_controller' => 'profile', '_action' => 'index']), 'en'));

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/profile/edit/foo/bar/corge/grault'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
        $this->assertEquals(['_module' => 'index', '_controller' => 'profile', '_action' => 'edit', 'foo' => 'bar', 'corge' => 'grault'], $routeData->getParams());
        $this->assertSame('/profile/edit/foo/bar/corge/grault', $urlMaker->makeUrl(new RouteData('default', ['_controller' => 'profile', '_action' => 'edit', 'foo' => 'bar', 'corge' => 'grault']), 'en'));

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/users/profile'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
        $this->assertEquals(['_module' => 'users', '_controller' => 'profile', '_action' => 'index'], $routeData->getParams());
        $this->assertSame('/users/profile', $urlMaker->makeUrl(new RouteData('default', ['_module' => 'users', '_controller' => 'profile', '_action' => 'index']), 'en'));

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/users/profile/edit/foo/bar/corge/grault'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());<commit_msg>Added trivial update to tests<commit_after><?php

use Mendo\Translator\Translator;
use Mendo\Http\Request\StringHttpRequest;
use Mendo\Http\Request\Resolver\LanguageSubdirectoryResolver;
use Mendo\Mvc\Router\DefaultRouter;
use Mendo\Router\RequestMatcher;
use Mendo\Router\UrlMaker;
use Mendo\Router\RouterCollection;
use Mendo\Router\RouteData;

class DefaultRouterTest extends PHPUnit_Framework_TestCase
{
    public function testDefaultRouter()
    {
        $routers = new RouterCollection();

        $routers->add(new DefaultRouter(['index', 'users']));

        $requestMatcher = new RequestMatcher($routers);
        $urlMaker = new UrlMaker($routers);

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/profile?foo='));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
        $this->assertEquals(['_module' => 'index', '_controller' => 'profile', '_action' => 'index'], $routeData->getParams());
        $this->assertSame('/profile', $urlMaker->makeUrl(new RouteData('default', ['_controller' => 'profile', '_action' => 'index']), 'en'));

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/profile/edit/foo/bar/corge/grault'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
        $this->assertEquals(['_module' => 'index', '_controller' => 'profile', '_action' => 'edit', 'foo' => 'bar', 'corge' => 'grault'], $routeData->getParams());
        $this->assertSame('/profile/edit/foo/bar/corge/grault', $urlMaker->makeUrl(new RouteData('default', ['_controller' => 'profile', '_action' => 'edit', 'foo' => 'bar', 'corge' => 'grault']), 'en'));

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/users/profile'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
        $this->assertEquals(['_module' => 'users', '_controller' => 'profile', '_action' => 'index'], $routeData->getParams());
        $this->assertSame('/users/profile', $urlMaker->makeUrl(new RouteData('default', ['_module' => 'users', '_controller' => 'profile', '_action' => 'index']), 'en'));

        $routeData = $requestMatcher->match(new StringHttpRequest('http://example.com/users/profile/edit/foo/bar/corge/grault'));

        $this->assertInstanceOf('Mendo\Router\RouteData', $routeData);
        $this->assertSame('default', $routeData->getRouteName());
{'fraction_non_alphanumeric': 0.196123584724621, 'fraction_numerical': 0.0, 'mean_word_length': 4.929465301478953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 101, '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': '6786639', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1531, 'n_words': 241}