Download the PHP package meritum/testing without Composer

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

meritum/testing

Test kernel orchestration for the Meritum ecosystem — boots and tears down the app kernels under test, applies service overrides and mocks before boot, and manages the test-support dependencies (e.g. a database connection for model factories) needed alongside them.

Requirements

Installation

Usage

Managing kernels

TestingKernel is a plain Georgeff\Kernel\Kernel that takes custody of one or more already-built, unbooted app kernels via manages(). Booting the testing kernel boots itself first, then boots every managed kernel:

manages() requires an id — there's no optional/anonymous form — so a managed kernel can always be looked up later by the same string, regardless of how many kernels are involved. Convention is to key it by the kernel's own contract (e.g. an interface FQCN) rather than an arbitrary label, so anything built on top of meritum/testing has a stable name to resolve against. Both manages() and boot() throw a Georgeff\Kernel\KernelException if the testing kernel has already booted.

Overriding services

instance() and factory() stage a replacement for a service id, applied to every managed kernel when the testing kernel boots:

instance() takes an already-built object — the closure it registers always returns that exact instance, so identity is guaranteed regardless of container caching, which matters for anything a test wants to assert against later (e.g. messages published to $queue). factory() takes a callable instead, for cases that don't need a captured reference back:

Both throw if the testing kernel is already booted.

By default an override applies to every managed kernel. Pass one or more managed-kernel ids to scope it to just those:

Targeting an id that isn't actually managed throws a KernelException as soon as boot() runs, before any managed kernel starts booting.

Mocking

mock() builds a Mockery mock, registers it as an instance override, and returns it so expectations can be set before boot:

The class to mock defaults to the id itself, so mock(RepositoryInterface::class) is equivalent to mock(RepositoryInterface::class, RepositoryInterface::class). shutdown() calls Mockery::close() automatically, verifying expectations without needing the MockeryPHPUnitIntegration trait on your own test case.

Environment variables

setEnv() stages a variable to be applied via putenv() when the testing kernel boots:

shutdown() restores whatever the variable was set to beforehand, or unsets it entirely if it didn't exist before — so environment changes never leak into the next test.

Shutdown

shutdown() shuts down every managed kernel, then itself, then closes Mockery and forces gc_collect_cycles():

It's a no-op if the testing kernel was never booted, so it's always safe to call unconditionally in a test's teardown.

The base test case

Meritum\Testing\TestCase extends PHPUnit\Framework\TestCase and constructs a fresh TestingKernel in setUp(), available as $this->kernel. It does not call boot() automatically — that stays an explicit call, so a test can register manages()/instance()/mock() right up until it's actually ready, including inline in a test method body:

Override modules()/environment() to configure the testing kernel's own dependencies (not the managed app kernels' — those are built and configured independently, then handed to manages()). tearDown() calls $this->kernel->shutdown() automatically. onTeardown(callable $callback) is a shortcut for $this->kernel->onShutdown($callback).


All versions of testing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
georgeff/kernel Version ^1.10
mockery/mockery Version ^1.6
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 meritum/testing contains the following files

Loading the files please wait ...