PHP code example of italix / testing

1. Go to this page and download the library: Download italix/testing 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/ */

    

italix / testing example snippets


use Italix\Mvc\Engine;
use function Italix\Testing\{ix_client, suite, test, summary};

suite('Acme — routes, auth and CSRF');

$config = run

$client = ix_client((new Engine($config))->pipeline());

$res = $client->as(['admin_id' => 1])->get('/it/admin/customers/index.html');

test('the list renders',      $res->status() === 200);
test('the customer is there', $res->contains('Rossi'));
test('nobody else\'s is',    !$res->contains('Bianchi'));

$admin = $client->as(['admin_id' => 1]);
$admin->post('/it/admin/customers/new/edit.html', [...]);  // writes a flash
$admin->get('/it/admin/customers/index.html');              // sees it

$client->post('/it/admin/logout');                 // 419 — no token
$client->with_csrf()->post('/it/admin/logout');    // passes the check

use function Italix\Testing\{factory, writer, in_rollback};

$w = writer($dm->get_connection());

$customer = factory(Customer::table(), $w)
    ->with(['last_name' => 'Rossi', 'tenant_id' => $tenant_id])
    ->create();

in_rollback($pdo, static function () use ($dm, $client): void {
    // every INSERT here disappears when the closure returns
});

use function Italix\Testing\{suite, section, test, summary};

suite('Italix Encode — Html');
section('attributes');
test('a bad name is refused', $threw, 'expected TestingException');
exit(summary());          // 0 clean, 1 failures

final class ItalixSuites extends \Italix\Testing\PhpunitSuite
{
    public static function suite_patterns(): array
    {
        return [__DIR__ . '/../src/Libs/Italix/*/tests/*Test.php'];
    }
}
bash
php src/Libs/Italix/Testing/tests/ClientTest.php
php src/Libs/Italix/Testing/tests/FactoryTest.php
bash
ITALIX_JUNIT=build/junit php src/Libs/Italix/I18n/tests/I18nTest.php
ix test --junit=build/junit