Koha integration tests - remove and create test user
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 23 Feb 2010 18:16:03 +0000 (18:16 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 23 Feb 2010 18:16:03 +0000 (18:16 +0000)
t/koha/01-remove-test-user.t [new file with mode: 0755]
t/koha/02-create-test-user.t [new file with mode: 0755]

diff --git a/t/koha/01-remove-test-user.t b/t/koha/01-remove-test-user.t
new file mode 100755 (executable)
index 0000000..3f3a694
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 6;
+use Test::WWW::Mechanize;
+
+our ( $user, $passwd );
+require 'config.pl';
+
+my $url = 'https://localhost:8443'; # Koha intranet
+
+my $mech = Test::WWW::Mechanize->new;
+
+$mech->get_ok( $url, 'intranet' );
+
+$mech->submit_form_ok({
+       fields => {
+               userid => $user,
+               password => $passwd,
+       },
+}, 'login');
+
+$mech->submit_form_ok({
+       form_number => 2,
+       fields => {
+               member => 'kohatest@ffzg.hr',
+       },
+}, 'find patron' );
+
+#diag $mech->content;
+
+$mech->follow_link_ok({ url_regex => qr/moremember/ }, 'details' );
+
+my $html = $mech->content();
+
+if ( $html =~ m{(/cgi-bin/koha/members/deletemem\.pl\?member=\d+)}s ) {
+       ok( $1, 'found deletemem' );
+       $mech->get_ok( $url . $1 );
+}
diff --git a/t/koha/02-create-test-user.t b/t/koha/02-create-test-user.t
new file mode 100755 (executable)
index 0000000..62df482
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 3;
+use Test::WWW::Mechanize;
+use File::Slurp;
+
+our $config;
+require 't/config.pl';
+
+use WWW::Mechanize;
+
+my $mech = Test::WWW::Mechanize->new;
+
+my $save_count = 1;
+sub save { write_file "/tmp/login-$save_count.html", @_; $save_count++; }
+       
+
+$mech->get_ok( 'https://localhost', 'opac' );
+save $mech->content;
+
+$mech->follow_link_ok({ text_regex => qr/Log in to Your Account/i }, 'login form' );
+save $mech->content;
+
+$mech->submit_form_ok({
+       form_number => 2,
+       fields => {
+               userid => $config->{bind_as},
+               password => $config->{password},
+       },
+}, 'login');
+save $mech->content;
+