Debian Codegraph @

share/skel/tutorial/t/003_login.t

raw
1 use strict;
2 use warnings;
3 use Test::More;
4 use Test::WWW::Mechanize::PSGI;
5
6 use [d2% appname %2d];
7 my $mech = Test::WWW::Mechanize::PSGI->new(
8 app => [d2% appname %2d]->to_app,
9 );
10
11 $mech->get_ok('/create', 'Got /create while not logged in');
12 $mech->content_contains('Password', '...and was presented with a login page');
13 $mech->submit_form_ok({
14 fields => {
15 username => 'admin',
16 password => 'foobar',
17 }}, '...which we gave invalid credentials');
18 $mech->content_contains('Invalid username or password', '...and gave us an appropriate error');
19 $mech->submit_form_ok({
20 fields => {
21 username => 'admin',
22 password => 'test',
23 }}, '...so we give it real credentials');
24 $mech->content_contains('form', '...and get something that looks like the create form' );
25 $mech->content_contains('Content', 'Confirmed this is the create form');
26
27 done_testing;