6 use Test::More tests => 14;
8 # We just want the class definitions in here.
12 ok( HasClassAttribute->meta()->has_class_attribute('ObjectCount'),
13 q{has_class_attribute('ObjectCount') returns true} );
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' );
19 my @ca = qw( Delegatee
31 is_deeply( [ sort HasClassAttribute->meta()->get_class_attribute_list() ],
33 'HasClassAttribute get_class_attribute_list gets all class attributes' );
35 is_deeply( [ sort map { $_->name() } HasClassAttribute->meta()->get_all_attributes() ],
37 'HasClassAttribute get_all_attributes only finds size attribute' );
39 is_deeply( [ sort map { $_->name() } HasClassAttribute->meta()->get_all_class_attributes() ],
41 'HasClassAttribute get_all_class_attributes gets all class attributes' );
43 is_deeply( [ sort keys %{ HasClassAttribute->meta()->get_class_attribute_map() } ],
45 'HasClassAttribute get_class_attribute_map gets all class attributes' );
47 is_deeply( [ sort map { $_->name() } Child->meta()->get_all_class_attributes() ],
48 [ sort ( @ca, 'YetAnotherAttribute' ) ],
49 'Child get_class_attribute_map gets all class attributes' );
51 ok( ! Child->meta()->has_class_attribute('ObjectCount'),
52 q{has_class_attribute('ObjectCount') returns false for Child} );
54 ok( Child->meta()->has_class_attribute('YetAnotherAttribute'),
55 q{has_class_attribute('YetAnotherAttribute') returns true for Child} );
57 ok( Child->can('YetAnotherAttribute'),
58 'Child has accessor for YetAnotherAttribute' );
60 ok( Child->meta()->has_class_attribute_value('YetAnotherAttribute'),
61 'Child has class attribute value for YetAnotherAttribute' );
63 Child->meta()->remove_class_attribute('YetAnotherAttribute');
65 ok( ! Child->meta()->has_class_attribute('YetAnotherAttribute'),
66 q{... has_class_attribute('YetAnotherAttribute') returns false after remove_class_attribute} );
68 ok( ! Child->can('YetAnotherAttribute'),
69 'accessor for YetAnotherAttribute has been removed' );
71 ok( ! Child->meta()->has_class_attribute_value('YetAnotherAttribute'),
72 'Child does not have a class attribute value for YetAnotherAttribute' );