File: test1.php
Source Location: /Testing_DocTest-0.6.0/docs/test1.php
Classes:
Bar
A class that does nothing.
Foo
Foo class.
Page Details:
This file is part of the PEAR Testing_DocTest package.
PHP version 5 LICENSE: This source file is subject to the MIT license that is available through the world-wide-web at the following URI: http://opensource.org/licenses/mit-license.php <?php
echo "Foo!";
// expects:
// Foo!
?>
FOO [line 660]
OS_TYPE [line 61]
multiply [line 539]
float multiply(
mixed $a, mixed $b)
|
|
A simple function that multiply two int or float and return a float number. It throws an exception if arguments given have a wrong type. Note that the "^M" chars have been intentionally added for tests purpose ;)
try {
} catch (Exception $exc) {
echo $exc->getMessage() . "\n";
}
try {
} catch (Exception $exc) {
echo $exc->getMessage() . "\n";
}
// expects:
// 12.00
// 12.80
// 13.44
// Wrong type for first argument.
// Wrong type for second argument.
Parameters
mixed |
$a |
an int or a float |
mixed |
$b |
an int or a float |
multiply2 [line 568]
float multiply2(
mixed $a, mixed $b)
|
|
A simple function that multiply two int or float and return a float number. It throws an exception if arguments given have a wrong type. This example shows the use of an external doctest file. // test-file: docs/external_file.doctest
Parameters
mixed |
$a |
an int or a float |
mixed |
$b |
an int or a float |
testArray [line 609]
array testArray(
[bool $multi = false])
|
|
A simple function that return a simple or multidimensional array. // flags:
// expects:
// Array
// (
// [foo] => 1
// [bar] => 2
// )
// note that here we must add a blank line at the end because we are using
// STRICT_WHITESPACE flag.
// flags: NORMALIZE_WHITESPACE
// expects:
// Array([0]=>foo [1]=>bar)
Parameters
bool |
$multi |
return a multidimensional array if set to true. |
testFlags [line 498]
string testFlags(
[string $foo = ''])
|
|
This little function will explain the usage of flags in doc tests. At the moment, doc tests can have the following flags: - NORMALIZE_WHITESPACE: tells the runner to compare strings ignoring
all whitespace differences;
- CASE_INSENSITIVE: tells the runner to compare strings ignoring case;
- SKIP: tells the parser to just ignore the test;
- ELLIPSIS: allow to pass a wildcard pattern: [...] that will match
any string in the actual result.
flags syntax: // flags: FLAG_1, FLAG_2 , ... , FLAG_N or: // flags: FLAG_1 // FLAG_2 , FLAG_3 // FLAG_N Here are some examples: // flags: NORMALIZE_WHITESPACE
// expects:
// function says: foo
// flags: CASE_INSENSITIVE
// expects:
// FUNCtion says: Foo
// flags: SKIP
// expects:
// don't care too much...
// flags: ELLIPSIS
// expects:
// function [...]: [...]
Parameters
testString [line 642]
A simple function that return a string. // note that here we must set the ELLIPSIS flag cause we cannot predict
// exactly the result of the function
// flags: ELLIPSIS
// expects:
// A string that cannot be predicted [...].
// an example on how we can wrap long text
// flags: ELLIPSIS
// expects:
// A string \
// that cannot \
// be predicted [...].
Documentation generated on Mon, 11 Mar 2019 15:52:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|