$schema->storage->txn_begin;
- # Remove existing patrons
- Koha::Patrons->delete;
- my $provider = $builder->build_object( { class => 'Koha::Auth::Identity::Providers', value => { matchpoint => 'email' } } );
+ # generate a random patron
+ my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' });
+ my $userid = $patron_to_delete->userid;
+ # delete patron
+ $patron_to_delete->delete;
+
+ my $provider = $builder->build_object( { class => 'Koha::Auth::Identity::Providers', value => { matchpoint => 'email' } } );
+
my $domain_with_register = $builder->build_object(
- { class => 'Koha::Auth::Identity::Provider::Domains', value => { identity_provider_id => $provider->id, domain => 'domain1.com', auto_register => 1 } } );
+ { class => 'Koha::Auth::Identity::Provider::Domains',
+ value => { identity_provider_id => $provider->id, domain => 'domain1.com', auto_register => 1 }
+ }
+ );
+
my $domain_without_register = $builder->build_object(
- { class => 'Koha::Auth::Identity::Provider::Domains', value => { identity_provider_id => $provider->id, domain => 'domain2.com', auto_register => 0 } } );
+ { class => 'Koha::Auth::Identity::Provider::Domains',
+ value => { identity_provider_id => $provider->id, domain => 'domain2.com', auto_register => 0 }
+ }
+ );
+
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
my $category = $builder->build_object( { class => 'Koha::Patron::Categories' } );
+
my $user_data = {
firstname => 'test',
surname => 'test',
- userid => 'id1',
+ userid => $userid,
branchcode => $library->branchcode,
categorycode => $category->categorycode
};
$t->post_ok( '/register_user' => json => { data => $user_data, domain_id => $domain_without_register->identity_provider_domain_id, interface => 'opac' } )->status_is(401)
->json_has( '/message', 'unauthorized' );
+
$schema->storage->txn_rollback;
};
$schema->storage->txn_begin;
- # Remove existing patrons
- Koha::Patrons->delete;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $t = Test::Mojo->new;