View | Details | Raw Unified | Return to bug 14698
Collapse All | Expand All

(-)a/Koha/AtomicUpdater.pm (+19 lines)
Lines 130-135 sub addAtomicUpdate { Link Here
130
    return $atomicupdate;
130
    return $atomicupdate;
131
}
131
}
132
132
133
=head addAllAtomicUpdates
134
135
Gets all pending atomicupdates and marks them added. This is useful for installer
136
where we want to set all atomicupdates marked as applied to avoid applying them
137
after installation.
138
139
=cut
140
141
sub addAllAtomicUpdates {
142
    my ($self) = @_;
143
144
    my $atomicUpdates = $self->getPendingAtomicUpdates();
145
    foreach my $key (keys %$atomicUpdates) {
146
        $self->addAtomicUpdate($atomicUpdates->{$key}->unblessed);
147
    }
148
149
    return $atomicUpdates;
150
}
151
133
sub removeAtomicUpdate {
152
sub removeAtomicUpdate {
134
    my ($self, $issueId) = @_;
153
    my ($self, $issueId) = @_;
135
    print "Deleting atomicupdate '$issueId'\n" if $self->{verbose} > 2;
154
    print "Deleting atomicupdate '$issueId'\n" if $self->{verbose} > 2;
(-)a/installer/install.pl (+1 lines)
Lines 320-325 elsif ( $step && $step == 3 ) { Link Here
320
            "error" => $error,
320
            "error" => $error,
321
            "$op"   => 1,
321
            "$op"   => 1,
322
        );
322
        );
323
        Koha::AtomicUpdater->new->addAllAtomicUpdates();
323
    }
324
    }
324
    elsif ( $op && $op eq 'updatestructure' ) {
325
    elsif ( $op && $op eq 'updatestructure' ) {
325
        #
326
        #
(-)a/t/db_dependent/Koha/AtomicUpdater.t (-1 / +45 lines)
Lines 326-330 sub applySingleAtomicUpdateFromFile { Link Here
326
    t::lib::TestObjects::ObjectFactory->tearDownTestContext($subtestContext);
326
    t::lib::TestObjects::ObjectFactory->tearDownTestContext($subtestContext);
327
}
327
}
328
328
329
subtest 'Mark all atomicupdates as installed (for fresh installs), but do not'
330
       .' execute them' => \&addAllAtomicUpdates;
331
sub addAllAtomicUpdates {
332
    my $subtestContext = {};
333
    eval {
334
    my $files = t::lib::TestObjects::FileFactory->createTestGroup([
335
                        {
336
                            filepath => 'atomicupdate/',
337
                            filename => 'Bug_00001-First-update.pl',
338
                            content  => '$ENV{ATOMICUPDATE_TESTS_3}++;',
339
                        },
340
                        {
341
                            filepath => 'atomicupdate/',
342
                            filename => 'Bug_00002-Second-update.pl',
343
                            content  => '$ENV{ATOMICUPDATE_TESTS_3}++;',
344
                        },
345
                        ],
346
                        undef, $subtestContext, $testContext);
347
348
    my $atomicUpdater = Koha::AtomicUpdater->new({
349
            scriptDir => $files->{'Bug_00001-First-update.pl'}->dirname(),
350
    });
351
352
    $atomicUpdater->addAllAtomicUpdates;
353
    my $atomicUpdate = $atomicUpdater->find('Bug-00001');
354
    my $atomicUpdate2 = $atomicUpdater->find('Bug-00002');
355
    t::lib::TestObjects::AtomicUpdateFactory->addToContext($atomicUpdate, undef,
356
                                                $subtestContext, $testContext);
357
    t::lib::TestObjects::AtomicUpdateFactory->addToContext($atomicUpdate2, undef,
358
                                                $subtestContext, $testContext);
359
360
    is($atomicUpdate->filename,
361
       "Bug_00001-First-update.pl",
362
       "Bug_00001-First-update.pl added to DB");
363
    is($atomicUpdate2->filename,
364
       "Bug_00002-Second-update.pl",
365
       "Bug_00002-Second-update.pl added to DB");
366
    is($ENV{ATOMICUPDATE_TESTS_3}, undef, "However, updates were not executed.");
367
    };
368
    if ($@) {
369
        ok(0, $@);
370
    }
371
    t::lib::TestObjects::ObjectFactory->tearDownTestContext($subtestContext);
372
}
373
329
t::lib::TestObjects::ObjectFactory->tearDownTestContext($testContext);
374
t::lib::TestObjects::ObjectFactory->tearDownTestContext($testContext);
330
done_testing;
375
done_testing;
331
- 

Return to bug 14698