Stop the request needing the context, just pass in the logger instead
[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;
7
8use_ok('Catalyst::Action');
9
10my $action_1 = Catalyst::Action->new(
11 name => 'foo',
12 code => sub { "DUMMY" },
13 reverse => 'bar/foo',
14 namespace => 'bar',
15 attributes => {
16 Args => [ 1 ],
17 attr2 => [ 2 ],
18 },
19);
20
21my $action_2 = Catalyst::Action->new(
22 name => 'foo',
23 code => sub { "DUMMY" },
24 reverse => 'bar/foo',
25 namespace => 'bar',
26 attributes => {
27 Args => [ 2 ],
28 attr2 => [ 2 ],
29 },
30);
31
32is("${action_1}", $action_1->reverse, 'overload string');
33is($action_1->(), 'DUMMY', 'overload code');
34
35my $anon_meta = Moose::Meta::Class->create_anon_class(
36 attributes => [
37 Moose::Meta::Attribute->new(
38 request => (
39 reader => 'request',
40 required => 1,
7c1c4dc6 41 default => sub { Catalyst::Request->new(_log => Catalyst::Log->new, arguments => [qw/one two/]) },
009b5b23 42 ),
43 ),
44 ],
45 methods => { req => sub { shift->request(@_) } }
46);
47
48my $mock_c = $anon_meta->new_object();
49$mock_c->request;
50
51ok(!$action_1->match($mock_c), 'bad match fails');
52ok($action_2->match($mock_c), 'good match works');
53
54ok($action_2->compare( $action_1 ), 'compare works');