Download the PHP package kenjis/phpunit-helper without Composer

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

PHPUnit Helper

Provides helper traits for PHPUnit.

Table of Contents

Requirements

Installation

Run:

Usage

TestDouble

This trait provides helper methods to create mock objects and to verify invocations.

Import the Kenjis\PhpUnitHelper\TestDouble trait into your test class:

$this->getDouble()

param type description
$classname string class name
$params array [method_name => return_value]
[[method_name => [return_value1, return_value2 [, ...]]]
$constructor_params false/array false: disable constructor / array: constructor params

returns (object) PHPUnit mock object.

Gets PHPUnit mock object.

You could write code above like below:

You can set Closure as the return value of a mocked method.

You can also set the mock itself as the return value of a mocked method with using $this->returnSelf().

You can create mocks with consecutive calls.

You could write code above like below:

$this->verifyInvoked()

param type description
$mock object PHPUnit mock object
$method string method name
$params array arguments

Verifies a method was invoked at least once.

You could write code above like below:

$this->verifyInvokedOnce()

param type description
$mock object PHPUnit mock object
$method string method name
$params array arguments

Verifies that method was invoked only once.

You could write code above like below:

$this->verifyInvokedMultipleTimes()

param type description
$mock object PHPUnit mock object
$method string method name
$times int times
$params array arguments

Verifies that method was called exactly $times times.

You could write code above like below:

$this->verifyNeverInvoked()

param type description
$mock object PHPUnit mock object
$method string method name
$params array arguments

Verifies that method was not called.

You could write code above like below:

ReflectionHelper

This trait provides helper methods to access private or protected properties and methods.

But generally it is not recommended testing non-public properties or methods, so think twice before you use the methods in this trait.

Import the Kenjis\PhpUnitHelper\ReflectionHelper trait into your test class:

$this->getPrivateProperty()

param type description
$obj object/string object / class name
$property string property name

returns (mixed) property value.

Gets private or protected property value.

$obj = new SomeClass();
$private_propery = $this->getPrivateProperty(
    $obj,
    'privatePropery'
);

$this->setPrivateProperty()

param type description
$obj object/string object / class name
$property string property name
$value mixed value

Sets private or protected property value.

$obj = new SomeClass();
$this->setPrivateProperty(
    $obj,
    'privatePropery',
    'new value'
);

$this->getPrivateMethodInvoker()

param type description
$obj object/string object / class name
$method string method name

returns (closure) method invoker.

Gets private or protected method invoker.

$obj = new SomeClass();
$method = $this->getPrivateMethodInvoker(
    $obj, 'privateMethod'
);
$this->assertEquals(
    'return value of the privateMethod() method', $method()
);

DebugHelper

This trait provides helper functions, dd() and d() to dump variables.

Import the Kenjis\PhpUnitHelper\DebugHelper trait into your test class:

License

This package is licensed using the MIT License.

Please have a look at LICENSE.


All versions of phpunit-helper with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3||^8.0
phpunit/phpunit Version ^9.5
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 kenjis/phpunit-helper contains the following files

Loading the files please wait ....