Koha/t/lib/KohaTest/Context/preference.pm
Andrew Moore 551b95284e bug 1953 [1/2]: fixing SQL injection problem in C4::Context->preference
C4::Context->preference was not using placeholders and was potentially vulnerable to
a SQL injectin attack. This patch refactors the method to use placeholders.

Added some tests for C4::Context.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-07-24 11:25:58 -05:00

54 lines
939 B
Perl

package KohaTest::Context::preference;
use base qw( KohaTest::Context );
use strict;
use warnings;
use Test::More;
use C4::Context;
sub testing_class { 'C4::Context' };
=head2 STARTUP METHODS
These get run once, before the main test methods in this module
=cut
=head2 TEST METHODS
standard test methods
=head3 preference_does_not_exist
=cut
sub preference_does_not_exist : Test( 1 ) {
my $self = shift;
my $missing = C4::Context->preference( 'doesnotexist' );
is( $missing, undef, 'a query for a missing syspref returns undef' )
or diag( Data::Dumper->Dump( [ $missing ], [ 'missing' ] ) );
}
=head3 version_preference
=cut
sub version_preference : Test( 1 ) {
my $self = shift;
my $version = C4::Context->preference( 'version' );
ok( $version, 'C4::Context->preference returns a good version number' )
or diag( Data::Dumper->Dump( [ $version ], [ 'version' ] ) );
}
1;