Download the PHP package atk14/tester without Composer

On this page you can find all versions of the php package atk14/tester. 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 tester

Tester

Tests

Tester is a PHPUnit wrapper that abstracts PHPUnit's API changes across different PHP and PHPUnit versions. This means you can use the same test suites regardless of which PHPUnit version is installed. Tester makes it much easier to keep your tests working as you upgrade PHP or PHPUnit.

Statements:

Supported versions:

Installation

Installation only for a specific project:

composer require --dev atk14/tester

Global installation:

composer global require atk14/tester

In case of global installation, it is convenient to have the path $HOME/.config/composer/vendor/bin/ in the $PATH environment variable.

Checking that all required dependencies are met:

$ run_unit_tests --check-dependencies && echo "ok"
# or
$ run_unit_tests -c && echo "ok"

Basic usage

In the project directory, create a test directory:

$ mkdir test
$ cd test

Place a test case file tc_first_test_case.php in there:

The TcBase class doesn't need to be defined — Tester creates it automatically if the file tc_base.php is absent.

Run all tests in the directory:

$ run_unit_tests
--- tc_first_test_case.php

Time: 00:00.012, Memory: 4.00 MB

OK (2 tests, 2 assertions)

You can also run a specific test case or a subset of test cases:

$ run_unit_tests tc_first_test_case
$ run_unit_tests tc_first_test_case tc_strings

Or point run_unit_tests at a subdirectory:

$ run_unit_tests path/to/test/

Initialization

Usually it is necessary to load and initialize something before running tests. The file initialize.php, if it exists in the test directory, is loaded automatically before each test case.

TcBase and TcSuperBase

Tester provides the TcSuperBase class (and its alias tc_super_base), which extends PHPUnit's TestCase and adds compatibility shims described below.

Your test cases should extend TcBase. If you don't create a tc_base.php file, Tester creates a plain TcBase that simply extends TcSuperBase. When you need shared setup, teardown, or helper methods across all your test cases, define TcBase yourself:

Note that Tester uses _setUp() and _tearDown() instead of PHPUnit's setUp() and tearDown(). This is intentional — it avoids conflicts with PHPUnit's internal lifecycle and works consistently across all supported PHPUnit versions.

Compatibility shims

Tester adds the following assertion methods to TcSuperBase when they are missing from the installed PHPUnit version:

This means you can use assertStringContains in your tests and they will work on both old and new PHPUnit versions.

Global variable $_TEST

Before each test case file is loaded, the global variable $_TEST is set. It contains the full path to the currently executed test case file, which can be useful in initialize.php:

Dangerous tests

Sometimes you don't want certain test files to run automatically — for example, tests that modify a production database or send real emails. Prefix such files with an exclamation mark:

!tc_dangerous_test_case.php

These files are ignored by a plain run_unit_tests call:

$ run_unit_tests
# !tc_dangerous_test_case.php is skipped

To run a dangerous test explicitly, name it on the command line:

$ run_unit_tests \!tc_dangerous_test_case.php
# or
$ run_unit_tests '!tc_dangerous_test_case.php'

Automation in CI

cd test && \
../vendor/bin/run_unit_tests && \
echo "TESTS ARE OK" && exit 0 || \
echo "THERE WERE ERRORS" && exit 1

For use in shell scripts or Makefile targets, run_unit_tests exits with code 0 on success and 1 on failure, making it straightforward to integrate into any CI pipeline.

License

Tester is free software distributed under the terms of the MIT license.


All versions of tester with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
phpunit/phpunit Version ~4.8|~5.7|~6.0|~7.5|~8.5|~9.6|~10.0|~11.0
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 atk14/tester contains the following files

Loading the files please wait ...