pfSense-pkg-saml2-auth

TestCase
in package

Defines a TestCase object that can be used to define child TestCase classes that test internal functionality of the API. This is needed because pfSense does not have PHPUnit readily available.

Table of Contents

Properties

$method  : string
$method_docstring  : string

Methods

run()  : void
Runs this TestCase when the object is created. Any method that starts with `test` will automatically be run.
setup()  : void
Sets up the test case before tests are run. This can be overridden by your TestCase to setup shared resources required for your tests.
teardown()  : void
Tears down the test case after tests are run. This can be overridden by your TestCase to destroy resources that may have been created during tests.
assert_does_not_throw()  : void
Checks if a given callable throws any exception.
assert_equals()  : void
Checks if two values are equal.
assert_is_empty()  : void
Checks if a given value is empty.
assert_is_false()  : mixed
Checks if a given value is a `false` boolean.
assert_is_greater_than()  : void
Checks if a given $value1 is greater than $value2.
assert_is_greater_than_or_equal()  : void
Checks if a given $value1 is greater than or equal to $value2.
assert_is_less_than()  : void
Checks if a given $value1 is less than $value2.
assert_is_less_than_or_equal()  : void
Checks if a given $value1 is less than or equal to $value2.
assert_is_not_empty()  : void
Checks if a given value is not empty.
assert_is_true()  : void
Checks if a given value is a `true` boolean.
assert_not_equals()  : void
Checks if two values are not equal.
assert_str_contains()  : void
Checks if a string contains another string.
assert_str_does_not_contain()  : void
Checks if a string does not contains another string.
assert_throws()  : void
Checks if an embedded callable raises a specific error
assert_type()  : void
Checks if a given value is of a given type.
get_method_retry_settings()  : TestCaseRetry

Properties

$method

public string $method = 'unknown'

Placeholder for the method that is currently being tested.

$method_docstring

public string $method_docstring = ''

Placeholder for the docstring for the method that is currently being tested.

Methods

run()

Runs this TestCase when the object is created. Any method that starts with `test` will automatically be run.

public run() : void
Tags
throws
ReflectionException

When ReflectionMethod could not find a test method.

throws
Error|Exception

The exception thrown by failed Tests, typically an AssertionError.

setup()

Sets up the test case before tests are run. This can be overridden by your TestCase to setup shared resources required for your tests.

public setup() : void

teardown()

Tears down the test case after tests are run. This can be overridden by your TestCase to destroy resources that may have been created during tests.

public teardown() : void

assert_does_not_throw()

Checks if a given callable throws any exception.

protected assert_does_not_throw(mixed $callable) : void
Parameters
$callable : mixed

A callable to run and check for thrown exception.

Tags
throws
AssertionError

If the $callable throws any exception.

assert_equals()

Checks if two values are equal.

protected assert_equals(mixed $value1, mixed $value2[, string $message = '' ]) : void
Parameters
$value1 : mixed

The first value to evaluate.

$value2 : mixed

The second value to evaluate.

$message : string = ''

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When $value1 and $value2 are not equal.

assert_is_empty()

Checks if a given value is empty.

protected assert_is_empty(mixed $value[, string $message = 'Expected value to be empty.' ]) : void
Parameters
$value : mixed

The value to evaluate.

$message : string = 'Expected value to be empty.'

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When the value is not empty.

assert_is_false()

Checks if a given value is a `false` boolean.

protected assert_is_false(mixed $value[, string $message = "Expected value to equal 'false'." ]) : mixed
Parameters
$value : mixed

The value to evaluate.

$message : string = "Expected value to equal 'false'."

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When the value is not false.

assert_is_greater_than()

Checks if a given $value1 is greater than $value2.

protected assert_is_greater_than(mixed $value1, mixed $value2) : void
Parameters
$value1 : mixed

The first value to evaluate. This value must be greater than value 2 to pass check.

$value2 : mixed

The second value to evaluate. This value must be less than value 1 to pass check.

assert_is_greater_than_or_equal()

Checks if a given $value1 is greater than or equal to $value2.

protected assert_is_greater_than_or_equal(mixed $value1, mixed $value2) : void
Parameters
$value1 : mixed

The first value to evaluate. This value must be greater than or equal to value 2 to pass check.

$value2 : mixed

The second value to evaluate. This value must be less than or equal to value 1 to pass check.

assert_is_less_than()

Checks if a given $value1 is less than $value2.

protected assert_is_less_than(mixed $value1, mixed $value2) : void
Parameters
$value1 : mixed

The first value to evaluate. This value must be less than value 2 to pass check.

$value2 : mixed

The second value to evaluate. This value must be greater than value 1 to pass check.

assert_is_less_than_or_equal()

Checks if a given $value1 is less than or equal to $value2.

protected assert_is_less_than_or_equal(mixed $value1, mixed $value2) : void
Parameters
$value1 : mixed

The first value to evaluate. This value must be less than or equal to value 2 to pass check.

$value2 : mixed

The second value to evaluate. This value must be greater than or equal to value 1 to pass check.

assert_is_not_empty()

Checks if a given value is not empty.

protected assert_is_not_empty(mixed $value[, string $message = 'Expected value to not be empty.' ]) : void
Parameters
$value : mixed

The value to evaluate.

$message : string = 'Expected value to not be empty.'

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When the value is not empty.

assert_is_true()

Checks if a given value is a `true` boolean.

protected assert_is_true(mixed $value[, string $message = "Expected value to equal 'true'." ]) : void
Parameters
$value : mixed

The value to evaluate.

$message : string = "Expected value to equal 'true'."

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When the value is not true.

assert_not_equals()

Checks if two values are not equal.

protected assert_not_equals(mixed $value1, mixed $value2[, string $message = '' ]) : void
Parameters
$value1 : mixed

The first value to evaluate.

$value2 : mixed

The second value to evaluate.

$message : string = ''

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When $value1 and $value2 are equal.

assert_str_contains()

Checks if a string contains another string.

protected assert_str_contains(string $haystack, string $needle) : void
Parameters
$haystack : string

The string to check for the $needle in.

$needle : string

The string to check for within the $haystack.

Tags
throws
AssertionError

When $haystack string did not contain the $needle string.

assert_str_does_not_contain()

Checks if a string does not contains another string.

protected assert_str_does_not_contain(string $haystack, string $needle) : void
Parameters
$haystack : string

The string to check for the $needle in.

$needle : string

The string to check for within the $haystack.

Tags
throws
AssertionError

When $haystack string did contain the $needle string.

assert_throws()

Checks if an embedded callable raises a specific error

protected assert_throws(array<string|int, mixed> $exceptions, mixed $callable[, string $message = '' ]) : void
Parameters
$exceptions : array<string|int, mixed>

An array of Exceptions this method will expect the callable to raise.

$callable : mixed

An anonymous function that raises one of the $exceptions.

$message : string = ''

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When the $callable did not raise one of the $exceptions.

assert_type()

Checks if a given value is of a given type.

protected assert_type(mixed $value, string $type[, string $message = '' ]) : void
Parameters
$value : mixed

The value to evaluate.

$type : string

The string representation of the type to expect. This must match a gettype() return value.

$message : string = ''

Set the error message embedded in any AssertionError thrown by this method.

Tags
throws
AssertionError

When the $value's type does not match the given $type.

get_method_retry_settings()

protected get_method_retry_settings(ReflectionMethod $method) : TestCaseRetry
Parameters
$method : ReflectionMethod

The method to check for a TestCaseRetry attribute.

Return values
TestCaseRetry

The TestCaseRetry attribute found on the method, or a default TestCaseRetry object


        
On this page

Search results