Skip to content

Commit

Permalink
Merge pull request #199 from CODESIGN2/webhooks
Browse files Browse the repository at this point in the history
Webhooks
  • Loading branch information
zvuki authored May 5, 2017
2 parents 172076c + 2c172f5 commit a03188a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Bigcommerce/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ public static function updateOptionValue($optionId, $optionValueId, $object)
*/
public static function listWebhooks()
{
return self::getResource('/hooks');
return self::getCollection('/hooks');
}

/**
Expand Down
47 changes: 47 additions & 0 deletions test/Unit/Api/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,53 @@ public function testDeletingAllGiftCertificatesDeletesToTheAllGiftCertificatesRe

Client::deleteAllGiftCertificates();
}


public function testGettingWebhooksReturnsAllWebhooks()
{
$this->connection->expects($this->once())
->method('get')
->with($this->basePath . '/hooks', false)
->will($this->returnValue(array(new \Bigcommerce\Api\Resource(),new \Bigcommerce\Api\Resource())));
$collection = Client::listWebhooks();
$this->assertInternalType('array', $collection);
foreach ($collection as $resource) {
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
}
}

public function testGettingSpecifiedWebhookReturnsTheSpecifiedWebhook()
{
$this->connection->expects($this->once())
->method('get')
->with($this->basePath . '/hooks/1', false)
->will($this->returnValue(new \Bigcommerce\Api\Resource()));
$resource = Client::getWebhook(1);
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
}

public function testCreatingWebhookPostsToTheSpecifiedResource()
{
$this->connection->expects($this->once())
->method('post')
->with($this->basePath . '/hooks', (object)array());
Client::createWebhook(array());
}
public function testUpdatingWebhookPutsToTheSpecifiedResource()
{
$this->connection->expects($this->once())
->method('put')
->with($this->basePath . '/hooks/1', (object)array());
Client::updateWebhook(1, array());
}

public function testDeleteWebhookDeletesToTheSpecifiedResource()
{
$this->connection->expects($this->once())
->method('delete')
->with($this->basePath . '/hooks/1');
Client::deleteWebhook(1);
}

public function testCreatingProductReviewPostsToTheProductReviewResource()
{
Expand Down

0 comments on commit a03188a

Please sign in to comment.