#!/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

package t::medium::Cpanel::Template::Plugin::Sitejet;

use cPstrict;

use Test2::V0;

use Test::Exception;
use Test::MockFile;
use Test::MockObject;

use Test::Cpanel::Policy;

use parent qw(
  Cpanel::TestObj
);


use Cpanel::Template::Plugin::Sitejet ();

__PACKAGE__->new()->runtests() if !caller;

#----------------------------------------------------------------------

#e.g., num_method_tests()
sub new ( $class, @args ) {
    my $self = $class->SUPER::new(@args);
    return $self;
}

#e.g., set environs before running tests
sub runtests ( $self, @args ) {
    return $self->SUPER::runtests(@args);
}

sub test_get_is_beta : Tests(2) ($self) {
    my ( $connector, $domain );

    my $sitejet_config_yaml = '/var/cpanel/plugins/sitejet/config.yaml';
    my $contents            = <<~_YAML_;
        is-beta:
        - company-id:
          - 7
          - 4393
    _YAML_
    my $mock_file    = Test::MockFile->file( $sitejet_config_yaml, $contents );
    my $company_id   = 7;
    my $mock_company = Test::MockModule->new("Cpanel::License::CompanyID");
    $mock_company->redefine(
        get_company_id => sub {
            return $company_id;
        }
    );

    my $result = Cpanel::Template::Plugin::Sitejet::get_is_beta();
    is( $result, 1, "get_is_beta returns 1 when the server has company_id '$company_id'" ) or diag explain $result;

    $company_id = 777;
    $result     = Cpanel::Template::Plugin::Sitejet::get_is_beta();
    is( $result, 0, "_get_is_beta returns 0 when the server has company_id '$company_id'" ) or diag explain $result;

}

1;
