<?php

namespace AutoAdmin\Bundle\Tests\Unit\Content\Service;

use AutoAdmin\Bundle\Content\Service\ObfuscatorService;
use PHPUnit\Framework\TestCase;

class ObfuscatorServiceTest extends TestCase
{
    /**
     * @dataProvider provideObfuscateData
     */
    public function testObfuscate($expectedResult, $input)
    {
        $this->assertEquals($expectedResult, ObfuscatorService::obfuscate($input));
    }

    public function provideObfuscateData()
    {
        return [
            [
                '',
                '',
            ],
            [
                'test',
                'test',
            ],
            [
                'tést',
                'tést',
            ],
            [
                'test & test',
                'test & test',
            ],
            [
                '<p>test</p>',
                '<p>test</p>',
            ],
            [
                '<p>tést</p>',
                '<p>tést</p>',
            ],
            [
                '<p>test &amp; test</p>',
                '<p>test & test</p>',
            ],
            [
                '<p>test<a href="/test">test</a>test</p>',
                '<p>test<a href="/test">test</a>test</p>',
            ],
            [
                '<p>test<a class="obfuscated-link" href="#" data-href="/test">test</a>test</p>',
                '<p>test<a class="obfuscated-link" href="/test">test</a>test</p>',
            ],
            [
                '<p>test<a class="obfuscated-link" href="#" target="_blank" data-href="/test">test</a>test</p>',
                '<p>test<a class="obfuscated-link" href="/test" target="_blank">test</a>test</p>',
            ],
            [
                '<p>test<a class="obfuscated-link test" href="#" target="_blank" data-href="/test">test</a>test</p>',
                '<p>test<a class="obfuscated-link test" href="/test" target="_blank">test</a>test</p>',
            ],
            [
                '<p>test<a class="obfuscated-link test" href="#" target="_blank" data-href="/test">test</a>test<a class="obfuscated-link test" href="#" data-href="/test">test</a></p>',
                '<p>test<a class="obfuscated-link test" href="/test" target="_blank">test</a>test<a class="obfuscated-link test" href="/test">test</a></p>',
            ],
        ];
    }
}
