<commit_before><?php

namespace Code16\Sharp\Tests\Unit\Utils;

use Code16\Sharp\Tests\SharpTestCase;
use Code16\Sharp\Utils\LinkToEntity;

class LinkToEntityTest extends SharpTestCase
{

    /** @test */
    function we_can_generate_a_link_to_an_entity_list()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_to_an_entity_instance()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/form/my-entity/23" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->setInstanceId(23)->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_search()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity?search=my-search" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->setSearch("my-search")->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_filter()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity?filter_country=France&filter_city=Paris" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))
                ->addFilter("country", "France")
                ->addFilter("city", "Paris")
                ->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_sort()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity?sort=name&dir=desc" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->setSort("name", "desc")->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_tooltip()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity" title="tooltip">test</a>',
            (new LinkToEntity("test", "my-entity"))->setTooltip("tooltip")->render()
        );
    }
}<commit_msg>add missing test for render as url<commit_after><?php

namespace Code16\Sharp\Tests\Unit\Utils;

use Code16\Sharp\Tests\SharpTestCase;
use Code16\Sharp\Utils\LinkToEntity;

class LinkToEntityTest extends SharpTestCase
{

    /** @test */
    function we_can_generate_a_link_to_an_entity_list()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_to_an_entity_instance()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/form/my-entity/23" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->setInstanceId(23)->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_search()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity?search=my-search" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->setSearch("my-search")->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_filter()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity?filter_country=France&filter_city=Paris" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))
                ->addFilter("country", "France")
                ->addFilter("city", "Paris")
                ->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_sort()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity?sort=name&dir=desc" title="">test</a>',
            (new LinkToEntity("test", "my-entity"))->setSort("name", "desc")->render()
        );
    }

    /** @test */
    function we_can_generate_a_link_with_a_tooltip()
    {
        $this->assertEquals(
            '<a href="http://localhost/sharp/list/my-entity" title="tooltip">test</a>',
            (new LinkToEntity("test", "my-entity"))->setTooltip("tooltip")->render()
        );
    }

    /** @test */
    function we_can_generate_an_url()
    {
        $this->assertEquals(
            'http://localhost/sharp/list/my-entity',
            (new LinkToEntity())->setEntityKey( "my-entity")->renderAsUrl()
        );
    }
}
{'fraction_non_alphanumeric': 0.1814697926059513, 'fraction_numerical': 0.004508566275924256, 'mean_word_length': 2.4854673998428907, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 66, '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': '1197757', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1402, 'n_words': 168}