Ignore MYMETA.yml
[gitmo/MooseX-ClassAttribute.git] / t / 03-introspection.t
CommitLineData
a5e3ddfd 1use strict;
2use warnings;
3
4use lib 't/lib';
5
ee29de7b 6use Test::More;
a5e3ddfd 7
8# We just want the class definitions in here.
9use SharedTests;
10
a3ced883 11ok(
12 HasClassAttribute->meta()->has_class_attribute('ObjectCount'),
13 q{has_class_attribute('ObjectCount') returns true}
14);
a5e3ddfd 15
a3ced883 16ok(
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 22my @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
35is_deeply(
36 [ sort HasClassAttribute->meta()->get_class_attribute_list() ],
37 [ sort @ca ],
38 'HasClassAttribute get_class_attribute_list gets all class attributes'
39);
40
41is_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
50is_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
59is_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
65is_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
71ok(
72 !Child->meta()->has_class_attribute('ObjectCount'),
73 q{has_class_attribute('ObjectCount') returns false for Child}
74);
75
76ok(
77 Child->meta()->has_class_attribute('YetAnotherAttribute'),
78 q{has_class_attribute('YetAnotherAttribute') returns true for Child}
79);
80
81ok(
82 Child->can('YetAnotherAttribute'),
83 'Child has accessor for YetAnotherAttribute'
84);
85
86ok(
87 Child->meta()->has_class_attribute_value('YetAnotherAttribute'),
88 'Child has class attribute value for YetAnotherAttribute'
89);
a5e3ddfd 90
91Child->meta()->remove_class_attribute('YetAnotherAttribute');
92
a3ced883 93ok(
94 !Child->meta()->has_class_attribute('YetAnotherAttribute'),
95 q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute}
96);
a5e3ddfd 97
a3ced883 98ok(
99 !Child->can('YetAnotherAttribute'),
100 'accessor for YetAnotherAttribute has been removed'
101);
a5e3ddfd 102
a3ced883 103ok(
104 !Child->meta()->has_class_attribute_value('YetAnotherAttribute'),
105 'Child does not have a class attribute value for YetAnotherAttribute'
106);
ee29de7b 107
108done_testing();