3 # Tests 'fetch', 'fake db data', and 'checks for existant attributes'
8 use Test
::More tests
=> 9;
11 use_ok
('C4::Members::AttributeTypes');
14 my $module = new Test
::MockModule
('C4::Context');
18 my $dbh = DBI
->connect( 'DBI:Mock:', '', '' )
19 || die "Cannot create handle: $DBI::errstr\n";
23 my $members_attributetypes = [
25 'code', 'description',
26 'repeatable', 'unique_id',
27 'opac_display', 'password_allowed',
28 'staff_searchable', 'authorised_value_category',
29 'display_checkout', 'catagory_code',
32 [ 'one', 'ISBN', '1', '1', '1', '1', '1', 'red', '1', 'orange', 'green' ],
33 [ 'two', 'ISSN', '0', '0', '0', '0', '0', 'blue', '0', 'yellow', 'silver' ]
36 my $dbh = C4
::Context
->dbh();
38 $dbh->{mock_add_resultset
} = $members_attributetypes;
40 my @members_attributetypes = C4
::Members
::AttributeTypes
::GetAttributeTypes
(undef, 1);
42 is
( $members_attributetypes[0]->{'code'}, 'one', 'First code value is one' );
44 is
( $members_attributetypes[1]->{'code'}, 'two', 'Second code value is two' );
46 is
( $members_attributetypes[0]->{'class'},
47 'green', 'First class value is green' );
49 is
( $members_attributetypes[1]->{'class'},
50 'silver', 'Second class value is silver' );
52 $dbh->{mock_add_resultset
} = $members_attributetypes;
54 ok
( C4
::Members
::AttributeTypes
::AttributeTypeExists
('one'),
55 'checking an attribute type exists' );
58 !C4
::Members
::AttributeTypes
::AttributeTypeExists
('three'),
59 "checking a attribute that isn't in the code doesn't exist"
62 $dbh->{mock_add_resultset
} = $members_attributetypes;
64 ok
( C4
::Members
::AttributeTypes
->fetch('ISBN'), "testing fetch feature" );
66 ok
( !C4
::Members
::AttributeTypes
->fetch('FAKE'),
67 "testing fetch feature doesn't work if value not in database" );