ADd login test.
Errietta Kostala [Thu, 22 Jan 2015 14:35:51 +0000 (14:35 +0000)]
Makefile.PL
t/04login.t [new file with mode: 0644]

index c5b870c..3155092 100644 (file)
@@ -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 (file)
index 0000000..5816ab2
--- /dev/null
@@ -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;