<commit_before><?php


namespace Brera;


use Brera\Http\HttpUrl;

class PageKeyGeneratorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var PageKeyGenerator
     */
    private $pageKeyGenerator;

    protected function setUp()
    {
        $this->pageKeyGenerator = new PageKeyGenerator();
    }

    /**
     * @test
     */
    public function itShouldReturnStrings()
    {
        $env = new VersionedEnvironment(DataVersion::fromVersionString('1'));
        $url = HttpUrl::fromString('http://example.com/product.html');

        $this->assertInternalType(
            'string',
            $this->pageKeyGenerator->getKeyForSnippet($url, $env)
        );

        $this->assertInternalType(
            'string',
            $this->pageKeyGenerator->getKeyForSnippetList($url, $env)
        );
    }

    /**
     * @test
     */
    public function itShouldGenerateAKeyForSnippetFromAnEnvironmentAndUrl()
    {
        $env = new VersionedEnvironment(DataVersion::fromVersionString('1'));
        $url = HttpUrl::fromString('http://example.com/product.html');

        $this->assertEquals(
            '_product_html_1',
            $this->pageKeyGenerator->getKeyForSnippet($url, $env)
        );
    }

    /**
     * @test
     */
    public function itShouldGenerateAKeyForSnippetListFromAnEnvironmentAndUrl()
    {
        $env = new VersionedEnvironment(DataVersion::fromVersionString('1'));
        $url = HttpUrl::fromString('http://example.com/product.html');

        $this->assertEquals(
            '_product_html_1_l',
            $this->pageKeyGenerator->getKeyForSnippetList($url, $env)
        );
    }
}
<commit_msg>Issue #26: remove dependency in unit test. VersionedEnvironment can be complex, too complex for a unit test<commit_after><?php


namespace Brera;


use Brera\Http\HttpUrl;

class PageKeyGeneratorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var PageKeyGenerator
     */
    private $pageKeyGenerator;

    protected function setUp()
    {
        $this->pageKeyGenerator = new PageKeyGenerator();
    }

    /**
     * @test
     */
    public function itShouldReturnStrings()
    {
        $env = $this->getMock(VersionedEnvironment::class);
        $env->expects($this->any())->method('getVersion')->willReturn('1');
        
        $url = HttpUrl::fromString('http://example.com/product.html');

        $this->assertInternalType(
            'string',
            $this->pageKeyGenerator->getKeyForSnippet($url, $env)
        );

        $this->assertInternalType(
            'string',
            $this->pageKeyGenerator->getKeyForSnippetList($url, $env)
        );
    }

    /**
     * @test
     */
    public function itShouldGenerateAKeyForSnippetFromAnEnvironmentAndUrl()
    {
        $env = $this->getMock(VersionedEnvironment::class);
        $env->expects($this->any())->method('getVersion')->willReturn('1');

        $url = HttpUrl::fromString('http://example.com/product.html');

        $this->assertEquals(
            '_product_html_1',
            $this->pageKeyGenerator->getKeyForSnippet($url, $env)
        );
    }

    /**
     * @test
     */
    public function itShouldGenerateAKeyForSnippetListFromAnEnvironmentAndUrl()
    {
        $env = $this->getMock(VersionedEnvironment::class);
        $env->expects($this->any())->method('getVersion')->willReturn('1');

        $url = HttpUrl::fromString('http://example.com/product.html');

        $this->assertEquals(
            '_product_html_1_l',
            $this->pageKeyGenerator->getKeyForSnippetList($url, $env)
        );
    }
}

{'fraction_non_alphanumeric': 0.1417015341701534, 'fraction_numerical': 0.0033472803347280333, 'mean_word_length': 2.5504950495049505, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '1549808', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1029, 'n_words': 140}