Skip to content

Commit

Permalink
Merge pull request #120 from npadilla/BIG-15711
Browse files Browse the repository at this point in the history
BIG-15711: Add delete all functionality for products, categories, & bran...
  • Loading branch information
aleachjr committed Feb 26, 2015
2 parents 87c0638 + 76fd295 commit d45fcb0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/Bigcommerce/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,16 @@ public static function deleteProduct($id)
return self::deleteResource('/products/' . $id);
}

/**
* Delete all products.
*
* @return hash|bool|mixed
*/
public static function deleteAllProducts()
{
return self::deleteResource('/products');
}

/**
* Return the collection of options.
*
Expand Down Expand Up @@ -635,6 +645,16 @@ public static function deleteCategory($id)
return self::deleteResource('/categories/' . $id);
}

/**
* Delete all categories.
*
* @return hash|bool|mixed
*/
public static function deleteAllCategories($id)
{
return self::deleteResource('/categories');
}

/**
* The collection of brands.
*
Expand Down Expand Up @@ -704,6 +724,16 @@ public static function deleteBrand($id)
return self::deleteResource('/brands/' . $id);
}

/**
* Delete all brands.
*
* @return hash|bool|mixed
*/
public static function deleteAllBrands()
{
return self::deleteResource('/brands');
}

/**
* The collection of orders.
*
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/Api/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ public function testDeleteResourceDeletesToTheRightPlace()
$this->connection->expects($this->once())
->method('delete')
->with('http://storeurl/api/v2/whatever')
->will($this->returnValue(5));
->will($this->returnValue("Successfully deleted"));

Client::configure(array('store_url' => 'http://storeurl/', 'username' => 'whatever', 'api_key' => 'whatever'));
Client::setConnection($this->connection); // re-set the connection since Client::configure unsets it
$result = Client::deleteResource('/whatever');
$this->assertSame(5, $result);
$this->assertSame("Successfully deleted", $result);
}

public function testGetTimeReturnsTheExpectedTime()
Expand Down

0 comments on commit d45fcb0

Please sign in to comment.