@@ -128,6 +128,10 @@ public function testCanGetNoPrefixList() {
128128 * @depends testCanPutKey
129129 */
130130 public function testCanGetPrefixList () {
131+ /** @var \DCarbone\PHPConsulAPI\KV\KVPair[] $list */
132+ /** @var \DCarbone\PHPConsulAPI\QueryMeta $qm */
133+ /** @var \DCarbone\PHPConsulAPI\Error $err */
134+
131135 $ client = new KVClient (new Config ());
132136 $ client ->put (new KVPair (['Key ' => self ::KVPrefix . '/ ' . self ::KVKey1, 'Value ' => self ::KVValue1]));
133137 $ client ->put (new KVPair (['Key ' => self ::KVPrefix . '/ ' . self ::KVKey2, 'Value ' => self ::KVValue2]));
@@ -138,5 +142,32 @@ public function testCanGetPrefixList() {
138142 $ this ->assertInstanceOf (QueryMeta::class, $ qm );
139143 $ this ->assertInternalType ('array ' , $ list );
140144 $ this ->assertCount (3 , $ list );
145+ $ this ->assertContainsOnlyInstancesOf (KVPair::class, $ list );
146+
147+ $ key1found = false ;
148+ $ key2found = false ;
149+ $ key3found = false ;
150+
151+ foreach ($ list as $ kv ) {
152+ if (self ::KVValue1 === $ kv ->Value ) {
153+ $ key1found = true ;
154+ } else if (self ::KVValue2 === $ kv ->Value ) {
155+ $ key2found = true ;
156+ } else if (self ::KVValue3 === $ kv ->Value ) {
157+ $ key3found = true ;
158+ }
159+ }
160+
161+ try {
162+ $ this ->assertTrue ($ key1found , 'Key1 not found in list! ' );
163+ $ this ->assertTrue ($ key2found , 'Key2 not found in list! ' );
164+ $ this ->assertTrue ($ key3found , 'Key3 not found in list! ' );
165+ } catch (\PHPUnit_Framework_AssertionFailedError $ e ) {
166+ echo "\n\$list value: \n" ;
167+ var_dump ($ list );
168+ echo "\n" ;
169+
170+ throw $ e ;
171+ }
141172 }
142173}
0 commit comments