summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-12-28 06:09:41 -0600
committerJesse Luehrs <doy@tozt.net>2012-12-28 06:09:41 -0600
commit78a70ab703db2f44d4af3117388e62a2ac1396fa (patch)
tree92f0daeaccb0acef89082b4a6f4029aa4c74a2a5 /t
parentb125d0c515a005c193f6d3cf28c3662a0f8eeb8a (diff)
downloadp6-bread-board-78a70ab703db2f44d4af3117388e62a2ac1396fa.tar.gz
p6-bread-board-78a70ab703db2f44d4af3117388e62a2ac1396fa.zip
implement fetch, and path resolution
Diffstat (limited to 't')
-rw-r--r--t/011_container_path.t83
1 files changed, 83 insertions, 0 deletions
diff --git a/t/011_container_path.t b/t/011_container_path.t
new file mode 100644
index 0000000..b0e1b78
--- /dev/null
+++ b/t/011_container_path.t
@@ -0,0 +1,83 @@
+use v6;
+use Test;
+
+use Bread::Board;
+
+class MyApp::Schema { }
+class MyApp::View::TT { }
+
+my $c = Bread::Board::Container.new(
+ name => 'Application',
+ sub_containers => [
+ Bread::Board::Container.new(
+ name => 'Model',
+ services => [
+ Bread::Board::Literal.new(name => 'dsn', value => ''),
+ Bread::Board::ConstructorInjection.new(
+ name => 'schema',
+ class => MyApp::Schema,
+ dependencies => {
+ dsn => Bread::Board::Dependency.new(
+ service_path => 'dsn',
+ ),
+ user => Bread::Board::Literal.new(
+ name => 'user',
+ value => '',
+ ),
+ pass => Bread::Board::Literal.new(
+ name => 'pass',
+ value => '',
+ ),
+ },
+ ),
+ ],
+ ),
+ Bread::Board::Container.new(
+ name => 'View',
+ services => [
+ Bread::Board::ConstructorInjection.new(
+ name => 'TT',
+ class => MyApp::View::TT,
+ dependencies => {
+ tt_include_path => Bread::Board::Literal.new(
+ name => 'include_path',
+ value => [],
+ ),
+ },
+ ),
+ ],
+ ),
+ Bread::Board::Container.new(name => 'Controller'),
+ ],
+);
+
+my $model = $c.fetch('Model');
+isa_ok($model, Bread::Board::Container);
+is($model.name, 'Model');
+
+{
+ my $model2 = $c.fetch('/Model');
+ isa_ok($model2, Bread::Board::Container);
+ is($model, $model2);
+}
+
+my $dsn = $model.fetch('schema/dsn');
+isa_ok($dsn, Bread::Board::Dependency);
+is($dsn.service_path, 'dsn');
+
+{
+ my $dsn2 = $c.fetch('/Model/schema/dsn');
+ isa_ok($dsn2, Bread::Board::Dependency);
+ is($dsn, $dsn2);
+}
+
+my $root = $model.fetch('../');
+isa_ok($root, Bread::Board::Container);
+is($root, $c);
+is($model, $model.fetch('../Model'));
+is($dsn, $model.fetch('../Model/schema/dsn'));
+is($model, $dsn.fetch('../Model'));
+
+done;
+
+# vim:ft=perl6:foldmethod=manual