8 use lib "$FindBin::Bin/lib";
10 my $awesome_robot = 0;
15 package MyModule::Plugin::TestActions;
17 use Class::C3::Componentised::ApplyHooks;
19 BEFORE_APPLY { $awesome_robot++; $first = $awesome_robot };
20 BEFORE_APPLY { $awesome_robot++; $first = $awesome_robot };
21 AFTER_APPLY { $awesome_robot++; $last = $awesome_robot };
27 package MyModule::Plugin::TestActionDie;
29 use Class::C3::Componentised::ApplyHooks
30 -before_apply => sub { die 'this component is not applicable (yuk yuk yuk)' };
36 package MyModule::Plugin::TestActionLoadFrew;
38 use Class::C3::Componentised::ApplyHooks;
40 BEFORE_APPLY { $_[0]->load_components('TestActionFrew') };
46 package MyModule::Plugin::TestActionFrew;
52 is( $first, 0, 'first starts at zero' );
53 is( $last, 0, 'last starts at zero' );
55 MyModule->load_components('TestActions');
56 is( $first, 2, 'first gets value of 1 (it runs first)' );
57 is( $last, 3, 'last gets value of 2 (it runs last)' );
59 dies_ok { MyModule->load_components('TestActionDie') } 'die from BEFORE_APPLY works';
61 dies_ok { MyModule->frew } 'fREW is not loaded';
62 MyModule->load_components('TestActionLoadFrew');
63 is( MyModule->frew, 1, 'fREW is loaded' );