Acrux

 view release on metacpan or  search on metacpan

t/10-app-min.t  view on Meta::CPAN

#!/usr/bin/perl -w
#########################################################################
#
# Serż Minus (Sergey Lepenkov), <abalama@cpan.org>
#
# Copyright (C) 1998-2026 D&D Corporation
#
# This program is distributed under the terms of the Artistic License 2.0
#
#########################################################################
use strict;
use utf8;
use Test::More;

use_ok qw/Acme::Crux/;

# Direct
{
    my $app = new_ok( 'Acme::Crux' => [(
        project => 'MyApp',
        preload => [], # Disable plugins
    )] );
    ok(!$app->error, 'No errors') or diag($app->error);
}

1;

package MyApp;

use parent 'Acme::Crux';

__PACKAGE__->register_handler; # default

__PACKAGE__->register_handler(
    handler     => "foo",
    aliases     => "one, two",
    description => "Foo handler",
    params => {
        param1 => "test",
        param2 => 123,
    },
    code => sub {
### CODE:
    my ($self, $meta, @args) = @_;

    print Acrux::Util::dumper({
        name => 'foo',
        meta => $meta,
        args => \@args,
    });

    return 1;
});

__PACKAGE__->register_handler(
    handler     => "bar",
    aliases     => "aaa, bbb",
    description => "Bar handler",
    code => sub {
### CODE:
    my ($self, $meta, @args) = @_;

    print Acrux::Util::dumper({
        name => 'bar',
        meta => $meta,
        args => \@args,
    });

    return 1;
});

1;



( run in 0.835 second using v1.01-cache-2.11-cpan-97f6503c9c8 )