Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 000_recipes / moose_cookbook_basics_recipe6.t
CommitLineData
f9aca0f3 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More 'no_plan';
5use Test::Exception;
6$| = 1;
7
8
9
10# =begin testing SETUP
11{
12
13 package Document::Page;
14 use Mouse;
15
16 has 'body' => ( is => 'rw', isa => 'Str', default => sub {''} );
17
18 sub create {
19 my $self = shift;
20 $self->open_page;
21 inner();
22 $self->close_page;
23 }
24
25 sub append_body {
26 my ( $self, $appendage ) = @_;
27 $self->body( $self->body . $appendage );
28 }
29
30 sub open_page { (shift)->append_body('<page>') }
31 sub close_page { (shift)->append_body('</page>') }
32
33 package Document::PageWithHeadersAndFooters;
34 use Mouse;
35
36 extends 'Document::Page';
37
38 augment 'create' => sub {
39 my $self = shift;
40 $self->create_header;
41 inner();
42 $self->create_footer;
43 };
44
45 sub create_header { (shift)->append_body('<header/>') }
46 sub create_footer { (shift)->append_body('<footer/>') }
47
48 package TPSReport;
49 use Mouse;
50
51 extends 'Document::PageWithHeadersAndFooters';
52
53 augment 'create' => sub {
54 my $self = shift;
55 $self->create_tps_report;
56 inner();
57 };
58
59 sub create_tps_report {
60 (shift)->append_body('<report type="tps"/>');
61 }
62
63 # <page><header/><report type="tps"/><footer/></page>
64 my $report_xml = TPSReport->new->create;
65}
66
67
68
69# =begin testing
70{
71my $tps_report = TPSReport->new;
72isa_ok( $tps_report, 'TPSReport' );
73
74is(
75 $tps_report->create,
76 q{<page><header/><report type="tps"/><footer/></page>},
77 '... got the right TPS report'
78);
79}
80
81
82
83
841;