TestContext

The test context is used for performing test assertions and manage the completion of the test. This context is provided by <i>vertx-unit</i> as argument of the test case.

package

Default

Methods

__construct

__construct() 

Assert the <code>expected</code> argument is equals to the <code>actual</code> argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.

assertEquals( $arg0,  $arg1,  $arg2 = null) : $this

param $expected [mixed] the object the actual object is supposedly equals to param $actual [mixed] the actual object to test assertEquals($expected, $actual)

Assert the expected argument is equals to the actual argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.

param $expected [mixed] the object the actual object is supposedly equals to param $actual [mixed] the actual object to test param $message [string] the failure message assertEquals($expected, $actual, $message)

Arguments

$arg0

mixed

$arg1

mixed

$arg2

string

Response

$this

a reference to this, so the API can be used fluently

Assert the specified <code>condition</code> is <code>false</code>. If the condition is <code>true</code>, an assertion error is thrown otherwise the execution continue.

assertFalse( $arg0,  $arg1 = null) : $this

param $condition [boolean] the condition to assert assertFalse($condition)

Assert the specified condition is false. If the condition is true, an assertion error is thrown otherwise the execution continue.

param $condition [boolean] the condition to assert param $message [string] the failure message assertFalse($condition, $message)

Arguments

$arg0

boolean

$arg1

string

Response

$this

a reference to this, so the API can be used fluently

Asserts that the <code>expected</code> double argument is equals to the <code>actual</code> double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.

assertInRange( $arg0,  $arg1,  $arg2,  $arg3 = null) : $this

param $expected [float] the object the actual object is supposedly equals to param $actual [float] the actual object to test param $delta [float] the maximum delta assertInRange($expected, $actual, $delta)

Asserts that the expected double argument is equals to the actual double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.

param $expected [float] the object the actual object is supposedly equals to param $actual [float] the actual object to test param $delta [float] the maximum delta param $message [string] the failure message assertInRange($expected, $actual, $delta, $message)

Arguments

$arg0

float

$arg1

float

$arg2

float

$arg3

string

Response

$this

a reference to this, so the API can be used fluently

Assert the <code>first</code> argument is not equals to the <code>second</code> argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.

assertNotEquals( $arg0,  $arg1,  $arg2 = null) : $this

param $first [mixed] the first object to test param $second [mixed] the second object to test assertNotEquals($first, $second)

Assert the first argument is not equals to the second argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.

param $first [mixed] the first object to test param $second [mixed] the second object to test param $message [string] the failure message assertNotEquals($first, $second, $message)

Arguments

$arg0

mixed

$arg1

mixed

$arg2

string

Response

$this

a reference to this, so the API can be used fluently

Assert the <code>expected</code> argument is not <code>null</code>. If the argument is <code>null</code>, an assertion error is thrown otherwise the execution continue.

assertNotNull( $arg0,  $arg1 = null) : $this

param $expected [mixed] the argument being asserted to be not null assertNotNull($expected)

Assert the expected argument is not null. If the argument is null, an assertion error is thrown otherwise the execution continue.

param $expected [mixed] the argument being asserted to be not null param $message [string] the failure message assertNotNull($expected, $message)

Arguments

$arg0

mixed

$arg1

string

Response

$this

a reference to this, so the API can be used fluently

Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown otherwise the execution continue.

assertNull( $arg0,  $arg1 = null) : $this

param $expected [mixed] the argument being asserted to be null assertNull($expected)

Assert the expected argument is null. If the argument is not, an assertion error is thrown otherwise the execution continue.

param $expected [mixed] the argument being asserted to be null param $message [string] the failure message assertNull($expected, $message)

Arguments

$arg0

mixed

$arg1

string

Response

$this

a reference to this, so the API can be used fluently

Assert the specified <code>condition</code> is <code>true</code>. If the condition is <code>false</code>, an assertion error is thrown otherwise the execution continue.

assertTrue( $arg0,  $arg1 = null) : $this

param $condition [boolean] the condition to assert assertTrue($condition)

Assert the specified condition is true. If the condition is false, an assertion error is thrown otherwise the execution continue.

param $condition [boolean] the condition to assert param $message [string] the failure message assertTrue($condition, $message)

Arguments

$arg0

boolean

$arg1

string

Response

$this

a reference to this, so the API can be used fluently

Create and returns a new async object, the returned async controls the completion of the test. Calling the

async( $arg0 = null) : \io\vertx\jphp\ext\unit\Async
see \io\vertx\jphp\ext\unit\Async::complete

completes the async operation.

The test case will complete when all the async objects have their @see \io\vertx\jphp\ext\unit\Async::complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

async()

Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when the @see \io\vertx\jphp\ext\unit\Async::countDown is called count times.

The test case will complete when all the async objects have their @see \io\vertx\jphp\ext\unit\Async::complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

param $count [integer] async($count)

Arguments

$arg0

integer

Response

\io\vertx\jphp\ext\unit\Async

the async instance

Creates and returns a new async handler, the returned handler controls the completion of the test.<p/>

asyncAssertFailure( $arg0 = null) : callable

When the returned handler is called back with a failed result it completes the async operation.

When the returned handler is called back with a succeeded result it fails the test.

asyncAssertFailure()

Creates and returns a new async handler, the returned handler controls the completion of the test.

When the returned handler is called back with a failed result it completes the async operation.

When the returned handler is called back with a succeeded result it fails the test.

param $causeHandler [callable] the cause handler asyncAssertFailure($causeHandler)

Arguments

$arg0

callable

Response

callable

the async result handler

Creates and returns a new async handler, the returned handler controls the completion of the test.<p/>

asyncAssertSuccess( $arg0 = null) : callable

When the returned handler is called back with a succeeded result it completes the async operation.

When the returned handler is called back with a failed result it fails the test with the cause of the failure.

asyncAssertSuccess()

Creates and returns a new async handler, the returned handler controls the completion of the test.

When the returned handler is called back with a succeeded result it invokes the resultHandler argument with the async result. The test completes after the result handler is invoked and does not fails.

When the returned handler is called back with a failed result it fails the test with the cause of the failure.

Note that the result handler can create other async objects during its invocation that would postpone the completion of the test case until those objects are resolved.

param $resultHandler [callable] the result handler asyncAssertSuccess($resultHandler)

Arguments

$arg0

callable

Response

callable

the async result handler

exceptionHandler

exceptionHandler() : callable

Response

callable

an exception handler that will fail this context

Throw a failure.

fail( $arg0 = null) : void

fail()

Throw a failure with the specified failure message.

param $message [string] the failure message fail($message)

Throw a failure with the specified failure cause.

param $cause [\Exception] the failure cause fail($cause)

Arguments

$arg0

string | \Exception

Get some data from the context.

get( $arg0) : mixed

Arguments

$arg0

string

Response

mixed

the data

Put some data in the context.

put( $arg0,  $arg1) : mixed

This can be used to share data between different tests and before/after phases.

Arguments

$arg0

string

$arg1

mixed

Response

mixed

the previous object when it exists

Remove some data from the context.

remove( $arg0) : mixed

Arguments

$arg0

string

Response

mixed

the removed object when it exists

Create and returns a new async object, the returned async controls the completion of the test.

strictAsync( $arg0) : \io\vertx\jphp\ext\unit\Async

This async operation completes when the @see \io\vertx\jphp\ext\unit\Async::countDown is called count times.

If @see \io\vertx\jphp\ext\unit\Async::countDown is called more than count times, an \java.lang.IllegalStateException is thrown.

The test case will complete when all the async objects have their @see \io\vertx\jphp\ext\unit\Async::complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

Arguments

$arg0

integer

Response

\io\vertx\jphp\ext\unit\Async

the async instance

Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework.

verify( $arg0) : $this

Any \java.lang.AssertionError thrown will be caught (and propagated) in order to fulfill potential expected async completeness.

Arguments

$arg0

callable

Response

$this

a reference to this, so the API can be used fluently