use inlined module hiding in tests
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_action.t
CommitLineData
009b5b23 1use Test::More tests => 6;
2use strict;
3use warnings;
4use Moose::Meta::Class;
5#use Moose::Meta::Attribute;
6use Catalyst::Request;
3453aef8 7use Catalyst::Log;
009b5b23 8
9use_ok('Catalyst::Action');
10
11my $action_1 = Catalyst::Action->new(
12 name => 'foo',
13 code => sub { "DUMMY" },
14 reverse => 'bar/foo',
15 namespace => 'bar',
16 attributes => {
17 Args => [ 1 ],
18 attr2 => [ 2 ],
19 },
20);
21
22my $action_2 = Catalyst::Action->new(
23 name => 'foo',
24 code => sub { "DUMMY" },
25 reverse => 'bar/foo',
26 namespace => 'bar',
27 attributes => {
28 Args => [ 2 ],
29 attr2 => [ 2 ],
30 },
31);
32
33is("${action_1}", $action_1->reverse, 'overload string');
34is($action_1->(), 'DUMMY', 'overload code');
35
36my $anon_meta = Moose::Meta::Class->create_anon_class(
37 attributes => [
38 Moose::Meta::Attribute->new(
39 request => (
40 reader => 'request',
41 required => 1,
7c1c4dc6 42 default => sub { Catalyst::Request->new(_log => Catalyst::Log->new, arguments => [qw/one two/]) },
009b5b23 43 ),
44 ),
45 ],
46 methods => { req => sub { shift->request(@_) } }
47);
48
49my $mock_c = $anon_meta->new_object();
50$mock_c->request;
51
52ok(!$action_1->match($mock_c), 'bad match fails');
53ok($action_2->match($mock_c), 'good match works');
54
55ok($action_2->compare( $action_1 ), 'compare works');