Bugzilla – Attachment 128882 Details for
Bug 29746
Add a handy Koha::Result::Boolean class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29746: Unit tests
Bug-29746-Unit-tests.patch (text/plain), 3.05 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-23 12:21:23 UTC
(
hide
)
Description:
Bug 29746: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-23 12:21:23 UTC
Size:
3.05 KB
patch
obsolete
>From b8b97eac10141ffd95dd119fe87975cf1f583659 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 21 Dec 2021 09:44:09 -0300 >Subject: [PATCH] Bug 29746: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/Koha/Result/Boolean.t | 74 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > create mode 100755 t/Koha/Result/Boolean.t > >diff --git a/t/Koha/Result/Boolean.t b/t/Koha/Result/Boolean.t >new file mode 100755 >index 0000000000..49223f4aeb >--- /dev/null >+++ b/t/Koha/Result/Boolean.t >@@ -0,0 +1,74 @@ >+#!/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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 4; >+ >+use_ok('Koha::Result::Boolean'); >+ >+subtest 'new() tests' => sub { >+ >+ plan tests => 4; >+ >+ ok( Koha::Result::Boolean->new, >+ 'Defaults to true if initialized without the parameter' ); >+ ok( Koha::Result::Boolean->new('Martin'), >+ 'Evals to true in boolean context if set an expression that evals to true' ); >+ ok( !Koha::Result::Boolean->new(0), >+ 'Evals to false in boolean context if set a false expression' ); >+ ok( !Koha::Result::Boolean->new(""), >+ 'Evals to false in boolean context if set a false expression' ); >+ >+}; >+ >+subtest 'set_value() tests' => sub { >+ >+ plan tests => 4; >+ >+ my $bool = Koha::Result::Boolean->new; >+ >+ ok( !$bool->set_value(), >+ 'Undef makes it eval to false' ); >+ ok( $bool->set_value('Martin'), >+ 'Evals to true in boolean context if set an expression that evals to true' ); >+ ok( !$bool->set_value(0), >+ 'Evals to false in boolean context if set a false expression' ); >+ ok( !$bool->set_value(""), >+ 'Evals to false in boolean context if set a false expression' ); >+ >+}; >+ >+subtest 'messages() and add_message() tests' => sub { >+ >+ plan tests => 5; >+ >+ my $bool = Koha::Result::Boolean->new(); >+ >+ my @messages = @{ $bool->messages }; >+ is( scalar @messages, 0, 'No messages' ); >+ >+ $bool->add_message({ message => "message_1" }); >+ $bool->add_message({ message => "message_2" }); >+ >+ @messages = @{ $bool->messages }; >+ >+ is( scalar @messages, 2, 'Messages are returned' ); >+ is( ref($messages[0]), 'Koha::Object::Message', 'Right type returned' ); >+ is( ref($messages[1]), 'Koha::Object::Message', 'Right type returned' ); >+ is( $messages[0]->message, 'message_1', 'Right message recorded' ); >+}; >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29746
:
128830
|
128831
|
128834
|
128835
|
128882
|
128883
|
128997
|
128998
|
129007