summaryrefslogtreecommitdiffstats
path: root/t/025_sugar_w_absolute_path.t
blob: ca9a08a2f65f7bf643cc09aa234e5b6f2428e902 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use v6;
use Test;

use Bread::Board;

class MyApp::Schema { }
class MyApp::View::TT { }

my $c = container 'Application', {
    container 'Model', {
        service 'dsn', '';
        service 'schema', (
            class        => MyApp::Schema,
            dependencies => {
                dsn  => depends_on('dsn'),
                user => depends_on('user'),
                pass => depends_on('pass'),
            },
        );
    };
    container 'View', {
        service 'TT', (
            class        => MyApp::View::TT,
            dependencies => {
                tt_include_path => depends_on('include_path'),
            };
        );
    };
    container '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