1. Go to this page and download the library: Download keboola/php-test-utils 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/ */
keboola / php-test-utils example snippets
use PHPUnit\Framework\TestCase;
use Keboola\PhpTestUtils\TestEnvVarsTrait;
final class MyEnvTest extends TestCase
{
use TestEnvVarsTrait;
public function testOptionalEnv(): void
{
$clientOptions = new ClientOptions(
url: new ServiceClient(self::getRequiredEnv('HOSTNAME_SUFFIX'))->getConnectionServiceUrl(),
token: self::getRequiredEnv('TEST_STORAGE_API_TOKEN_SNOWFLAKE'),
);
}
use PHPUnit\Framework\TestCase;
use Keboola\PhpTestUtils\AssertArrayPropertySameTrait;
use Keboola\PhpTestUtils\AssertObjectPropertyValueTrait;
final class MyAssertionsTest extends TestCase
{
use AssertArrayPropertySameTrait;
use AssertObjectPropertyValueTrait;
public function testHelpers(): void
{
// Assert nested array property value
$row = ['customer' => ['id' => 123, 'name' => 'Acme']];
self::assertArrayPropertySame(123, $row, 'customer.id');
// Assert (even private) object property value
$obj = new class() {
private string $token = 'abc';
};
self::assertObjectPropertyValue('abc', $obj, 'token');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.