From 1442499a0b6d6c22c87b7ef9eea4c7cc540e3fce Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 11 Sep 2018 10:43:32 -0700 Subject: [PATCH] Bug 21334: Unit tests This patch adds unit tests for the new content types being added. It also adds tests for the 'json' overloading that already takes place in V1.pm. Signed-off-by: Michal Denar Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- t/db_dependent/Koha/REST/V1.t | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 t/db_dependent/Koha/REST/V1.t diff --git a/t/db_dependent/Koha/REST/V1.t b/t/db_dependent/Koha/REST/V1.t new file mode 100644 index 0000000000..faddea9da3 --- /dev/null +++ b/t/db_dependent/Koha/REST/V1.t @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Test::More tests => 1; +use Test::Mojo; +use Test::Warn; + +use JSON::Validator::OpenAPI::Mojolicious; + +subtest 'Type definition tests' => sub { + + plan tests => 4; + + # initialize Koha::REST::V1 after mocking + my $remote_address = '127.0.0.1'; + my $t; + + $t = Test::Mojo->new('Koha::REST::V1'); + my $types = $t->app->types; + + is( $types->type('json'), + 'application/json; charset=utf8', + 'application/json gets charset added' + ); + is( $types->type('marcxml'), 'application/marcxml+xml', 'application/marcxml+xml is defined' ); + is( $types->type('mij'), 'application/marc-in-json', 'application/marc-in-json is defined' ); + is( $types->type('marc'), 'application/marc', 'application/marc is defined' ); +}; -- 2.39.5