1. Go to this page and download the library: Download digitalzenworks/api-test library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitalzenworks / api-test example snippets
use DigitalZenWorks\ApiTest\ApiTester;
final class UnitTests extends TestCase
{
#[Test]
public function ApiEndPointPostSuccess()
{
$data =
[
'name' => 'Somebody',
'email' => '[email protected]'
];
$apiTester = new APITester('https://httpbin.org');
$testOptions = new TestOptions();
$testOptions->tryBasicAsserts = false;
$response =
$this->apiTester->apiEndPointTest(
'POST', 'https://httpbin.org/post', $data, $testOptions);
$this->assertIsArray($response);
}
)
use DigitalZenWorks\ApiTest\PageTester;
final class UnitTests extends TestCase
{
#[Test]
public function SimplePage()
{
PageTester $pageTester =
new PageTester('https://httpbin.org', 'text/html', 'text/html');
$endPoint = 'https://httpbin.org/get';
$content = $pageTester->webPageTest('GET', $endPoint, null);
$this->assertNotNull($content);
$this->assertNotEmpty($content);
$this->assertStringContainsStringIgnoringCase(
'<!DOCTYPE html>', $content);
}
}