|
Lines 2021-2027
subtest 'anonymize' => sub {
Link Here
|
| 2021 |
$schema->storage->txn_rollback; |
2021 |
$schema->storage->txn_rollback; |
| 2022 |
|
2022 |
|
| 2023 |
subtest 'extended_attributes' => sub { |
2023 |
subtest 'extended_attributes' => sub { |
| 2024 |
plan tests => 10; |
2024 |
plan tests => 11; |
| 2025 |
my $schema = Koha::Database->new->schema; |
2025 |
my $schema = Koha::Database->new->schema; |
| 2026 |
$schema->storage->txn_begin; |
2026 |
$schema->storage->txn_begin; |
| 2027 |
|
2027 |
|
|
Lines 2046-2051
subtest 'extended_attributes' => sub {
Link Here
|
| 2046 |
} |
2046 |
} |
| 2047 |
)->store; |
2047 |
)->store; |
| 2048 |
|
2048 |
|
|
|
2049 |
my $deleted_attribute_type = $builder->build_object({ class => 'Koha::Patron::Attribute::Types' }); |
| 2050 |
my $deleted_attribute_type_code = $deleted_attribute_type->code; |
| 2051 |
$deleted_attribute_type->delete; |
| 2052 |
|
| 2049 |
my $new_library = $builder->build( { source => 'Branch' } ); |
2053 |
my $new_library = $builder->build( { source => 'Branch' } ); |
| 2050 |
my $attribute_type_limited = Koha::Patron::Attribute::Type->new( |
2054 |
my $attribute_type_limited = Koha::Patron::Attribute::Type->new( |
| 2051 |
{ code => 'my code3', description => 'my description3' } )->store; |
2055 |
{ code => 'my code3', description => 'my description3' } )->store; |
|
Lines 2074-2079
subtest 'extended_attributes' => sub {
Link Here
|
| 2074 |
{ |
2078 |
{ |
| 2075 |
attribute => 'my attribute limited 2', |
2079 |
attribute => 'my attribute limited 2', |
| 2076 |
code => $attribute_type_limited->code(), |
2080 |
code => $attribute_type_limited->code(), |
|
|
2081 |
}, |
| 2082 |
{ |
| 2083 |
attribute => 'my nonexistent attribute 2', |
| 2084 |
code => $deleted_attribute_type_code, |
| 2077 |
} |
2085 |
} |
| 2078 |
]; |
2086 |
]; |
| 2079 |
|
2087 |
|
|
Lines 2084-2090
subtest 'extended_attributes' => sub {
Link Here
|
| 2084 |
$patron_1->extended_attributes->filter_by_branch_limitations->delete; |
2092 |
$patron_1->extended_attributes->filter_by_branch_limitations->delete; |
| 2085 |
$patron_2->extended_attributes->filter_by_branch_limitations->delete; |
2093 |
$patron_2->extended_attributes->filter_by_branch_limitations->delete; |
| 2086 |
$patron_1->extended_attributes($attributes_for_1); |
2094 |
$patron_1->extended_attributes($attributes_for_1); |
| 2087 |
$patron_2->extended_attributes($attributes_for_2); |
2095 |
|
|
|
2096 |
my $print_error = $schema->storage->dbh->{PrintError}; |
| 2097 |
$schema->storage->dbh->{PrintError} = 0; |
| 2098 |
warning_like { |
| 2099 |
$patron_2->extended_attributes($attributes_for_2); |
| 2100 |
} [ qr/a foreign key constraint fails/, qr/a foreign key constraint fails/ ], 'nonexistent attribute should have not exploded but print a warning'; |
| 2101 |
$schema->storage->dbh->{PrintError} = $print_error; |
| 2088 |
|
2102 |
|
| 2089 |
my $extended_attributes_for_1 = $patron_1->extended_attributes; |
2103 |
my $extended_attributes_for_1 = $patron_1->extended_attributes; |
| 2090 |
is( $extended_attributes_for_1->count, 3, 'There should be 3 attributes now for patron 1'); |
2104 |
is( $extended_attributes_for_1->count, 3, 'There should be 3 attributes now for patron 1'); |
| 2091 |
- |
|
|