diff --git a/banaan.php b/banaan.php new file mode 100644 index 0000000..a0ed078 --- /dev/null +++ b/banaan.php @@ -0,0 +1,15 @@ +brancherApp->list('hntestgroot'); + +var_dump($active[0]['labels']); + +$result = $client->brancherApp->update('hntestgroot-ephx0u2z7', ['labels' => ['mykey='.time()]]); + +var_dump($result); \ No newline at end of file diff --git a/tests/unit/Service/BrancherAppTest.php b/tests/unit/Service/BrancherAppTest.php index a7d8310..309d4ca 100644 --- a/tests/unit/Service/BrancherAppTest.php +++ b/tests/unit/Service/BrancherAppTest.php @@ -183,6 +183,46 @@ public function testUpdateBrancherApp() ); } + public function testUpdateBrancherAppAppendsLabels() + { + $this->responses->append( + // List Brancher apps + new Response(200, [], json_encode([ + 'branchers' => [ + [ + 'name' => 'johndoe-eph123456', + 'labels' => ['key1' => 'value1'] + ] + ] + ])), + // Update Brancher app + new Response(200, [], json_encode([ + 'labels' => [ + 'key1' => 'value1', + 'key2' => 'value2', + ] + ])), + ); + + $result = $this->client->brancherApp->update( + 'johndoe-eph123456', ['labels' => ['key2=value2']], + true + ); + + $request = $this->responses->getLastRequest(); + $this->assertEquals('PUT', $request->getMethod()); + $this->assertEquals('/v2/brancher/johndoe-eph123456/', $request->getUri()); + $this->assertJson((string)$request->getBody()); + $this->assertEquals( + ['labels' => ['key2=value2', 'key1=value1']], + json_decode((string)$request->getBody(), true) + ); + $this->assertEquals( + ['labels' => [ 'key1' => 'value1', 'key2' => 'value2']], + $result + ); + } + public function testUpdateBrancherAppRaisesClientExceptions() { $badRequestResponse = new Response(400, [], json_encode([