| Lines 19-29
          
      
      
        Link Here | 
        
          | 19 |  | 19 |  | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 10; | 22 | use Test::More tests => 11; | 
        
          | 23 |  | 23 |  | 
        
          | 24 | use C4::Context; | 24 | use C4::Context; | 
            
              |  |  | 25 | use C4::Members::Messaging; | 
        
          | 25 | use Koha::Database; | 26 | use Koha::Database; | 
        
          | 26 | use Koha::DateUtils; | 27 | use Koha::DateUtils; | 
            
              |  |  | 28 | use Koha::Patron; | 
        
          | 27 | use Koha::Patron::Category; | 29 | use Koha::Patron::Category; | 
        
          | 28 | use Koha::Patron::Categories; | 30 | use Koha::Patron::Categories; | 
        
          | 29 | use t::lib::Dates; | 31 | use t::lib::Dates; | 
  
    | Lines 101-106
          subtest 'BlockExpiredPatronOpacActions' => sub {
      
      
        Link Here | 
        
          | 101 |     $category->delete; | 103 |     $category->delete; | 
        
          | 102 | }; | 104 | }; | 
        
          | 103 |  | 105 |  | 
            
              |  |  | 106 | subtest 'default_messaging tests' => sub { | 
            
              | 107 |     plan tests => 5; | 
            
              | 108 |  | 
            
              | 109 |     my $next_month = dt_from_string->add( months => 1 ); | 
            
              | 110 |     my $category = Koha::Patron::Category->new({ | 
            
              | 111 |         categorycode => 'my2ndcat', | 
            
              | 112 |         category_type => 'A', | 
            
              | 113 |         description  => 'mycatdesc', | 
            
              | 114 |         enrolmentperiod => undef, | 
            
              | 115 |         enrolmentperioddate => $next_month, | 
            
              | 116 |     })->store; | 
            
              | 117 |     my $attr = $builder->build({ source => 'MessageAttribute', }); | 
            
              | 118 |     my $transport = $builder->build({ | 
            
              | 119 |         source => 'MessageTransport', | 
            
              | 120 |         value => { | 
            
              | 121 |             message_attribute_id => $attr->{'message_attribute_id'}, | 
            
              | 122 |             message_transport_type => 'email', | 
            
              | 123 |             is_digest => 1, | 
            
              | 124 |         } | 
            
              | 125 |     }); | 
            
              | 126 |     C4::Members::Messaging::SetMessagingPreference({ | 
            
              | 127 |         categorycode            => $category->categorycode, | 
            
              | 128 |         message_attribute_id    => $attr->{'message_attribute_id'}, | 
            
              | 129 |         message_transport_types => [ qw( email ) ], | 
            
              | 130 |         days_in_advance         => 5, | 
            
              | 131 |         wants_digest            => 1 | 
            
              | 132 |     }); | 
            
              | 133 |     my $default_messaging = $category->default_messaging; | 
            
              | 134 |     is(@$default_messaging, 1, "One default messaging found."); | 
            
              | 135 |     $default_messaging = $default_messaging->[0]; | 
            
              | 136 |     is($default_messaging->{'message_attribute_id'}, $attr->{'message_attribute_id'}, "Default attribute id is correct."); | 
            
              | 137 |     is($default_messaging->{'message_name'}, $attr->{'message_name'}, "Default message_name is correct."); | 
            
              | 138 |     ok($default_messaging->{$attr->{'message_name'}}, "Found message_name as a key."); | 
            
              | 139 |     is($default_messaging->{'transports'}->[0]->{'transport'}, "email", "Email found as transport type"); | 
            
              | 140 |     $category->delete; # finally, delete the category in order not to fail last delete test | 
            
              | 141 | }; | 
            
              | 142 |  | 
        
          | 104 | $retrieved_category_1->delete; | 143 | $retrieved_category_1->delete; | 
        
          | 105 | is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' ); | 144 | is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' ); | 
        
          | 106 |  | 145 |  | 
            
              | 107 | -  |  |  |