X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fdb_helper%2Facts_as_list.t;h=3b5b570eaf17fa57d2d336ba2df21bc82c252d87;hb=db3b23aa8ab6baaa3854259b59b033fbd23541ad;hp=0d47bb2537492a413e1ae0ef528c3e1b66c251f3;hpb=49556f01cfe6a395cf5554e1a00dc61d6da0493e;p=kivitendo-erp.git diff --git a/t/db_helper/acts_as_list.t b/t/db_helper/acts_as_list.t index 0d47bb253..3b5b570ea 100644 --- a/t/db_helper/acts_as_list.t +++ b/t/db_helper/acts_as_list.t @@ -1,4 +1,4 @@ -use Test::More tests => 50; +use Test::More; use Test::Exception; use strict; @@ -9,9 +9,18 @@ use utf8; use Data::Dumper; use Support::TestSetup; -use_ok 'SL::DB::RequirementSpec'; -use_ok 'SL::DB::RequirementSpecItem'; -use_ok 'SL::DB::RequirementSpecTextBlock'; +eval { + require 'SL::DB::RequirementSpec'; + require 'SL::DB::RequirementSpecItem'; + require 'SL::DB::RequirementSpecTextBlock'; + 1; +} or my $skip = 'RequirementSpec is not available for this test'; + +if ($skip) { + plan skip_all => $skip; +} else { + plan tests => 48; +} sub reset_state { "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(RequirementSpecTextBlock RequirementSpecItem RequirementSpec); @@ -206,6 +215,10 @@ reset_state(); $item = get_item(8); $item->remove_from_list; $item->parent_id(3); $item->add_to_list(position => 'first'); test_positions "add_to_list position 'first' in empty", [ 1, undef, 1 ], [ 2, undef, 2 ], [ 3, 1, 1 ], [ 4, 1, 2 ], [ 5, 1, 3 ], [ 6, 4, 1 ], [ 7, 4, 2 ], [ 8, 3, 1 ]; +reset_state(); +$item = get_item(5); $item->add_to_list(position => 'after', reference => 3); +test_positions "add_to_list without prior remove_from_list", [ 1, undef, 1 ], [ 2, undef, 2 ], [ 3, 1, 1 ], [ 5, 1, 2 ], [ 4, 1, 3 ], [ 6, 4, 1 ], [ 7, 4, 2 ], [ 8, 2, 1 ]; + reset_state(); $item = get_item(4); is($item->get_next_in_list->id, 5, 'Next of 4 is 5');