Test
in package
A class that handles various site testing related things
Table of Contents
- $oldtests : mixed
- $tests : mixed
- ajax() : string
- Test AJAX functions
- assert() : void
- Test failed assertion handling
- cookie() : string
- Test the FormData Cookie functions
- fail() : string
- Test run time error handling
- file() : string
- Test the FormData File functions
- get() : string
- Test the FormData Get functions
- mail() : string
- Test mail
- page() : string
- Generate a test page. This tests various twig macros etc.
- post() : string
- Test the FormData Post functions
- put() : string
- Test the FormData Put functions
- toss() : void
- Throw an unhandled exception. Tests exception handling.
- upload() : string
- Test the upload features
- dotest() : string
- Do test
- mapping() : array<, mixed>
- mapping old tests
Properties
$oldtests
private
static mixed
$oldtests
= [
// function, parameters, expected result, if TRUE then failure is expected and result may be default or an exception
['has', ['exist'], TRUE, TRUE],
['has', ['notexist'], FALSE, FALSE],
['has', [['aexist', 0]], TRUE, TRUE],
['has', [['aexist', 3]], FALSE, TRUE],
['has', [['nexist', 0]], FALSE, TRUE],
['', ['exist', 3], '42', TRUE],
['', ['notexist', 3], 3, FALSE],
['must', ['exist'], '42', TRUE],
['must', ['notexist'], '42', FALSE],
['', [['aexist', 0], 3], '42', TRUE],
['', [['aexist', 3], 3], 3, FALSE],
['must', [['aexist', 1]], '66', TRUE],
['must', [['aexist', 3]], '42', FALSE],
['', [['nexist', 14], 3], '42', TRUE],
['', [['nexist', 13], 3], 3, FALSE],
['must', [['nexist', 14]], '42', TRUE],
['must', [['nexist', 13]], '42', FALSE],
['', [['kexist', 'key1'], 3], '42', TRUE],
['', [['kexist', 'key45'], 3], 3, FALSE],
['must', [['kexist', 'key1']], '42', TRUE],
['must', [['kexist', 'key45']], '42', FALSE],
['filter', ['email', FILTER_VALIDATE_EMAIL], 'foo@bar.com', TRUE],
['mustfilter', ['email', FILTER_VALIDATE_EMAIL], 'foo@bar.com', TRUE, ''],
['filter', ['email', 3, FILTER_VALIDATE_INT], 3, FALSE],
['mustfilter', ['email', FILTER_VALIDATE_INT], 3, FALSE],
]
$tests
private
static mixed
$tests
= [
// function, parameters, expected result, if FALSE then failure is expected and result may be default or an exception
['exists', ['exist'], TRUE, TRUE],
['exists', ['notexist'], FALSE, TRUE],
['exists', [['aexist', 0]], TRUE, TRUE],
['exists', [['aexist', 3]], FALSE, TRUE],
['exists', [['nexist', 0]], FALSE, TRUE],
['mustExist', ['exist'], TRUE, TRUE],
['mustExist', ['notexist'], FALSE, FALSE],
['fetch', ['exist', 3], '42', TRUE],
['fetch', ['notexist', 3], 3, FALSE],
['mustFetch', ['notarray'], 3, FALSE],
['mustFetch', ['exist'], '42', TRUE],
['mustFetch', ['notexist'], '42', FALSE],
['fetch', [['aexist', 0], 3], '42', TRUE],
['fetch', [['aexist', 3], 3], 3, FALSE],
['fetch', ['aexist', 3, NULL, '', FALSE], 3, FALSE],
['fetch', ['aexist', 3, NULL, '', TRUE], ['42', '66'], TRUE],
['mustFetch', ['aexist', NULL, '', FALSE], 3, FALSE],
['mustFetch', ['aexist', NULL, '', TRUE], ['42', '66'], TRUE],
['mustFetch', [['aexist', 1]], '66', TRUE],
['mustFetch', [['aexist', 3]], '42', FALSE],
['fetch', [['nexist', 14], 3], '42', TRUE],
['fetch', [['nexist', 13], 3], 3, FALSE],
['mustFetch', [['nexist', 14]], '42', TRUE],
['mustFetch', [['nexist', 13]], '42', FALSE],
['fetch', [['kexist', 'key1'], 3], '42', TRUE],
['fetch', [['kexist', 'key45'], 3], 3, FALSE],
['mustFetch', [['kexist', 'key1']], '42', TRUE],
['mustFetch', [['kexist', 'key45']], '42', FALSE],
['fetch', ['email', FILTER_VALIDATE_EMAIL], 'foo@bar.com', TRUE],
['mustFetch', ['email', FILTER_VALIDATE_EMAIL], 'foo@bar.com', TRUE, ''],
['fetch', ['email', 3, FILTER_VALIDATE_INT], 3, FALSE],
['mustFetch', ['email', FILTER_VALIDATE_INT], 3, FALSE],
['mustFetchBean', ['beanid', 'user'], 'userid', TRUE],
['mustFetchBean', ['notbeanid', 'user'], 'userid', FALSE],
['mustFetchBean', ['badbeanid', 'user'], 'userid', FALSE],
['mustFetchBean', ['badbeanid2', 'user'], 'userid', FALSE],
['fetchArray', ['kexist'], ['iterator', ['key1' => 42, 'key2' => 43]], TRUE],
['mustFetchArray', ['kexist'], ['iterator', ['key1' => 42, 'key2' => 43]], TRUE],
['fetchArray', ['knotexist'], ['iterator', []], FALSE],
['mustFetchArray', ['knotexist'], ['iterator', []], FALSE],
]
Methods
ajax()
Test AJAX functions
public
ajax(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —assert()
Test failed assertion handling
public
assert(Context $context) : void
Parameters
- $context : Context
-
The site context object
Return values
void —cookie()
Test the FormData Cookie functions
public
cookie(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —fail()
Test run time error handling
public
fail(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —file()
Test the FormData File functions
public
file(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —get()
Test the FormData Get functions
public
get(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —mail()
Test mail
public
mail(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —page()
Generate a test page. This tests various twig macros etc.
public
page(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —post()
Test the FormData Post functions
public
post(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —put()
Test the FormData Put functions
public
put(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —toss()
Throw an unhandled exception. Tests exception handling.
public
toss(Context $context) : void
Parameters
- $context : Context
-
The site context object
Tags
Return values
void —upload()
Test the upload features
public
upload(Context $context) : string
Parameters
- $context : Context
-
The site context object
Return values
string —dotest()
Do test
private
static dotest(Context $context, string $type) : string
Parameters
- $context : Context
- $type : string
Return values
string —mapping()
mapping old tests
private
static mapping(string $type) : array<, mixed>
Parameters
- $type : string