Download the PHP package lucinda/unit-testing without Composer

On this page you can find all versions of the php package lucinda/unit-testing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package unit-testing

Lucinda Unit Testing

Lightweight PHP 8.1 unit testing library with no package dependencies. It reads an XML configuration, mirrors source classes into test classes, runs matching test methods, and reports Lucinda\UnitTest\Result objects in the console or as JSON.

Requirements

Install it in the project that owns the code you want to test:

Configuration

Create an XML file, commonly unit-tests.xml, that describes one or more source/test folder pairs:

unit_tests is required. Each unit_test entry requires sources and tests tags with non-empty namespace attributes. The path attributes default to src and tests; the source path must already exist, while a missing tests path is created automatically.

The optional servers/sql/{environment}/server entry configures the SQL validator. The environment name is the second argument passed to a controller, for example local.

Running Tests

Create a small runner script in the consuming project:

Then run it:

You can run a single generated test class by passing its fully qualified name as the third controller argument:

Runtime Flow

Lucinda\UnitTest\Controller coordinates the whole process:

  1. Configuration reads the XML file, validates configured APIs, and builds an optional SQL data source for the selected environment.
  2. Creator scans configured source folders and creates or updates missing test classes and methods.
  3. Runner scans sources and tests, executes matching test methods, and collects Runner\UnitTest rows.
  4. A concrete controller displays or exports the collected results.

The package includes two controllers:

Class Output
Lucinda\UnitTest\ConsoleController Text table with passed/failed totals. Uses ANSI colors on non-Windows systems.
Lucinda\UnitTest\JsonController JSON array containing class, method, passed, and message.

You can also extend Controller and implement handle(array $results): void to store or render results differently.

Generated Tests

The generator scans PHP files under each configured source path. Concrete classes are mirrored into the tests path using the same relative file structure, the source class name with Test appended, and a Test\ namespace prefix.

For example:

Only concrete classes are generated and run. Abstract classes, interfaces, and enums are skipped. Public methods are mirrored, excluding __construct and __destruct. Public inherited and implemented interface methods are included when the parent/interface is found in the configured scan results.

Generated methods are intentionally empty:

Fill each generated method with assertions. A test method must return either one Lucinda\UnitTest\Result or a non-empty array of Result objects:

If a source class or source method is not covered, or if a test method returns something other than Result or Result[], the runner records a failed result.

Additional public methods that exist only on the test class are also executed. This is useful for setup-specific checks that do not directly mirror one source method.

Results

Lucinda\UnitTest\Result is the common assertion payload:

Use hasPassed(): bool to read status and getMessage(): string to read the message. Validators return this object directly.

Validators

Primitive and filesystem validators wrap a value and expose assertion methods that return Result.

Validator Assertions
Validator\Booleans assertTrue, assertFalse
Validator\Integers assertEquals, assertNotEquals, assertGreater, assertGreaterEquals, assertSmaller, assertSmallerEquals
Validator\Floats assertEquals, assertNotEquals, assertGreater, assertGreaterEquals, assertSmaller, assertSmallerEquals
Validator\Strings assertEmpty, assertNotEmpty, assertEquals, assertNotEquals, assertContains, assertNotContains, assertSize, assertNotSize
Validator\Arrays assertEmpty, assertNotEmpty, assertEquals, assertNotEquals, assertIdentical, assertNotIdentical, assertContainsKey, assertNotContainsKey, assertContainsValue, assertNotContainsValue, assertSize, assertNotSize
Validator\Objects assertInstanceOf, assertNotInstanceOf
Validator\Files assertExists, assertNotExists, assertEquals, assertNotEquals, assertContains, assertNotContains, assertSize, assertNotSize

Examples:

SQL Assertions

SQL assertions use a shared Validator\SQL instance configured from XML by the runner. The connection is opened through PDO, starts a transaction, and rolls back when the instance is destroyed.

If no SQL data source is configured, SQL::getInstance() throws Lucinda\UnitTest\Exception.

URL Assertions

URL assertions use cURL through Validator\URL. Configure a Validator\URL\DataSource, run the request, and validate the Validator\URL\Response.

Supported request methods are GET, POST, PUT, HEAD, DELETE, PATCH, and OPTIONS. GET parameters are appended as a query string; other request parameters are sent as URL-encoded fields. Requests time out after 10 seconds.

Notes And Constraints


All versions of unit-testing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-simplexml Version *
ext-curl Version *
ext-pdo Version *
ext-tokenizer Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lucinda/unit-testing contains the following files

Loading the files please wait ...