root/lang/perl/Class-Hookable/trunk/t/02_register/01_register_method.t @ 4056

Revision 4056, 1.0 kB (checked in by nyarla, 5 years ago)

lang/perl/Class-Hookable: The dummy class was made a module.

Line 
1#!perl -T
2
3use strict;
4use warnings;
5
6use Test::More tests => 6;
7use Class::Hookable;
8use lib 't';
9use DummyClass;
10
11my $hook    = Class::Hookable->new;
12my $plugin  = Plugin->new;
13
14$hook->register_method(
15    $plugin,
16    'foo.bar' => $plugin->can('foo'),
17);
18
19is_deeply(
20    $hook->hookable_all_methods->{'foo.bar'},
21    {
22        plugin      => $plugin,
23        function    => $plugin->can('foo'),
24    },
25);
26
27$hook->hookable_set_filter(
28    'register_method' => sub {
29        my ( $self, $filter, $method, $action ) = @_;
30        isa_ok( $self, 'Class::Hookable' );
31        is( $filter, 'register_method' );
32        is( $method, 'bar.baz' );
33        is_deeply(
34            $action,
35            {
36                plugin      => $plugin,
37                function    => $plugin->can('bar'),
38            },
39        );
40        return 0;
41    },
42);
43
44$hook->register_method(
45    $plugin,
46    'bar.baz' => $plugin->can('bar'),
47);
48
49is(
50    $hook->hookable_all_methods->{'bar.baz'},
51    undef,
52);
Note: See TracBrowser for help on using the browser.