| Lines 19-26
          
      
      
        Link Here | 
        
          | 19 |  | 19 |  | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 7; | 22 | use Test::More tests => 8; | 
            
              | 23 |  |  |  | 
        
          | 24 | use t::lib::Mocks; | 23 | use t::lib::Mocks; | 
        
          | 25 | use t::lib::TestBuilder; | 24 | use t::lib::TestBuilder; | 
        
          | 26 |  | 25 |  | 
  
    | Lines 187-192
          subtest 'Add preferences from defaults' => sub {
      
      
        Link Here | 
        
          | 187 |     $schema->storage->txn_rollback; | 186 |     $schema->storage->txn_rollback; | 
        
          | 188 | }; | 187 | }; | 
        
          | 189 |  | 188 |  | 
            
              |  |  | 189 | subtest 'Test action logging' => sub { | 
            
              | 190 |     plan tests => 8; | 
            
              | 191 |  | 
            
              | 192 |     $schema->storage->txn_begin; | 
            
              | 193 |  | 
            
              | 194 |     t::lib::Mocks::mock_preference('BorrowersLog', 1); | 
            
              | 195 |  | 
            
              | 196 |     my $patron = build_a_test_patron(); | 
            
              | 197 |     my ($default, $mtt1, $mtt2) = build_a_test_category_preference({ | 
            
              | 198 |         patron => $patron, | 
            
              | 199 |     }); | 
            
              | 200 |     Koha::Patron::Message::Preference->new_from_default({ | 
            
              | 201 |         borrowernumber       => $patron->borrowernumber, | 
            
              | 202 |         categorycode         => $patron->categorycode, | 
            
              | 203 |         message_attribute_id => $default->message_attribute_id, | 
            
              | 204 |     })->store; | 
            
              | 205 |     my $pref = Koha::Patron::Message::Preferences->find({ | 
            
              | 206 |         borrowernumber       => $patron->borrowernumber, | 
            
              | 207 |         message_attribute_id => $default->message_attribute_id, | 
            
              | 208 |     }); | 
            
              | 209 |  | 
            
              | 210 |     my $actionLog = []; | 
            
              | 211 |     $pref->push_to_action_log_buffer($actionLog); | 
            
              | 212 |     is(ref($actionLog), 'ARRAY', 'Action log is an array'); | 
            
              | 213 |     is(@{$actionLog}, 1, 'One element in action log'); | 
            
              | 214 |     is($actionLog->[0]->{_name}, $pref->message_name, 'Correct message name'); | 
            
              | 215 |     is(@{$actionLog->[0]->{mtt}}, keys %{$pref->message_transport_types}, | 
            
              | 216 |        'Correct mtts'); | 
            
              | 217 |  | 
            
              | 218 |     # Let's push it another time for the lulz | 
            
              | 219 |     $pref->push_to_action_log_buffer($actionLog); | 
            
              | 220 |     is(@{$actionLog}, 2, 'Two elements in action log'); | 
            
              | 221 |  | 
            
              | 222 |     $pref->store_action_log_buffer($actionLog, $patron->borrowernumber); | 
            
              | 223 |     my $logs = C4::Log::GetLogs("","","",["MEMBERS"],["MOD MTT"], | 
            
              | 224 |         $patron->borrowernumber,""); | 
            
              | 225 |     is($logs->[0]->{action}, 'MOD MTT', 'Correct log action'); | 
            
              | 226 |     is($logs->[0]->{object}, $patron->borrowernumber, 'Correct borrowernumber'); | 
            
              | 227 |  | 
            
              | 228 |     # Test empty action log buffer | 
            
              | 229 |     my $patron2 = build_a_test_patron(); | 
            
              | 230 |     $pref->store_action_log_buffer([], $patron2->borrowernumber); | 
            
              | 231 |     $logs = C4::Log::GetLogs("","","",["MEMBERS"],["MOD MTT"], | 
            
              | 232 |         $patron2->borrowernumber,""); | 
            
              | 233 |     is($logs->[0]->{info}, 'All message_transport_types removed', 'All message_transport_types removed'); | 
            
              | 234 |  | 
            
              | 235 |     $schema->storage->txn_rollback; | 
            
              | 236 | }; | 
            
              | 237 |  | 
        
          | 190 | subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub { | 238 | subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub { | 
        
          | 191 |     plan tests => 4; | 239 |     plan tests => 4; | 
        
          | 192 |  | 240 |  | 
            
              | 193 | -  |  |  |