X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTestAppCustomContainer%2FNoSugarContainer.pm;h=d345aad0925d47cf183bfbb8a45a3ce935e05598;hb=96c9f5d4c9cebf815970a5ea94b90ad693ebaa93;hp=55fdd8364cec8900934792a770df0e3fcb97629e;hpb=a0475a83a743321bb9cfac486792b9a9322c2743;p=catagits%2FCatalyst-Runtime.git diff --git a/t/lib/TestAppCustomContainer/NoSugarContainer.pm b/t/lib/TestAppCustomContainer/NoSugarContainer.pm index 55fdd83..d345aad 100644 --- a/t/lib/TestAppCustomContainer/NoSugarContainer.pm +++ b/t/lib/TestAppCustomContainer/NoSugarContainer.pm @@ -8,107 +8,79 @@ extends 'Catalyst::IOC::Container'; sub BUILD { my $self = shift; - $self->get_sub_container('component')->add_service( - # Catalyst::IOC::ConstructorInjection gives the constructor the wrong - # parameters - Bread::Board::ConstructorInjection->new( - name => 'model_Bar', + $self->get_sub_container('model')->add_service( + Catalyst::IOC::ConstructorInjection->new( + name => 'SingletonLifeCycle', lifecycle => 'Singleton', - class => 'TestAppCustomContainer::Model::Bar', - constructor_name => 'new', + class => 'TestAppCustomContainer::Model::SingletonLifeCycle', + catalyst_component_name => 'TestAppCustomContainer::Model::SingletonLifeCycle', dependencies => { - application_name => depends_on( '/application_name' ), - config => depends_on( '/config' ), - foo => Bread::Board::Dependency->new( - service_name => 'foo', - service_path => '/model/Foo', - - # FIXME - obviously this is a mistake - # what to do with ctx here? - # I have no way to get $s here, do I? - service_params => { - ctx => +{}, - accept_context_args => [ +{} ], - }, - ), - }, - ) - ); - $self->get_sub_container('model')->add_service( - Catalyst::IOC::BlockInjection->new( - name => 'Bar', - lifecycle => 'Singleton', - dependencies => [ - depends_on( '/component/model_Bar' ), - ], - block => sub { - shift->param('model_Bar'); + catalyst_application => depends_on( '/catalyst_application' ), }, ) ); - # FIXME - this is to avoid the default service to be added - # if that happened, the app would die - $self->get_sub_container('component')->add_service( - service model_Baz => 'TestAppCustomContainer::Model::Baz', - ); $self->get_sub_container('model')->add_service( - # FIXME - i think it should be a ConstructorInjection - # but only BlockInjection gets ctx parameter - Catalyst::IOC::BlockInjection->new( - name => 'Baz', + Catalyst::IOC::ConstructorInjection->new( + name => 'RequestLifeCycle', lifecycle => '+Catalyst::IOC::LifeCycle::Request', - dependencies => [ - Bread::Board::Dependency->new( - service_name => 'foo', - service_path => 'Foo', - - # FIXME - same as above - service_params => { - ctx => +{}, - accept_context_args => [ +{} ], - }, - ), - ], - block => sub { - TestAppCustomContainer::Model::Baz->new(foo => shift->param('foo')); + class => 'TestAppCustomContainer::Model::RequestLifeCycle', + catalyst_component_name => 'TestAppCustomContainer::Model::RequestLifeCycle', + dependencies => { + catalyst_application => depends_on( '/catalyst_application' ), }, ) ); - $self->get_sub_container('model')->add_service( - Catalyst::IOC::BlockInjection->new( - name => 'Quux', - lifecycle => 'Singleton', - dependencies => [ - depends_on( '/component/model_Quux' ), - ], - block => sub { shift->param('model_Bar') }, - ) - ); +# $self->get_sub_container('model')->add_service( +# Catalyst::IOC::ConstructorInjection->new( +# name => 'DependsOnDefaultSetup', +# class => 'TestAppCustomContainer::Model::DependsOnDefaultSetup', +# catalyst_component_name => 'TestAppCustomContainer::Model::DependsOnDefaultSetup', +# dependencies => { +# catalyst_application => depends_on( '/catalyst_application' ), +# # FIXME - this is what is blowing up everything: +# # DefaultSetup needs the context. It's not getting it here! +# foo => depends_on('/model/DefaultSetup'), +# }, +# ) +# ); - $self->get_sub_container('component')->add_service( - Catalyst::IOC::ConstructorInjection->new( - name => 'model_Fnar', - lifecycle => 'Singleton', - class => 'TestAppCustomContainer::External::Class', - dependencies => [ - depends_on( '/application_name' ), - depends_on( '/config' ), - ], - ) - ); - $self->get_sub_container('model')->add_service( - Catalyst::IOC::BlockInjection->new( - name => 'model_Fnar', - lifecycle => 'Singleton', - dependencies => [ - depends_on( '/config' ), - depends_on( '/component/model_Fnar' ), - ], - block => sub { shift->param('model_Fnar') }, - ) - ); +# Broken deps!?! +# $self->get_sub_container('model')->add_service( +# Catalyst::IOC::BlockInjection->new( +# name => 'Quux', +# lifecycle => 'Singleton', +# dependencies => [ +# depends_on( '/component/model_Quux' ), +# ], +# block => sub { shift->param('model_Bar') }, +# ) +# ); + +# my $fnar_config = $self->resolve(service => 'config')->{'Model::Fnar'} || {}; +# $self->get_sub_container('component')->add_service( +# Catalyst::IOC::ConstructorInjection->new( +# name => 'model_Fnar', +# lifecycle => 'Singleton', +# class => 'TestAppCustomContainer::External::Class', +# dependencies => [ +# depends_on( '/catalyst_application' ), +# ], +# config => $fnar_config, +# ) +# ); +# $self->get_sub_container('model')->add_service( +# Catalyst::IOC::BlockInjection->new( +# name => 'model_Fnar', +# lifecycle => 'Singleton', +# dependencies => [ +# depends_on( '/config' ), +# depends_on( '/component/model_Fnar' ), +# ], +# block => sub { shift->param('model_Fnar') }, +# ) +# ); } __PACKAGE__->meta->make_immutable;