76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* @package Plumrocket_CookieConsent
|
|
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
|
|
* @license https://plumrocket.com/license End-user License Agreement
|
|
*/
|
|
|
|
namespace Plumrocket\CookieConsent\Test\Unit\Model\Cookie;
|
|
|
|
use Plumrocket\CookieConsent\Model\Cookie\ParentDomain;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ParentDomainTest extends TestCase
|
|
{
|
|
/**
|
|
* @var \Plumrocket\CookieConsent\Model\Cookie\ParentDomain
|
|
*/
|
|
private $parentDomain;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->parentDomain = new ParentDomain();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider getDomain
|
|
*
|
|
* @param string $domain
|
|
* @param string $expectedDomain
|
|
* @return void
|
|
*/
|
|
public function testResolve(string $domain, string $expectedDomain): void
|
|
{
|
|
$parentDomain = $this->parentDomain->resolve($domain);
|
|
self::assertSame($expectedDomain, $parentDomain);
|
|
}
|
|
|
|
public function getDomain()
|
|
{
|
|
yield [
|
|
'domain' => 'www.plumrocket.com',
|
|
'parentDomain' => '.plumrocket.com'
|
|
];
|
|
|
|
yield [
|
|
'domain' => 'blog.magento.com',
|
|
'parentDomain' => '.magento.com'
|
|
];
|
|
|
|
yield [
|
|
'domain' => 'magento.com',
|
|
'parentDomain' => ''
|
|
];
|
|
|
|
yield [
|
|
'domain' => 'magento.te.ua',
|
|
'parentDomain' => ''
|
|
];
|
|
|
|
yield [
|
|
'domain' => 'www.test.magento.com',
|
|
'parentDomain' => '.test.magento.com'
|
|
];
|
|
|
|
yield [
|
|
'domain' => 'www.magento.te.ua',
|
|
'parentDomain' => '.magento.te.ua'
|
|
];
|
|
|
|
yield [
|
|
'domain' => 'www.magento.xxx',
|
|
'parentDomain' => '.magento.xxx'
|
|
];
|
|
}
|
|
}
|