From 4f52cfffd12fb0c95e0c5f88699bd1d54e46289a Mon Sep 17 00:00:00 2001 From: Mark Hofstetter Date: Mon, 6 May 2024 22:04:59 +0200 Subject: [PATCH] Bug 36607: [discuss] setup and teardown patron --- .../integration/DataTestSetupTeardown_spec.ts | 2 ++ t/cypress/support/cypress_builder.pl | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/t/cypress/integration/DataTestSetupTeardown_spec.ts b/t/cypress/integration/DataTestSetupTeardown_spec.ts index 7aef9470f7..a4fbfc43e9 100644 --- a/t/cypress/integration/DataTestSetupTeardown_spec.ts +++ b/t/cypress/integration/DataTestSetupTeardown_spec.ts @@ -29,10 +29,12 @@ describe("Test data", () => { expect(result[0].surname).to.equal(testPatronData.surname); }); + /* cy.buildObject("Koha::Patrons", testPatronData, "teardown"); cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { expect(result[0].count).to.equal(patron_count); }); + */ }); }); diff --git a/t/cypress/support/cypress_builder.pl b/t/cypress/support/cypress_builder.pl index 73c07f0e71..a1bffa71b4 100644 --- a/t/cypress/support/cypress_builder.pl +++ b/t/cypress/support/cypress_builder.pl @@ -24,17 +24,30 @@ use JSON qw( decode_json ); use Getopt::Long; use Koha::Patrons; use Koha::Libraries; +use Koha::Patron::Category; my %data; my $class; my $teardown; +=head1 DESCRIPTION + +creates/deletes Koha Objects via command line, for each object to create an id has to be provided + +create: +perl t/cypress/support/cypress_builder.pl --class Koha::Patrons --data cardnumber=999 --data firstname=Mark + +teardown: +perl t/cypress/support/cypress_builder.pl --class Koha::Patrons --data cardnumber=999 --data firstname=Mark --teardown + +=cut + GetOptions( "data=s" => \%data, "class=s" => \$class, "teardown" => \$teardown); my $builder = t::lib::TestBuilder->new; my $objects = { - "Koha::Patrons" => { id => 'cardnumber', teardown => 'patron_delete', source => 'Borrower'}, + "Koha::Patrons" => { id => 'cardnumber', teardown => 'patron_delete',}, }; die unless $data{$objects->{$class}->{id}}; @@ -54,4 +67,5 @@ sub patron_delete { $builder->delete({ source => 'Borrower', records => $patron}); $builder->delete({ source => 'Branch', records => $branch}); + $builder->delete({ source => 'Category', records => $patron->category}); } \ No newline at end of file -- 2.39.2