Commit | Line | Data |
5084877e |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | |
5 | # FIXME |
6 | # the exact return value of get_all_component_services |
7 | # needs to be reviewed and discussed |
8 | # |
9 | # See also note in Catalyst::IOC::Container |
10 | # |
11 | # the temporary solution is |
12 | # { |
13 | # class_name => { |
14 | # type => (model|controller|view), |
15 | # service => Catalyst::IOC::*Injection instance, # most likely BlockInjection |
16 | # backcompat_service => Catalyst::IOC::ConstructorInjection instance or undef, |
17 | # }, |
18 | # class_name => ... |
19 | # } |
20 | |
21 | use Test::More; |
22 | use Test::Moose; |
23 | use FindBin '$Bin'; |
24 | use lib "$Bin/../lib"; |
25 | use TestAppGetAllComponentServices; |
26 | |
27 | ok(my $c = TestAppGetAllComponentServices->container, 'get the container'); |
28 | can_ok($c, 'get_all_component_services'); |
29 | ok(my $comp_services = $c->get_all_component_services, 'component services are fetched'); |
30 | |
31 | my $expected = { |
32 | 'TestAppGetAllComponentServices::Controller::Root' => { |
33 | type => 'controller', |
34 | service_isa => 'Catalyst::IOC::BlockInjection', |
35 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
36 | }, |
37 | 'TestAppGetAllComponentServices::Model::Foo' => { |
38 | type => 'model', |
39 | service_isa => 'Catalyst::IOC::BlockInjection', |
40 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
41 | }, |
42 | 'TestAppGetAllComponentServices::Model::Bar' => { |
43 | type => 'model', |
44 | service_isa => 'Catalyst::IOC::BlockInjection', |
45 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
46 | }, |
47 | 'TestAppGetAllComponentServices::Model::Baz' => { |
48 | type => 'model', |
49 | service_isa => 'Catalyst::IOC::BlockInjection', |
50 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
51 | }, |
52 | 'TestAppGetAllComponentServices::View::Wibble' => { |
53 | type => 'view', |
54 | service_isa => 'Catalyst::IOC::BlockInjection', |
55 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
56 | }, |
57 | 'TestAppGetAllComponentServices::View::Wobble' => { |
58 | type => 'view', |
59 | service_isa => 'Catalyst::IOC::BlockInjection', |
60 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
61 | }, |
62 | 'TestAppGetAllComponentServices::View::Wubble' => { |
63 | type => 'view', |
64 | service_isa => 'Catalyst::IOC::BlockInjection', |
65 | bcpt_service_isa => 'Catalyst::IOC::ConstructorInjection', |
66 | }, |
67 | }; |
68 | |
69 | while (my ($class, $info) = each %$expected) { |
70 | ok(exists $comp_services->{$class}, "class $class exists in the returned hash"); |
71 | my $received_info = $comp_services->{$class}; |
72 | is($received_info->{type}, $info->{type}, 'type is ok'); |
73 | isa_ok($received_info->{service}, $info->{service_isa}, 'service'); |
74 | isa_ok($received_info->{backcompat_service}, $info->{bcpt_service_isa}, 'backcompat_service'); |
75 | } |
76 | |
77 | done_testing; |