Lines 33-39
my $builder = t::lib::TestBuilder->new;
Link Here
|
33 |
|
33 |
|
34 |
subtest 'store() tests' => sub { |
34 |
subtest 'store() tests' => sub { |
35 |
|
35 |
|
36 |
plan tests => 4; |
36 |
plan tests => 5; |
37 |
|
37 |
|
38 |
subtest 'repeatable attributes tests' => sub { |
38 |
subtest 'repeatable attributes tests' => sub { |
39 |
|
39 |
|
Lines 106-111
subtest 'store() tests' => sub {
Link Here
|
106 |
$schema->storage->txn_rollback; |
106 |
$schema->storage->txn_rollback; |
107 |
}; |
107 |
}; |
108 |
|
108 |
|
|
|
109 |
subtest 'is_date attributes tests' => sub { |
110 |
plan tests => 2; |
111 |
|
112 |
$schema->storage->txn_begin; |
113 |
|
114 |
my $patron = $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
115 |
my $attribute_type_1 = $builder->build( |
116 |
{ source => 'BorrowerAttributeType', |
117 |
value => { is_date => 1 } |
118 |
} |
119 |
); |
120 |
|
121 |
throws_ok { |
122 |
Koha::Patron::Attribute->new( |
123 |
{ borrowernumber => $patron, |
124 |
code => $attribute_type_1->{code}, |
125 |
attribute => 'not_a_date' |
126 |
} |
127 |
)->store; |
128 |
} |
129 |
'Koha::Exceptions::Patron::Attribute::InvalidAttributeValue', |
130 |
'Exception thrown trying to store a date attribute with non-date value'; |
131 |
|
132 |
is( |
133 |
"$@", |
134 |
"Tried to use an invalid value for attribute type. type=" |
135 |
. $attribute_type_1->{code} |
136 |
. " value=not_a_date", |
137 |
'Exception stringified correctly, attribute passed correctly' |
138 |
); |
139 |
|
140 |
Koha::Patron::Attribute->new( |
141 |
{ borrowernumber => $patron, |
142 |
code => $attribute_type_1->{code}, |
143 |
attribute => '2024-03-04' |
144 |
} |
145 |
)->store; |
146 |
|
147 |
my $attr_count |
148 |
= Koha::Patron::Attributes->search( |
149 |
{ borrowernumber => $patron, code => $attribute_type_1->{code} } ) |
150 |
->count; |
151 |
is( $attr_count, 1, |
152 |
'1 date attribute stored and retrieved correctly' ); |
153 |
|
154 |
$schema->storage->txn_rollback; |
155 |
}; |
156 |
|
109 |
subtest 'unique_id attributes tests' => sub { |
157 |
subtest 'unique_id attributes tests' => sub { |
110 |
|
158 |
|
111 |
plan tests => 5; |
159 |
plan tests => 5; |
112 |
- |
|
|