From 17faa35f27fe9655c241cbcfa2a01fad1dd8f004 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 Mar 2008 00:11:10 +0000 Subject: [PATCH] coverage tests for AddressBook update --- t/Shop/AddressBook.t | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/t/Shop/AddressBook.t b/t/Shop/AddressBook.t index 8181bddf3..7ead6a085 100644 --- a/t/Shop/AddressBook.t +++ b/t/Shop/AddressBook.t @@ -31,7 +31,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 20; +my $tests = 22; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -161,18 +161,47 @@ cmp_deeply( 'getAddresses returns all address objects for this book' ); +####################################################################### +# +# update +# +####################################################################### + +$book->update({ lastShipId => $address1->getId, lastPayId => $address2->getId}); + +cmp_deeply( + $book->get(), + { + userId => ignore, + sessionId => ignore, + addressBookId => ignore, + lastShipId => $address1->getId, + lastPayId => $address2->getId, + }, + 'update updates the object properties cache' +); + +my $bookClone = WebGUI::Shop::AddressBook->new($session, $book->getId); + +cmp_deeply( + $bookClone, + $book, + 'update updates the db, too' +); + ####################################################################### # # delete # ####################################################################### -$book->delete(); +$bookClone->delete(); $bookCount = $session->db->quickScalar('select count(*) from addressBook'); my $addrCount = $session->db->quickScalar('select count(*) from address'); is($bookCount, 0, 'delete: book deleted'); is($addrCount, 0, 'delete: also deletes addresses in the book'); +undef $book; }