#!/usr/local/cpanel/3rdparty/bin/perl -w
#                                      Copyright 2025 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use cPstrict;

use Test2::V0;
use Test2::Tools::Explain;
use Test2::Plugin::NoWarnings;
use Test2::Tools::Subtest;
use Test2::Tools::Exception;

use Test::MockModule qw/strict/;

use Test::Cpanel::Policy testing => 'Cpanel::Plugins::Components::Rules::DnsOnly';

use Cpanel::Plugins::Components::Rules::DnsOnly;

my $mock_is_dnsonly = 0;
my $mock            = Test::MockModule->new("Cpanel::Server::Type");
$mock->redefine(
    is_dnsonly => sub {
        return $mock_is_dnsonly;
    }
);

subtest 'Check if the rule for DNS only licensing when the server is NOT licensed as DNS only.' => sub {
    my $mock_is_dnsonly = 0;
    my $got             = Cpanel::Plugins::Components::Rules::DnsOnly->new()->is_allowed();
    is $got, !!0, "got false value when the server is not licensed as DNS only.";
};

subtest 'Check if the rule for DNS only licensing when the server is  licensed as DNS only.' => sub {
    my $mock_is_dnsonly = 1;
    my $got             = Cpanel::Plugins::Components::Rules::DnsOnly->new()->is_allowed();
    is $got, !!0, "got false value when the server is not licensed as DNS only.";
};

done_testing;
