3 # Tests 'fetch', 'fake db data', and 'checks for existant attributes'
7 use Test::More tests => 10;
10 use_ok('C4::Members::AttributeTypes');
13 use Test::DBIx::Class {
14 schema_class => 'Koha::Schema',
15 connect_info => ['dbi:SQLite:dbname=:memory:','',''],
16 connect_opts => { name_sep => '.', quote_char => '`', },
17 fixture_class => '::Populate',
18 }, 'BorrowerAttributeType', 'Category' ;
23 ['orange'], ['yellow'],
25 BorrowerAttributeType => [
27 'code', 'description',
28 'repeatable', 'unique_id',
29 'opac_display', 'password_allowed',
30 'staff_searchable', 'authorised_value_category',
31 'display_checkout', 'category_code',
34 [ 'one', 'ISBN', '1', '1', '1', '1', '1', 'red', '1', 'orange', 'green' ],
35 [ 'two', 'ISSN', '0', '0', '0', '0', '0', 'blue', '0', 'yellow', 'silver' ]
40 my $db = Test::MockModule->new('Koha::Database');
41 $db->mock( _new_schema => sub { return Schema(); } );
43 my @members_attributetypes = C4::Members::AttributeTypes::GetAttributeTypes(undef, 1);
45 is( $members_attributetypes[0]->{'code'}, 'one', 'First code value is one' );
47 is( $members_attributetypes[1]->{'code'}, 'two', 'Second code value is two' );
49 is( $members_attributetypes[0]->{'class'},
50 'green', 'First class value is green' );
52 is( $members_attributetypes[1]->{'class'},
53 'silver', 'Second class value is silver' );
55 ok( C4::Members::AttributeTypes::AttributeTypeExists('one'),
56 'checking an attribute type exists' );
59 !C4::Members::AttributeTypes::AttributeTypeExists('three'),
60 "checking a attribute that isn't in the code doesn't exist"
63 ok( C4::Members::AttributeTypes->fetch('one'), "testing fetch feature" );
65 ok( !C4::Members::AttributeTypes->fetch('FAKE'),
66 "testing fetch feature doesn't work if value not in database" );