swew / test.phar
A test framework that is designed to fix the fatal flaw of other test frameworks.
README
phar package of swew/test
A PHP test framework that solves the fatal flaw of all others.
This composer package is a lightweight and fast testing library designed to provide an informative interface. It offers a variety of testing features, including unit testing, integration testing, and functional testing. The package is designed to make testing simple and easy, allowing developers to quickly identify and fix bugs in their code. With its fast and efficient testing tools, developers can ensure that their code is reliable and performs well in real-world scenarios.
It's designed to help you write tests quickly and stick to TDD.
Packages developed by SWEW
- swew/cli - A command-line interface program with formatting and text entry functions.
- swew/test - A test framework that is designed to fix the fatal flaw of other test frameworks.
- swew/db - A lightweight, fast, and secure PHP library for interacting with databases, creating migrations, and running queries.
- swew/dd - The simplest way to debug variables. As in Laravel.
Quick start
Installation
composer require --dev swew/test.phar
composer exec t -- --init
Next to the composer.json
file, a config file will be created for tests - swew.json
.
Now you can start writing tests.
Get started
All tests, by default, are in files with the ending *.spec.php
or *.test.php
. For example the path to the file may be as follows: tests/Unit/string-utils.spec.php
.
To write the test itself, you only need a few functions.
You may also need other functions:
It is now possible to run in the console:
composer exec t
Example
<?php // example.spec.php declare(strict_types=1); it('Test 1', function () { expect(10)->not()->toBe(1); }); it('Test 2: with dataset', function (int $num, int $n2 = 3) { $a = str_repeat("Hello", $num * 100000); return $a; })->with([ 1, [2, 3] ]); it('Test 3: skip', function () { sleep(2); })->skip();
License MIT.