#!/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::Plugins::Promotions;

use cPstrict;
use Test::Cpanel::Policy;

use Test2::V0;
use Test2::Plugin::NoWarnings;

use Test::MockModule;

use Cpanel::Plugins::Promotions ();

use base qw(Test::Class);

my $mock = Test::MockModule->new('Cpanel::LoadModule');

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

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

sub test_new : Tests(4) {

    ok( dies { Cpanel::Plugins::Promotions->new() },                          "new dies when no plugin defined." );
    ok( dies { Cpanel::Plugins::Promotions->new( { plugin => 'invalid' } ) }, "new dies when desired plugin does not exist." );

    $mock->redefine( 'load_perl_module' => sub { return 1 } );
    my $obj;
    ok( lives { $obj = Cpanel::Plugins::Promotions->new( { plugin => 'valid' } ) }, "new lives when a valid plugin is desired." );
    ok( $obj->isa('Cpanel::Plugins::Promotions::valid'),                            "new returns the correct object type." );

    return 1;
}

package Cpanel::Plugins::Promotions::valid;

sub new { return bless {}, shift }

1;
