Commit | Line | Data |
a5e3ddfd |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use lib 't/lib'; |
5 | |
076543d6 |
6 | use Test::More tests => 14; |
a5e3ddfd |
7 | |
8 | # We just want the class definitions in here. |
9 | use SharedTests; |
10 | |
11 | |
12 | ok( HasClassAttribute->meta()->has_class_attribute('ObjectCount'), |
13 | q{has_class_attribute('ObjectCount') returns true} ); |
14 | |
15 | ok( HasClassAttribute->meta()->get_class_attribute('ObjectCount') |
16 | ->meta()->does_role('MooseX::ClassAttribute::Role::Meta::Attribute'), |
17 | 'get_class_attribute_list returns an object which does the MooseX::ClassAttribute::Role::Meta::Attribute role' ); |
18 | |
19 | my @ca = qw( Delegatee LazyAttribute ManyNames ObjectCount ReadOnlyAttribute WeakAttribute ); |
20 | push @ca, 'Mapping' if SharedTests->HasMXAH(); |
21 | |
22 | is_deeply( [ sort HasClassAttribute->meta()->get_class_attribute_list() ], |
23 | [ sort @ca ], |
24 | 'HasClassAttribute get_class_attribute_list gets all class attributes' ); |
25 | |
26 | is_deeply( [ sort map { $_->name() } HasClassAttribute->meta()->get_all_attributes() ], |
27 | [ 'size' ], |
28 | 'HasClassAttribute get_all_attributes only finds size attribute' ); |
29 | |
30 | is_deeply( [ sort map { $_->name() } HasClassAttribute->meta()->get_all_class_attributes() ], |
31 | [ sort @ca ], |
32 | 'HasClassAttribute get_all_class_attributes gets all class attributes' ); |
33 | |
34 | is_deeply( [ sort keys %{ HasClassAttribute->meta()->get_class_attribute_map() } ], |
35 | [ sort @ca ], |
36 | 'HasClassAttribute get_class_attribute_map gets all class attributes' ); |
37 | |
38 | is_deeply( [ sort map { $_->name() } Child->meta()->get_all_class_attributes() ], |
39 | [ sort ( @ca, 'YetAnotherAttribute' ) ], |
40 | 'Child get_class_attribute_map gets all class attributes' ); |
41 | |
42 | ok( ! Child->meta()->has_class_attribute('ObjectCount'), |
43 | q{has_class_attribute('ObjectCount') returns false for Child} ); |
44 | |
45 | ok( Child->meta()->has_class_attribute('YetAnotherAttribute'), |
46 | q{has_class_attribute('YetAnotherAttribute') returns true for Child} ); |
47 | |
48 | ok( Child->can('YetAnotherAttribute'), |
49 | 'Child has accessor for YetAnotherAttribute' ); |
50 | |
51 | ok( Child->meta()->has_class_attribute_value('YetAnotherAttribute'), |
52 | 'Child has class attribute value for YetAnotherAttribute' ); |
53 | |
54 | Child->meta()->remove_class_attribute('YetAnotherAttribute'); |
55 | |
56 | ok( ! Child->meta()->has_class_attribute('YetAnotherAttribute'), |
57 | q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute} ); |
58 | |
59 | ok( ! Child->can('YetAnotherAttribute'), |
60 | 'accessor for YetAnotherAttribute has been removed' ); |
61 | |
62 | ok( ! Child->meta()->has_class_attribute_value('YetAnotherAttribute'), |
63 | 'Child does not have a class attribute value for YetAnotherAttribute' ); |