Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
22 |
use Test::More tests => 8; |
22 |
use Test::More tests => 9; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use Koha::Database; |
25 |
use Koha::Database; |
Lines 144-149
subtest 'fk_constraint_deletion_translation' => sub {
Link Here
|
144 |
$schema->storage->txn_rollback; |
144 |
$schema->storage->txn_rollback; |
145 |
}; |
145 |
}; |
146 |
|
146 |
|
|
|
147 |
subtest 'enum_truncation_with_object_value' => sub { |
148 |
plan tests => 2; |
149 |
|
150 |
$schema->storage->txn_begin; |
151 |
|
152 |
# Create a mock object with a property accessor |
153 |
my $mock_object = bless { test_enum => 'invalid_value' }, 'TestObject'; |
154 |
|
155 |
# Add the can method to simulate a real object |
156 |
{ |
157 |
no strict 'refs'; |
158 |
*{"TestObject::can"} = sub { |
159 |
my ( $self, $method ) = @_; |
160 |
return $method eq 'test_enum' ? sub { return $self->{test_enum} } : undef; |
161 |
}; |
162 |
*{"TestObject::test_enum"} = sub { return $_[0]->{test_enum} }; |
163 |
} |
164 |
|
165 |
# Create a mock DBIx::Class::Exception for enum data truncation |
166 |
my $exception = bless { msg => "Data truncated for column 'test_enum'" }, 'DBIx::Class::Exception'; |
167 |
|
168 |
# Mock column info with enum type |
169 |
my $columns_info = { test_enum => { data_type => 'enum' } }; |
170 |
|
171 |
# Test with object - should include the actual value |
172 |
throws_ok { |
173 |
Koha::Schema::Util::ExceptionTranslator->translate_exception( $exception, $columns_info, $mock_object ); |
174 |
} |
175 |
'Koha::Exceptions::Object::BadValue', 'Enum truncation with object throws BadValue exception'; |
176 |
|
177 |
# Test without object - should use default value |
178 |
throws_ok { |
179 |
Koha::Schema::Util::ExceptionTranslator->translate_exception( $exception, $columns_info ); |
180 |
} |
181 |
'Koha::Exceptions::Object::BadValue', 'Enum truncation without object throws BadValue exception'; |
182 |
|
183 |
$schema->storage->txn_rollback; |
184 |
}; |
185 |
|
147 |
subtest 'schema_safe_do_method' => sub { |
186 |
subtest 'schema_safe_do_method' => sub { |
148 |
plan tests => 2; |
187 |
plan tests => 2; |
149 |
|
188 |
|
150 |
- |
|
|