From: Errietta Kostala Date: Thu, 22 Jan 2015 14:35:51 +0000 (+0000) Subject: ADd login test. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9918773ac01a5610bbe99b9bf1a3ae9a8c918ff3;p=scpubgit%2Fstemmaweb.git ADd login test. --- diff --git a/Makefile.PL b/Makefile.PL index c5b870c..3155092 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -53,6 +53,8 @@ requires 'namespace::autoclean'; requires 'Config::General'; # This should reflect the config file format you've chosen # See Catalyst::Plugin::ConfigLoader for supported formats test_requires 'Test::More' => '0.88'; +test_requires 'LWP::Protocol::PSGI'; +test_requires 'Test::WWW::Mechanize'; catalyst; install_script glob('script/*.pl'); diff --git a/t/04login.t b/t/04login.t new file mode 100644 index 0000000..5816ab2 --- /dev/null +++ b/t/04login.t @@ -0,0 +1,28 @@ +use warnings; +use strict; + +use stemmaweb; +use LWP::Protocol::PSGI; +use Test::WWW::Mechanize; + +use Test::More; +use HTML::TreeBuilder; +use Data::Dumper; + +LWP::Protocol::PSGI->register(stemmaweb->psgi_app); + +my $ua = Test::WWW::Mechanize->new; + +$ua->get_ok('http://localhost/login'); +my $response = $ua->submit_form( + fields => { + username => 'user@example.org', + password => 'UserPass' + }); + +$ua->content_contains('Stemmaweb - Logged in', 'Log in successful.'); + +my $content = $ua->get('/'); +$ua->content_contains('Hello! user@example.org', 'We are logged in.'); + +done_testing;