1. Go to this page and download the library: Download xpat/api-test-library 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/ */
xpat / api-test-library example snippets
#!/usr/bin/env php
declare(strict_types=1);
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Xpat\ApiTest\Attribute\Test;
use Xpat\ApiTest\FileSystem\ClassesByPath;
use Xpat\ApiTest\FileSystem\MethodsWithAttribute;
use Xpat\ApiTest\FileSystem\MethodsWithName;
use Xpat\ApiTest\FileSystem\PublicMethodsOfClasses;
use Xpat\ApiTest\FileSystem\SubClassesOf;
use Xpat\ApiTest\Output\ResultsOutput;
use Xpat\ApiTest\Test\ApiTestMethods;
use Xpat\ApiTest\Test\TestCase;
use Xpat\ApiTest\Test\TestingResults;
s
),
),
$method
),
Test::class
)
),
$container
)
)
)->print();
declare(strict_types=1);
namespace ApiTest\TestCase;
use Xpat\ApiTest\Attribute\Test;
use Xpat\ApiTest\Expectation\FieldEqualityExpectation;
use Xpat\ApiTest\Expectation\StatusCodeExpectation;
use Xpat\ApiTest\Test\ApiTest;
use Xpat\ApiTest\Test\ApiTestInterface;
use Xpat\ApiTest\Test\TestCase;
readonly class CategoryTest extends TestCase
{
#[Test]
public function expenseCategories(): ApiTestInterface
{
return new ApiTest(
$this->requestFactory->get('/expense-categories'),
[
new StatusCodeExpectation(200),
new FieldEqualityExpectation(
'0.name',
'Education'
),
]
);
}
#[Test]
public function someTest(): ApiTestInterface
{
return new ApiTest(
$this->requestFactory->get('/expense-categories'),
[
new StatusCodeExpectation(200),
new FieldEqualityExpectation(
'1.name',
'Grocery'
),
]
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.