X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=t%2Fdb_dependent%2FInstaller.t;h=8dfd9167558c62da5f95225e79a385a4a316b8cc;hb=9d6d641d1f8b77271800f43bc027b651f9aea52b;hp=46d04c0427aa119f3782b7bc98f5551f788486bd;hpb=8938631f38bb22456424219d3c3453493df6f848;p=srvgit diff --git a/t/db_dependent/Installer.t b/t/db_dependent/Installer.t old mode 100644 new mode 100755 index 46d04c0427..8dfd916755 --- a/t/db_dependent/Installer.t +++ b/t/db_dependent/Installer.t @@ -22,11 +22,14 @@ # Add more tests here!!! use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 19; +use File::Temp qw(tempfile); +use utf8; + use Koha::Database; BEGIN { - use_ok('C4::Installer'); + use_ok('C4::Installer', qw( column_exists index_exists foreign_key_exists primary_key_exists marc_framework_sql_list )); } ok( my $installer = C4::Installer->new(), 'Testing NewInstaller' ); @@ -55,8 +58,39 @@ my $source = $schema->source('Borrower'); my @column_names = $source->columns(); my $column_name = $column_names[0]; ok( column_exists( 'borrowers', $column_name ), 'Known column does exist' ); - +ok( ! column_exists( 'borrowers', 'xxx'), 'Column xxx does not exist' ); +{ + ok( ! column_exists( 'this_table_will_never_exist', 'xxx'), 'Column xxx does not exist, the table does not exist' ); +} my @constraint_names = $source->unique_constraint_names(); my $constraint_name = $constraint_names[0]; -ok( constraint_exists( 'borrowers', $constraint_name ), - 'Known constraint does exist' ); +ok( index_exists( 'borrowers', $constraint_name), 'Known contraint does exist' ); +ok( ! index_exists( 'borrowers', 'xxx'), 'Constraint xxx does not exist' ); + +ok( foreign_key_exists( 'borrowers', 'borrowers_ibfk_1' ), 'FK borrowers_ibfk_1 exists' ); +ok( ! foreign_key_exists( 'borrowers', 'xxx' ), 'FK xxxx does not exist' ); + + +ok( primary_key_exists( 'borrowers', 'borrowernumber'), 'Borrowers has primary key on borrowernumber'); +ok( ! primary_key_exists( 'borrowers', 'email'), 'Borrowers does not have a primary key on email'); + +subtest 'marc_framework_sql_list' => sub { + plan tests => 1; + + my ($fh, $filepath) = tempfile( DIR => C4::Context->config("intranetdir") . "/installer/data/mysql/en/marcflavour/marc21/mandatory", SUFFIX => '.yml', UNLINK => 1 ); + print $fh Encode::encode_utf8("---\ndescription:\n - \"Standardowe typy haseł przedmiotowych MARC21\"\n"); + close $fh; + + my $yaml_files = $installer->marc_framework_sql_list('en', 'MARC21'); + + my $description; + FILE: for my $file ( @$yaml_files ) { + for my $framework ( @{ $file->{frameworks}} ) { + if ( $framework->{fwkfile} eq $filepath ) { + $description = $framework->{fwkdescription}->[0]; + last FILE; + } + } + } + is( $description, 'Standardowe typy haseł przedmiotowych MARC21' ); +};