Commit | Line | Data |
a5e3ddfd |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use lib 't/lib'; |
5 | |
ee29de7b |
6 | use Test::More; |
a5e3ddfd |
7 | |
8 | # We just want the class definitions in here. |
9 | use SharedTests; |
10 | |
a3ced883 |
11 | ok( |
12 | HasClassAttribute->meta()->has_class_attribute('ObjectCount'), |
13 | q{has_class_attribute('ObjectCount') returns true} |
14 | ); |
a5e3ddfd |
15 | |
a3ced883 |
16 | ok( |
17 | HasClassAttribute->meta()->get_class_attribute('ObjectCount')->meta() |
18 | ->does_role('MooseX::ClassAttribute::Role::Meta::Attribute'), |
19 | 'get_class_attribute_list returns an object which does the MooseX::ClassAttribute::Role::Meta::Attribute role' |
20 | ); |
a5e3ddfd |
21 | |
8207dfe7 |
22 | my @ca = qw( Delegatee |
a3ced883 |
23 | LazyAttribute |
24 | ManyNames |
25 | Mapping |
26 | ObjectCount |
27 | ReadOnlyAttribute |
28 | WeakAttribute |
29 | Built |
30 | LazyBuilt |
31 | Triggerish |
88b7f2c8 |
32 | TriggerRecord |
a3ced883 |
33 | ); |
34 | |
35 | is_deeply( |
36 | [ sort HasClassAttribute->meta()->get_class_attribute_list() ], |
37 | [ sort @ca ], |
38 | 'HasClassAttribute get_class_attribute_list gets all class attributes' |
39 | ); |
40 | |
41 | is_deeply( |
42 | [ |
43 | sort map { $_->name() } |
44 | HasClassAttribute->meta()->get_all_attributes() |
45 | ], |
46 | ['size'], |
47 | 'HasClassAttribute get_all_attributes only finds size attribute' |
48 | ); |
49 | |
50 | is_deeply( |
51 | [ |
52 | sort map { $_->name() } |
53 | HasClassAttribute->meta()->get_all_class_attributes() |
54 | ], |
55 | [ sort @ca ], |
56 | 'HasClassAttribute get_all_class_attributes gets all class attributes' |
57 | ); |
58 | |
59 | is_deeply( |
60 | [ sort keys %{ HasClassAttribute->meta()->get_class_attribute_map() } ], |
61 | [ sort @ca ], |
62 | 'HasClassAttribute get_class_attribute_map gets all class attributes' |
63 | ); |
64 | |
65 | is_deeply( |
66 | [ sort map { $_->name() } Child->meta()->get_all_class_attributes() ], |
67 | [ sort ( @ca, 'YetAnotherAttribute' ) ], |
68 | 'Child get_class_attribute_map gets all class attributes' |
69 | ); |
70 | |
71 | ok( |
72 | !Child->meta()->has_class_attribute('ObjectCount'), |
73 | q{has_class_attribute('ObjectCount') returns false for Child} |
74 | ); |
75 | |
76 | ok( |
77 | Child->meta()->has_class_attribute('YetAnotherAttribute'), |
78 | q{has_class_attribute('YetAnotherAttribute') returns true for Child} |
79 | ); |
80 | |
81 | ok( |
82 | Child->can('YetAnotherAttribute'), |
83 | 'Child has accessor for YetAnotherAttribute' |
84 | ); |
85 | |
86 | ok( |
87 | Child->meta()->has_class_attribute_value('YetAnotherAttribute'), |
88 | 'Child has class attribute value for YetAnotherAttribute' |
89 | ); |
a5e3ddfd |
90 | |
91 | Child->meta()->remove_class_attribute('YetAnotherAttribute'); |
92 | |
a3ced883 |
93 | ok( |
94 | !Child->meta()->has_class_attribute('YetAnotherAttribute'), |
95 | q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute} |
96 | ); |
a5e3ddfd |
97 | |
a3ced883 |
98 | ok( |
99 | !Child->can('YetAnotherAttribute'), |
100 | 'accessor for YetAnotherAttribute has been removed' |
101 | ); |
a5e3ddfd |
102 | |
a3ced883 |
103 | ok( |
104 | !Child->meta()->has_class_attribute_value('YetAnotherAttribute'), |
105 | 'Child does not have a class attribute value for YetAnotherAttribute' |
106 | ); |
ee29de7b |
107 | |
108 | done_testing(); |