root/lang/perl/Class-Hookable/trunk/t/30_register/00_register_hook.t @ 4622

Revision 4622, 1.0 kB (checked in by nyarla, 6 years ago)

lang/perl/Class-Hooakble: I made various changes.

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