Skip to content

Commit

Permalink
add: unit test for 2 new product api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin committed Jul 25, 2023
1 parent d5c19a4 commit 29f87d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/Resources/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,22 @@ public function testCategoryRecommended()
$this->caller->categoryRecommended('product name', 'description');
$this->assertPreviousRequest('POST', 'product/category_recommend');
}

public function testGetProductStock()
{
$this->caller->getProductStock();
$request = $this->assertPreviousRequest('POST', 'products/stock/list');
parse_str($request->getUri()->getQuery(), $query);
$this->assertArrayHasKey('version', $query);
$this->assertTrue(intval($query['version']) >= 202305);
}

public function testPrecheckForOperatingProduct()
{
$this->caller->precheckForOperatingProduct([]);
$request = $this->assertPreviousRequest('POST', 'product/pre_check');
parse_str($request->getUri()->getQuery(), $query);
$this->assertArrayHasKey('version', $query);
$this->assertTrue(intval($query['version']) >= 202306);
}
}
2 changes: 2 additions & 0 deletions tests/TestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ protected function assertPreviousRequest($method, $uri)
$request = array_pop(static::$container)['request'];
$this->assertEquals(strtolower($method), strtolower($request->getMethod()));
$this->assertEquals($uri, trim($request->getUri()->getPath(), '/'));

return $request;
}
}

0 comments on commit 29f87d8

Please sign in to comment.