X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flib%2FTestAppCustomContainer%2FNoSugarContainer.pm;h=f4ad4d648a325d2d99576a569a530f8301051a2f;hp=e30b08bea368ff9902a02659d184bd9742186edc;hb=refs%2Fheads%2Fgsoc_breadboard_with_app_instance;hpb=e9af4f7db9d15b4bcb6c49481031c2afa0de22e4 diff --git a/t/lib/TestAppCustomContainer/NoSugarContainer.pm b/t/lib/TestAppCustomContainer/NoSugarContainer.pm index e30b08b..f4ad4d6 100644 --- a/t/lib/TestAppCustomContainer/NoSugarContainer.pm +++ b/t/lib/TestAppCustomContainer/NoSugarContainer.pm @@ -8,121 +8,79 @@ extends 'Catalyst::IOC::Container'; sub BUILD { my $self = shift; - $self->get_sub_container('component')->add_service( - Catalyst::IOC::ConstructorInjection->new( - name => 'model_Bar', - lifecycle => 'Singleton', - class => 'TestAppCustomContainer::Model::Bar', - dependencies => [ - depends_on( '/application_name' ), - depends_on( '/config' ), - depends_on( 'model_Foo' ), - ], - ) - ); $self->get_sub_container('model')->add_service( - Catalyst::IOC::BlockInjection->new( - name => 'Bar', - lifecycle => 'Singleton', - dependencies => [ - Bread::Board::Dependency->new( - service_path => '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 => [ +{} ], - }, - ), - depends_on( '/component/model_Bar' ), - ], - block => sub { - my $s = shift; - - my $foo = $s->param('Foo'); - $foo->inc_bar_got_it; - - return $s->param('model_Bar'); + Catalyst::IOC::ConstructorInjection->new( + name => 'SingletonLifeCycle', + lifecycle => 'Singleton', + class => 'TestAppCustomContainer::Model::SingletonLifeCycle', + catalyst_component_name => 'TestAppCustomContainer::Model::SingletonLifeCycle', + dependencies => { + application => depends_on( '/application' ), }, ) ); - $self->get_sub_container('component')->add_service( - Catalyst::IOC::ConstructorInjection->new( - name => 'model_Baz', - class => 'TestAppCustomContainer::Model::Baz', - lifecycle => 'Singleton', - - # while it doesn't fully work - #lifecycle => '+Catalyst::IOC::LifeCycle::Request', - dependencies => [ - depends_on( '/application_name' ), - depends_on( '/config' ), - depends_on( 'model_Foo' ), - ], - ) - ); $self->get_sub_container('model')->add_service( - Catalyst::IOC::BlockInjection->new( - name => 'Baz', - dependencies => [ - Bread::Board::Dependency->new( - service_path => 'Foo', - - # FIXME - same as above - service_params => { - ctx => +{}, - accept_context_args => [ +{} ], - }, - ), - depends_on( '/component/model_Baz' ), - ], - block => sub { - my $s = shift; - - my $foo = $s->param('Foo'); - $foo->inc_baz_got_it; - - return $s->param('model_Baz'); + Catalyst::IOC::ConstructorInjection->new( + name => 'RequestLifeCycle', + lifecycle => '+Catalyst::IOC::LifeCycle::Request', + class => 'TestAppCustomContainer::Model::RequestLifeCycle', + catalyst_component_name => 'TestAppCustomContainer::Model::RequestLifeCycle', + dependencies => { + application => depends_on( '/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 => { +# application => depends_on( '/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( '/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;