File: 047_dependencies_override_parameters.t

package info (click to toggle)
libbread-board-perl 0.29-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 620 kB
  • sloc: perl: 5,280; makefile: 13
file content (26 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use Bread::Board;

my $c = container Foo => as {
    service a => 'A';
    service foo => (
        block        => sub { $_[0]->param('a'); },
        dependencies => ['a'],
        parameters   => {
            # XXX should optional need to be specified here? or should an
            # existing dependency of the same name imply that? seems to
            # parallel the default/required situation in moose, where default
            # overrides required, but not sure
            a => { optional => 1 },
        },
    );
};

is($c->resolve(service => 'foo'), 'A');
is($c->resolve(service => 'foo', parameters => { a => 'B' }), 'B');

done_testing;