HEX
Server: Apache
System: Linux webd003.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: slyfwmm (169339)
PHP: 8.1.34
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/slyfwmm/dallavitae/OLD_WP/wp-content/plugins/cloudflare/src/Test/WordPress/UtilsTest.php
<?php

namespace CF\Test\WordPress;

use CF\WordPress\Utils;

class UtilsTest extends \PHPUnit\Framework\TestCase
{
    public function setup(): void
    {
    }

    public function testStrEndsWith()
    {
        $this->assertFalse(Utils::strEndsWith('abcdef', 'ab'));
        $this->assertFalse(Utils::strEndsWith('abcdef', 'cd'));
        $this->assertTrue(Utils::strEndsWith('abcdef', 'ef'));
        $this->assertTrue(Utils::strEndsWith('abcdef', 'abcdef'));
        $this->assertFalse(Utils::strEndsWith('abcdef', ''));
        $this->assertFalse(Utils::strEndsWith('', 'abcdef'));
        $this->assertFalse(Utils::strEndsWith('', ''));
    }

    public function testIsSubdomainOf()
    {
        $this->assertTrue(Utils::isSubdomainOf('sub.domain.com', 'domain.com'));
        $this->assertTrue(Utils::isSubdomainOf('non.sub.domain.com', 'domain.com'));
        $this->assertFalse(Utils::isSubdomainOf('sub.domain.com', 'cooldomain.com'));
        $this->assertFalse(Utils::isSubdomainOf('', 'domain.com'));
        $this->assertFalse(Utils::isSubdomainOf('sub.domain.com', ''));
        $this->assertFalse(Utils::isSubdomainOf('', ''));
        $this->assertFalse(Utils::isSubdomainOf('domain.com', 'domain.com'));
        $this->assertFalse(Utils::isSubdomainOf('testdomain.com', 'domain.com'));
    }

    public function testGetRegistrableDomain()
    {
        $this->assertEquals('domain.com', Utils::getRegistrableDomain('sub.domain.com'));
        $this->assertEquals('domain.co.uk', Utils::getRegistrableDomain('sub.domain.co.uk'));
        $this->assertEquals('sub2.domain.com', Utils::getRegistrableDomain('sub1.sub2.domain.com'));
    }
}