Skip to content

Commit a03188a

Browse files
authored
Merge pull request #199 from CODESIGN2/webhooks
Webhooks
2 parents 172076c + 2c172f5 commit a03188a

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

src/Bigcommerce/Api/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ public static function updateOptionValue($optionId, $optionValueId, $object)
18961896
*/
18971897
public static function listWebhooks()
18981898
{
1899-
return self::getResource('/hooks');
1899+
return self::getCollection('/hooks');
19001900
}
19011901

19021902
/**

test/Unit/Api/ClientTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,53 @@ public function testDeletingAllGiftCertificatesDeletesToTheAllGiftCertificatesRe
841841

842842
Client::deleteAllGiftCertificates();
843843
}
844+
845+
846+
public function testGettingWebhooksReturnsAllWebhooks()
847+
{
848+
$this->connection->expects($this->once())
849+
->method('get')
850+
->with($this->basePath . '/hooks', false)
851+
->will($this->returnValue(array(new \Bigcommerce\Api\Resource(),new \Bigcommerce\Api\Resource())));
852+
$collection = Client::listWebhooks();
853+
$this->assertInternalType('array', $collection);
854+
foreach ($collection as $resource) {
855+
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
856+
}
857+
}
858+
859+
public function testGettingSpecifiedWebhookReturnsTheSpecifiedWebhook()
860+
{
861+
$this->connection->expects($this->once())
862+
->method('get')
863+
->with($this->basePath . '/hooks/1', false)
864+
->will($this->returnValue(new \Bigcommerce\Api\Resource()));
865+
$resource = Client::getWebhook(1);
866+
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
867+
}
868+
869+
public function testCreatingWebhookPostsToTheSpecifiedResource()
870+
{
871+
$this->connection->expects($this->once())
872+
->method('post')
873+
->with($this->basePath . '/hooks', (object)array());
874+
Client::createWebhook(array());
875+
}
876+
public function testUpdatingWebhookPutsToTheSpecifiedResource()
877+
{
878+
$this->connection->expects($this->once())
879+
->method('put')
880+
->with($this->basePath . '/hooks/1', (object)array());
881+
Client::updateWebhook(1, array());
882+
}
883+
884+
public function testDeleteWebhookDeletesToTheSpecifiedResource()
885+
{
886+
$this->connection->expects($this->once())
887+
->method('delete')
888+
->with($this->basePath . '/hooks/1');
889+
Client::deleteWebhook(1);
890+
}
844891

845892
public function testCreatingProductReviewPostsToTheProductReviewResource()
846893
{

0 commit comments

Comments
 (0)