File: match_accept_xml.t

package info (click to toggle)
libmagpie-perl 1.141660-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 3,524 kB
  • ctags: 337
  • sloc: perl: 4,081; xml: 405; makefile: 26
file content (45 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;
use Test::More;
use FindBin;
use lib "$FindBin::Bin/../lib";

use Test::Requires qw{
    XML::LibXML
};

use Plack::Test;
use Plack::Builder;
use HTTP::Request::Common;
use Plack::Middleware::Magpie;

my $context = {
    is              => 'everything',
    actually        => 'matters',
    is_frequently   => [qw(ignored misunderstood)],
};

my $handler = builder {
    enable "Magpie", context => $context, conf => 't/data/match_accept.xml'
};

test_psgi
    app    => $handler,
    client => sub {
        my $cb = shift;
        {
            my $res = $cb->(GET "http://localhost/",  Accept => 'text/plain', 'Accept-Language' => 'DE,en,fr;Q=0.5,es;q=0.1' );
            like $res->content, qr/_moebaz__moebar__curlyfoo_RIGHT_actually__is__is_frequently__larryfoo__larrybar_/;
        }
        {
            my $res = $cb->(GET "http://localhost/", Accept => 'application/x-xml', 'Accept-Language' => 'DE,en,fr;Q=0.5,es;q=0.1');
            like $res->content, qr/_moebaz__moebar__curlyfoo_RIGHT\b/;
        }
        {
            my $res = $cb->(GET "http://localhost/", 'Accept-Language' => 'en,fr;Q=0.5,es;q=0.1');
            like $res->content, qr/_moebaz__moebar__curlyfoo_RIGHT_larryfoo__larrybar__actually__is__is_frequently_\b/;
        }
    };


done_testing();