]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/object.t
Add maintenance methods
[chaz/p5-File-KDBX] / t / object.t
index ff46cf80b3cdd7779ce32832dca7d50df869138a..d3e766d26d5d402cc665cdba9540c88a88da877a 100644 (file)
@@ -17,13 +17,13 @@ subtest 'Cloning' => sub {
     my $entry = File::KDBX::Entry->new;
 
     my $copy = $entry->clone;
-    like exception { $copy->kdbx }, qr/disassociated/, 'Disassociated entry copy is also disassociated';
-    cmp_deeply $copy, $entry, 'Disassociated entry and its clone are identical';
+    like exception { $copy->kdbx }, qr/disconnected/, 'Disconnected entry copy is also disconnectedisconnected';
+    cmp_deeply $copy, $entry, 'Disconnected entry and its clone are identical';
 
     $entry->kdbx($kdbx);
     $copy = $entry->clone;
-    is $entry->kdbx, $copy->kdbx, 'Associated entry copy is also associated';
-    cmp_deeply $copy, $entry, 'Associated entry and its clone are identical';
+    is $entry->kdbx, $copy->kdbx, 'Connected entry copy is also connected';
+    cmp_deeply $copy, $entry, 'Connected entry and its clone are identical';
 
     my $txn = $entry->begin_work;
     $entry->title('foo');
@@ -44,26 +44,27 @@ subtest 'Cloning' => sub {
     $copy = $entry->clone(reference_username => 1);
     my $ref = sprintf('{REF:U@I:%s}', format_uuid($entry->uuid));
     is $copy->username, $ref, 'Copy has username reference';
-    is $copy->expanded_username, $ref, 'Entry copy does not expand username because entry is not in database';
+    is $copy->expand_username, $ref, 'Entry copy does not expand username because entry is not in database';
 
     my $group = $kdbx->add_group(label => 'Passwords');
     $group->add_entry($entry);
-    is $copy->expanded_username, $entry->username,
+    is $copy->expand_username, $entry->username,
         'Entry in database and its copy with username ref have same expanded username';
 
     $copy = $entry->clone;
-    is @{$kdbx->all_entries}, 1, 'Still only one entry after cloning';
+    is $kdbx->entries->size, 1, 'Still only one entry after cloning';
 
     $copy = $entry->clone(parent => 1);
-    is @{$kdbx->all_entries}, 2, 'New copy added to database if clone with parent option';
-    my ($e1, $e2) = @{$kdbx->all_entries};
+    is $kdbx->entries->size, 2, 'New copy added to database if clone with parent option';
+    my ($e1, $e2) = $kdbx->entries->each;
     isnt $e1, $e2, 'Entry and its copy in the database are different objects';
     is $e1->title, $e2->title, 'Entry copy has the same title as the original entry';
 
     $copy = $entry->clone(parent => 1, relabel => 1);
-    is @{$kdbx->all_entries}, 3, 'New copy added to database if clone with parent option';
-    is $kdbx->all_entries->[2], $copy, 'New copy and new entry in the database match';
-    is $kdbx->all_entries->[2]->title, "foo - Copy", 'New copy has a modified title';
+    is $kdbx->entries->size, 3, 'New copy added to database if clone with parent option';
+    my $e3 = $kdbx->entries->skip(2)->next;
+    is $e3, $copy, 'New copy and new entry in the database match';
+    is $e3->title, 'foo - Copy', 'New copy has a modified title';
 
     $copy = $group->clone;
     cmp_deeply $copy, $group, 'Group and its clone are identical';
@@ -80,10 +81,10 @@ subtest 'Cloning' => sub {
 
     $copy = $group->clone(relabel => 1);
     is $copy->name, 'Passwords - Copy', 'Group copy relabeled from the original title';
-    is @{$kdbx->all_entries}, 3, 'No new entries were added to the database';
+    is $kdbx->entries->size, 3, 'No new entries were added to the database';
 
     $copy = $group->clone(relabel => 1, parent => 1);
-    is @{$kdbx->all_entries}, 6, 'Copy a group within parent doubles the number of entries in the database';
+    is $kdbx->entries->size, 6, 'Copy a group within parent doubles the number of entries in the database';
     isnt $group->entries->[0]->uuid, $copy->entries->[0]->uuid,
         'First entry in group and its copy are different';
 };
This page took 0.02333 seconds and 4 git commands to generate.