Fix ::Ordered in combination with delete_all
[dbsrgits/DBIx-Class.git] / t / ordered / unordered_movement.t
CommitLineData
375c84bb 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use lib qw(t/lib);
7use DBICTest;
8
9my $schema = DBICTest->init_schema();
10
11my $cd = $schema->resultset('CD')->next;
37b9b05b 12$cd->tracks->delete;
375c84bb 13
37b9b05b 14$schema->resultset('CD')->related_resultset('tracks')->delete;
375c84bb 15
37b9b05b 16is $cd->tracks->count, 0, 'No tracks';
375c84bb 17
37b9b05b 18$cd->create_related('tracks', { title => "t_$_", position => $_ })
19 for (4,2,3,1,5);
20
21is $cd->tracks->count, 5, 'Created 5 tracks';
22
23# a txn should force the implicit pos reload, regardless of order
24$schema->txn_do(sub {
25 $cd->tracks->delete_all
26});
27
28is $cd->tracks->count, 0, 'Successfully deleted everything';
375c84bb 29
30done_testing;