Lines 30-46
BEGIN {
Link Here
|
30 |
} |
30 |
} |
31 |
|
31 |
|
32 |
# Start transaction |
32 |
# Start transaction |
33 |
my $dbh = C4::Context->dbh; |
33 |
my $database = Koha::Database->new(); |
34 |
$dbh->{AutoCommit} = 0; |
34 |
my $schema = $database->schema(); |
35 |
$dbh->{RaiseError} = 1; |
35 |
$schema->storage->txn_begin(); |
36 |
$dbh->do("DELETE FROM issues"); |
36 |
|
37 |
$dbh->do("DELETE FROM borrowers"); |
37 |
$schema->resultset('Issue')->delete_all(); |
38 |
|
38 |
$schema->resultset('Borrower')->delete_all(); |
39 |
my $categorycode = |
39 |
|
40 |
Koha::Database->new()->schema()->resultset('Category')->first() |
40 |
my $categorycode = $schema->resultset('Category')->first()->categorycode(); |
41 |
->categorycode(); |
41 |
my $branchcode = $schema->resultset('Branch')->first()->branchcode(); |
42 |
my $branchcode = |
|
|
43 |
Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode(); |
44 |
|
42 |
|
45 |
my $b1 = Koha::Patron->new( |
43 |
my $b1 = Koha::Patron->new( |
46 |
{ |
44 |
{ |
Lines 50-55
my $b1 = Koha::Patron->new(
Link Here
|
50 |
} |
48 |
} |
51 |
); |
49 |
); |
52 |
$b1->store(); |
50 |
$b1->store(); |
|
|
51 |
my $now = dt_from_string; |
53 |
my $b2 = Koha::Patron->new( |
52 |
my $b2 = Koha::Patron->new( |
54 |
{ |
53 |
{ |
55 |
surname => 'Test 2', |
54 |
surname => 'Test 2', |
Lines 72-84
$b3->store();
Link Here
|
72 |
my $b1_new = Koha::Patrons->find( $b1->borrowernumber() ); |
71 |
my $b1_new = Koha::Patrons->find( $b1->borrowernumber() ); |
73 |
is( $b1->surname(), $b1_new->surname(), "Found matching patron" ); |
72 |
is( $b1->surname(), $b1_new->surname(), "Found matching patron" ); |
74 |
isnt( $b1_new->updated_on, undef, "borrowers.updated_on should be set" ); |
73 |
isnt( $b1_new->updated_on, undef, "borrowers.updated_on should be set" ); |
75 |
is( dt_from_string($b1_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on creating" ); |
74 |
is( dt_from_string($b1_new->updated_on), $now, "borrowers.updated_on should have been set to now on creating" ); |
76 |
|
75 |
|
77 |
my $b3_new = Koha::Patrons->find( $b3->borrowernumber() ); |
76 |
my $b3_new = Koha::Patrons->find( $b3->borrowernumber() ); |
78 |
is( dt_from_string($b3_new->updated_on), $three_days_ago, "borrowers.updated_on should have been kept to what we set on creating" ); |
77 |
is( dt_from_string($b3_new->updated_on), $three_days_ago, "borrowers.updated_on should have been kept to what we set on creating" ); |
79 |
$b3_new->set({ surname => 'another surname for Test 3' }); |
78 |
$b3_new->set({ firstname => 'Some first name for Test 3' })->store(); |
80 |
$b3_new = Koha::Patrons->find( $b3->borrowernumber() ); |
79 |
$b3_new = Koha::Patrons->find( $b3->borrowernumber() ); |
81 |
is( dt_from_string($b1_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on updating" ); |
80 |
is( dt_from_string($b3_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on updating" ); |
82 |
|
81 |
|
83 |
my @patrons = Koha::Patrons->search( { branchcode => $branchcode } ); |
82 |
my @patrons = Koha::Patrons->search( { branchcode => $branchcode } ); |
84 |
is( @patrons, 3, "Found 3 patrons with Search" ); |
83 |
is( @patrons, 3, "Found 3 patrons with Search" ); |
Lines 104-107
foreach my $b ( $patrons->as_list() ) {
Link Here
|
104 |
is( $b->categorycode(), $categorycode, "Iteration returns a patron object" ); |
103 |
is( $b->categorycode(), $categorycode, "Iteration returns a patron object" ); |
105 |
} |
104 |
} |
106 |
|
105 |
|
|
|
106 |
$schema->storage->txn_rollback(); |
107 |
|
107 |
1; |
108 |
1; |
108 |
- |
|
|