first pass RT4 merge, RT#13852
[freeside.git] / rt / t / api / config.t
1 use strict;
2 use warnings;
3 use RT;
4 use RT::Test nodb => 1, tests => 9;
5
6 ok(
7     RT::Config->AddOption(
8         Name    => 'foo',
9         Section => 'bar',
10     ),
11     'added option foo'
12 );
13
14 my $meta = RT::Config->Meta('foo');
15 is( $meta->{Section}, 'bar', 'Section is bar' );
16 is( $meta->{Widget}, '/Widgets/Form/String', 'default Widget is string' );
17 is_deeply( $meta->{WidgetArguments},
18     {},, 'default WidgetArguments is empty hashref' );
19
20 ok(
21     RT::Config->UpdateOption(
22         Name    => 'foo',
23         Section => 'baz',
24         Widget => '/Widgets/Form/Boolean',
25     ),
26     'updated option foo to section baz'
27 );
28 is( $meta->{Section}, 'baz', 'section is updated to baz' );
29 is( $meta->{Widget}, '/Widgets/Form/Boolean', 'widget is updated to boolean' );
30
31 ok( RT::Config->DeleteOption( Name => 'foo' ), 'removed option foo' );
32 is( RT::Config->Meta('foo'), undef, 'foo is indeed deleted' );
33