Skip to content

Commit 007e59f

Browse files
committed
Adding "KV::valueList" test
- Travis now specifically uses dist config
1 parent 50049e2 commit 007e59f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ install:
2222
- composer install --no-interaction --no-progress --no-suggest --optimize-autoloader
2323

2424
script:
25-
- ./vendor/bin/phpunit
25+
- ./vendor/bin/phpunit -c phpunit.xml.dist

tests/Usage/KV/KVClientUsageTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)