1. Go to this page and download the library: Download memran/php-testify 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/ */
declare(strict_types=1);
use function Testify\describe;
use function Testify\expect;
use function Testify\it;
describe('cart totals', function (): void {
it('adds line items', function (): void {
$items = [12, 8, 5];
expect(array_sum($items))->toBe(25);
expect($items)->toHaveLength(3);
});
});
declare(strict_types=1);
use function Testify\describe;
use function Testify\expect;
use function Testify\it;
describe('cart totals', function (): void {
it('adds line items', function (array $items, int $expected): void {
expect(array_sum($items))->toBe($expected);
})->with([
'two items' => [[12, 8], 20],
'three items' => [[12, 8, 5], 25],
])->group('cart', 'fast');
})->group('unit');
declare(strict_types=1);
use function Testify\beforeEach;
use function Testify\describe;
use function Testify\expect;
use function Testify\it;
describe('account state', function (): void {
$balance = 0;
beforeEach(function () use (&$balance): void {
$balance = 100;
});
it('withdraws funds', function () use (&$balance): void {
$balance -= 40;
expect($balance)->toBe(60);
expect($balance)->not()->toBe(100);
});
});
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class InvoiceCalculatorTest extends TestCase
{
public function testRoundsTaxAmount(): void
{
self::assertSame(13, (int) round(12.6));
}
}
declare(strict_types=1);
use function Testify\describe;
use function Testify\expect;
use function Testify\it;
describe('invoice presentation', function (): void {
it('contains a currency symbol', function (): void {
expect('$12.50')->toContain('$');
});
});
declare(strict_types=1);
use function Testify\describe;
use function Testify\incomplete;
use function Testify\it;
use function Testify\skip;
describe('feature rollout', function (): void {
it('ships later', function (): void {
})->skip('waiting for backend support');
it('needs more implementation', function (): void {
incomplete('validation rules still missing');
});
it('is planned work', function (): void {
todo('queued for next sprint');
});
});