<commit_before><?php
/**
 *
 */

namespace Mvc5\Test\Url;

use Mvc5\Arg;
use Mvc5\Http\Uri\Config as HttpUri;
use Mvc5\Request\Config as Request;
use Mvc5\Test\Test\TestCase;
use Mvc5\Url\Generator;
use Mvc5\Url\Plugin;

class PluginTest
    extends TestCase
{
    /**
     * @var array
     */
    protected $route = [
        'app' => [
            Arg::PATH => '/{controller}'
        ]
    ];

    /**
     *
     */
    function test_current()
    {
        $request = new Request([
            Arg::NAME => 'app',
            Arg::PARAMS => ['controller' => 'foo']
        ]);

        $url = new Plugin($request, new Generator($this->route));

        $this->assertEquals('/foo', $url(''));
        $this->assertEquals('/bar', $url([null, 'controller' => 'bar']));
    }

    /**
     *
     */
    function test_named()
    {
        $url = new Plugin(new Request, new Generator($this->route));

        $this->assertEquals('/foo', $url(['app', 'controller' => 'foo']));
    }

    /**
     *
     */<commit_msg>absolute urls<commit_after><?php
/**
 *
 */

namespace Mvc5\Test\Url;

use Mvc5\Arg;
use Mvc5\Http\Uri\Config as HttpUri;
use Mvc5\Request\Config as Request;
use Mvc5\Test\Test\TestCase;
use Mvc5\Url\Generator;
use Mvc5\Url\Plugin;

class PluginTest
    extends TestCase
{
    /**
     * @var array
     */
    protected $route = [
        'app' => [
            Arg::PATH => '/{controller}'
        ]
    ];

    /**
     *
     */
    function test_absolute_global()
    {
        $request = new Request([
            Arg::NAME => 'app',
            Arg::PARAMS => ['controller' => 'foo'],
            Arg::URI => [
                Arg::SCHEME => 'http',
                Arg::HOST => 'localhost',
                Arg::PORT => '8080'
            ]
        ]);

        $url = new Plugin($request, new Generator($this->route), null, true);

        $this->assertEquals('http://localhost:8080/foo', $url());
    }

    /**
     *
     */
    function test_absolute_local()
    {
        $request = new Request([
            Arg::NAME => 'app',
            Arg::PARAMS => ['controller' => 'foo'],
            Arg::URI => [
                Arg::SCHEME => 'http',
                Arg::HOST => 'localhost',
                Arg::PORT => '8080'
            ]
        ]);

        $url = new Plugin($request, new Generator($this->route));

        $this->assertEquals('http://localhost:8080/foo', $url('app', '', '', ['absolute' => true]));
    }

    /**
     *
     */
    function test_current()
    {
        $request = new Request([
            Arg::NAME => 'app',
            Arg::PARAMS => ['controller' => 'foo']
        ]);

        $url = new Plugin($request, new Generator($this->route));

        $this->assertEquals('/foo', $url(''));
        $this->assertEquals('/bar', $url([null, 'controller' => 'bar']));
    }

    /**
     *
     */
    function test_named()
    {
        $url = new Plugin(new Request, new Generator($this->route));

        $this->assertEquals('/foo', $url(['app', 'controller' => 'foo']));
    }

    /**
     *
     */
{'fraction_non_alphanumeric': 0.19381107491856678, 'fraction_numerical': 0.009771986970684038, 'mean_word_length': 1.7791855203619908, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, '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': '4589063', 'n_tokens_mistral': 985, 'n_tokens_neox': 944, 'n_words': 179}