Skip to content

Commit

Permalink
Update tests to use VbcConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mheap committed May 3, 2019
1 parent 2fe13b8 commit 68a1d51
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,22 @@ public function jsonSerialize()
}

// Handle VBC specifically
if ($this->vbcConfig->isEnabled()) {
if ($this->getVbcConfig()->isEnabled()) {
$capabilities['vbc'] = new \StdClass;
}

// Workaround API bug. It expects an object and throws 500
// if it gets an array
if (!count($capabilities)) {
$capabilities = (object) $capabilities;
}

return [
'name' => $this->getName(),
'keys' => [
'public_key' => $this->getPublicKey()
],
'capabilities' => (object) $capabilities
'capabilities' => $capabilities
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Application/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected function createFromArrayV1($array) {

// VBC
if (isset($array['vbc']) && $array['vbc']) {
$application->enableVbc();
$application->getVbcConfig()->enable();
}

return $application;
Expand Down Expand Up @@ -303,7 +303,7 @@ protected function createFromArrayV2($array) {

// Handle VBC
if (isset($capabilities['vbc'])) {
$application->enableVbc();
$application->getVbcConfig()->enable();
}

return $application;
Expand Down
2 changes: 1 addition & 1 deletion test/Application/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testResponseSetsRtcConfigs()
public function testResponseSetsVbcConfigs()
{
$this->app->setResponse($this->getResponse());
$this->assertEquals(true, $this->app->isVbcEnabled());
$this->assertEquals(true, $this->app->getVbcConfig()->isEnabled());
}

public function testCanGetDirtyValues()
Expand Down
2 changes: 1 addition & 1 deletion test/Application/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function createApplication()
$application->getMessagesConfig()->setWebhook(MessagesConfig::INBOUND, 'https://example.com/inbound', 'POST');
$application->getRtcConfig()->setWebhook(RtcConfig::EVENT, 'https://example.com/event', 'POST');
$application->setPublicKey('-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCA\nKOxjsU4pf/sMFi9N0jqcSLcjxu33G\nd/vynKnlw9SENi+UZR44GdjGdmfm1\ntL1eA7IBh2HNnkYXnAwYzKJoa4eO3\n0kYWekeIZawIwe/g9faFgkev+1xsO\nOUNhPx2LhuLmgwWSRS4L5W851Xe3f\nUQIDAQAB\n-----END PUBLIC KEY-----\n');
$application->enableVbc();
$application->getVbcConfig()->enable();

$rawV1 = [
'name' => 'test application',
Expand Down

0 comments on commit 68a1d51

Please sign in to comment.