2007-02-24 21:23:17 +01:00
|
|
|
# Before `make install' is performed this script should be runnable with
|
|
|
|
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t'
|
|
|
|
|
|
|
|
#########################
|
|
|
|
|
|
|
|
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
|
|
|
2016-01-09 20:22:31 +01:00
|
|
|
use strict;
|
|
|
|
use Test::More;
|
2008-11-17 17:59:56 +01:00
|
|
|
BEGIN { use_ok('Lemonldap::NG::Common::Conf') }
|
2007-02-24 21:23:17 +01:00
|
|
|
|
|
|
|
#########################
|
|
|
|
|
|
|
|
# Insert your test code below, the Test::More module is use()ed here so read
|
|
|
|
# its man page ( perldoc Test::More ) for help writing this test script.
|
|
|
|
|
2007-05-06 16:41:30 +02:00
|
|
|
my $h;
|
2008-12-26 17:13:36 +01:00
|
|
|
|
2019-02-05 23:12:17 +01:00
|
|
|
ok(
|
2019-02-07 09:27:56 +01:00
|
|
|
$h = new Lemonldap::NG::Common::Conf( {
|
2019-02-05 23:12:17 +01:00
|
|
|
type => 'File',
|
2016-01-09 20:22:31 +01:00
|
|
|
dirName => "t/",
|
2009-02-25 19:10:07 +01:00
|
|
|
}
|
2008-12-26 17:13:36 +01:00
|
|
|
),
|
|
|
|
'type => file',
|
2007-05-06 16:41:30 +02:00
|
|
|
);
|
2016-01-09 20:22:31 +01:00
|
|
|
my $count = 2;
|
2008-12-26 17:13:36 +01:00
|
|
|
|
2016-01-09 20:22:31 +01:00
|
|
|
my @test = (
|
|
|
|
|
|
|
|
# simple ascii
|
|
|
|
{ cfgNum => 1, test => 'ascii' },
|
|
|
|
|
|
|
|
# utf-8
|
|
|
|
{ cfgNum => 1, test => 'Русский' },
|
|
|
|
|
|
|
|
# compatible utf8/latin-1 char but with different codes
|
|
|
|
{ cfgNum => 1, test => 'éà' }
|
|
|
|
);
|
|
|
|
|
2019-02-05 23:12:17 +01:00
|
|
|
for ( my $i = 0 ; $i < @test ; $i++ ) {
|
2016-01-09 20:22:31 +01:00
|
|
|
ok( $h->store( $test[$i] ) == 1, "Test $i is stored" )
|
2019-02-05 23:12:17 +01:00
|
|
|
or print STDERR "$Lemonldap::NG::Common::Conf::msg $!";
|
2016-01-09 20:22:31 +01:00
|
|
|
$count++;
|
|
|
|
my $cfg;
|
|
|
|
ok( $cfg = $h->load(1), "Test $i can be read" )
|
2019-02-05 23:12:17 +01:00
|
|
|
or print STDERR $Lemonldap::NG::Common::Conf::msg;
|
2016-01-11 21:32:44 +01:00
|
|
|
ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" )
|
2019-02-05 23:12:17 +01:00
|
|
|
or print STDERR "Expect $cfg->{test} eq $test[$i]->{test}\n";
|
2016-01-09 20:22:31 +01:00
|
|
|
$count += 2;
|
|
|
|
}
|
|
|
|
|
2017-01-27 12:58:46 +01:00
|
|
|
unlink 't/lmConf-1.json';
|
2016-01-09 20:22:31 +01:00
|
|
|
|
|
|
|
done_testing($count);
|