blob: 2110b7892d534b5166ec2825e4871bbd2170db47 [file] [log] [blame]
Akrone8235be2016-06-27 11:02:18 +02001use Mojo::Base -strict;
2use lib '../lib', 'lib';
Akronbe9d5b32017-04-05 20:48:24 +02003use Test::More;
Akrone8235be2016-06-27 11:02:18 +02004use Test::Mojo;
5use Data::Dumper;
6
7$ENV{MOJO_USERAGENT_DEBUG} = 1;
8
9my $t = Test::Mojo->new('Kalamar');
10
Akronbe9d5b32017-04-05 20:48:24 +020011$t->app->mode('test');
12
13# my $c = $t->app->build_controller;
14
15$t->get_ok('/')
16 ->element_exists('form[action=/user/login] input[name=handle_or_email]');
17
18$t->post_ok('/user/login' => form => { handle_or_email => 'test' })
19 ->status_is(302);
20
21$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'xyz' });
22
23done_testing;
24__END__
Akrone8235be2016-06-27 11:02:18 +020025
26
27ok(!$c->user->get('details'), 'User not logged in');
28
29# Login with user credentials
30ok($c->user->login('kustvakt', 'kustvakt2015'), 'Login with demo user');
31is($c->stash('user'), 'kustvakt', 'Kustvakt is logged in');
32like($c->stash('auth'), qr/^api_token /, 'Kustvakt is logged in');
33
34my $details = $c->user->get('details');
35is($details->{email}, 'kustvakt@ids-mannheim.de', 'Email');
36is($details->{firstName}, 'Kustvakt', 'Firstname');
37is($details->{lastName}, 'KorAP', 'Lastname');
38is($details->{country}, 'Germany', 'Country');
39is($details->{address}, 'Mannheim', 'Address');
40is($details->{username}, 'kustvakt', 'Username');
41is($details->{institution}, 'IDS Mannheim', 'Institution');
42
43my $settings = $c->user->get('settings');
44is($settings->{username}, 'kustvakt', 'Username');
45
46# ok($c->user->set(details => { firstName => 'Me' }), 'Set first name');
47#ok($c->user->set(details => {
48# firstName => 'Akron',
49# lastName => 'Fuxfell'
50#}), 'Set first name');
51
52# diag Dumper $c->user->get('info');
53
54ok(1,'Fine');
55
56done_testing;
57__END__