Skip to content

Commit

Permalink
Ramp up - Add tests for Products Delete API (facebook#2865)
Browse files Browse the repository at this point in the history
Summary:
### Changes proposed in this Pull Request:
- Adding simple Request and Response tests to the Products Delete API to increase code coverage and as a ramp-up work item for getting used to the dev flow in this repository

- [x] Do the changed files pass `phpcs` checks? Please remove `phpcs:ignore` comments in changed files and fix any issues, or delete if not practical.

Pull Request resolved: facebook#2865

Test Plan: - `phpunit tests/Unit/Api/ProductCatalog/Products/Delete`

Reviewed By: jczhuoMeta, vinkmeta

Differential Revision: D68915742

Pulled By: carterbuce

fbshipit-source-id: d7fb475ccc1f0c24632e8579d56feb5cb4bc54d2
  • Loading branch information
carterbuce authored and gurtejrehal committed Feb 11, 2025
1 parent fdeed31 commit ae8cc5d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/Unit/Api/ProductCatalog/Products/Delete/RequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare( strict_types=1 );

namespace Api\ProductCatalog\Products\Delete;

use WooCommerce;
use WP_UnitTestCase;

/**
* Test cases for product delete API request
*/
class RequestTest extends WP_UnitTestCase {
/**
* Tests request endpoint config
*
* @return void
*/
public function test_request() {
$product_group_id = 'facebook-product-group-id';
$request = new WooCommerce\Facebook\API\ProductCatalog\Products\Delete\Request( $product_group_id );

$this->assertEquals( 'DELETE', $request->get_method() );
$this->assertEquals( '/facebook-product-group-id', $request->get_path() );
}
}
25 changes: 25 additions & 0 deletions tests/Unit/Api/ProductCatalog/Products/Delete/ResponseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare( strict_types=1 );

namespace Api\ProductCatalog\Products\Delete;

use WooCommerce;
use WP_UnitTestCase;

/**
* Test cases for product delete API response
*/
class ResponseTest extends WP_UnitTestCase {
/**
* Tests response value
*
* @return void
*/
public function test_response() {
$json = '{"success":true}';
$response = new WooCommerce\Facebook\API\ProductCatalog\Products\Delete\Response( $json );

$this->assertTrue( $response->success );
}
}

0 comments on commit ae8cc5d

Please sign in to comment.