sub txn_do {
my ($self, $coderef, @args) = @_;
- ref $self or $self->throw_exception('Cannot execute txn_do as a '.
- 'class method');
+ ref $self or $self->throw_exception
+ ('Cannot execute txn_do as a class method');
+ ref $coderef eq 'CODE' or $self->throw_exception
+ ('$coderef must be a CODE reference');
my (@return_values, $return_value);
sub run_tests {
my $schema = shift;
-plan tests => 37;
+plan tests => 39;
my $code = sub {
my ($artist, @cd_titles) = @_;
return $artist->cds->all;
};
+# Test checking of parameters
+{
+
+ eval {
+ (ref $schema)->txn_do(sub{});
+ };
+ like($@, qr/class method/, '$coderef parameter check ok');
+ eval {
+ $schema->txn_do('');
+ };
+ like($@, qr/must be a CODE reference/, '$coderef parameter check ok');
+}
+
# Test successful txn_do() - scalar context
{
my @titles = map {'txn_do test CD ' . $_} (1..5);