Skip to content

Commit

Permalink
Test entries, groups and passwords iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jul 16, 2016
1 parent 4d658fa commit 5224d4d
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion src/test/php/info/keepass/unittest/GroupTest.class.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
<?php namespace info\keepass\unittest;

use info\keepass\Group;
use info\keepass\Entry;
use info\keepass\ProtectedValue;
use util\UUID;

class GroupTest extends \unittest\TestCase {
private $group;
private $entry, $child, $group;

/** @return void */
public function setUp() {
$this->entry= [
'UUID' => 'fZhlFzAGRU24qsKpoxQ2Lg==',
'IconID' => '42',
'ForegroundColor' => null,
'BackgroundColor' => null,
'OverrideURL' => null,
'Tags' => null,
'Times' => '',
'String' => [
'Notes' => null,
'Password' => new ProtectedValue("\323\$c", "\274J\006"),
'Title' => 'Entry #1',
'URL' => null,
'UserName' => null
]
];
$this->child= [
'UUID' => 'G73VLfHwkU+do8hF9gmofQ==',
'Name' => 'Child',
'Notes' => null,
'IconID' => '48',
'Times' => '',
'IsExpanded' => 'False',
'DefaultAutoTypeSequence' => null,
'EnableAutoType' => 'null',
'EnableSearching' => 'null',
'LastTopVisibleEntry' => 'AAAAAAAAAAAAAAAAAAAAAA==',
];
$this->group= [
'UUID' => 'Vy28plCgw0u5Y0PtP2c/2Q==',
'Name' => 'Test',
Expand All @@ -19,6 +49,12 @@ public function setUp() {
'EnableAutoType' => 'null',
'EnableSearching' => 'null',
'LastTopVisibleEntry' => 'AAAAAAAAAAAAAAAAAAAAAA==',
'Entry' => [
'fZhlFzAGRU24qsKpoxQ2Lg==' => $this->entry
],
'Group' => [
'G73VLfHwkU+do8hF9gmofQ==' => $this->child
]
];
}

Expand Down Expand Up @@ -51,5 +87,29 @@ public function notes() {
public function icon_field() {
$this->assertEquals('48', (new Group($this->group, '/Test'))->field('IconID'));
}

#[@test]
public function entries() {
$this->assertEquals(
['7d986517-3006-454d-b8aa-c2a9a314362e' => new Entry($this->entry, '/Test/Entry #1')],
iterator_to_array((new Group($this->group, '/Test'))->entries())
);
}

#[@test]
public function groups() {
$this->assertEquals(
['1bbdd52d-f1f0-914f-9da3-c845f609a87d' => new Group($this->child, '/Test/Child')],
iterator_to_array((new Group($this->group, '/Test'))->groups())
);
}

#[@test]
public function passwords() {
$this->assertEquals(
['/Test/Entry #1' => new ProtectedValue("\323\$c", "\274J\006")],
iterator_to_array((new Group($this->group, '/Test'))->passwords())
);
}
}

0 comments on commit 5224d4d

Please sign in to comment.