| Source for file test1.phpDocumentation is available at test1.php 
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ * This file is part of the PEAR Testing_DocTest package. * 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 * @package   Testing_DocTest * @author    David JEAN LOUIS <izimobil@gmail.com> * @copyright 2008 David JEAN LOUIS * @license   http://opensource.org/licenses/mit-license.php MIT License * @link      http://pear.php.net/package/Testing_DocTest * @since     Class available since release 0.1.0 * A class that does nothing. * @package   Testing_DocTest * @author    David JEAN LOUIS <izimobil@gmail.com> * @copyright 2008 David JEAN LOUIS * @license   http://opensource.org/licenses/mit-license.php MIT License * @version   Release: 0.6.0 * @link      http://pear.php.net/package/Testing_DocTest * @since     Class available since release 0.1.0 * This is a file level test. * // doctest: file-level doctest 1 * // $_ENV['OSTYPE'] = 'linux';define('OS_TYPE', $_ENV['OSTYPE']); * Below, an example of class level doc test. * // we can name our doctest explicitely, if a name is not provided it * // defaults to "class ClassName" (here "class Foo") * // doctest: my test for class Foo * $foo1->attr1 = 'value1'; * $foo1->attr2 = 'value2'; * @package   Testing_DocTest * @author    David JEAN LOUIS <izimobil@gmail.com> * @copyright 2008 David JEAN LOUIS * @license   http://opensource.org/licenses/mit-license.php MIT License * @version   Release: 0.6.0 * @link      http://pear.php.net/package/Testing_DocTest * @since     Class available since release 0.1.0     * Properties doc blocs do not accept doc tests.     * Properties doc blocs do not accept doc tests.    // Foo::__construct() {{{     * @param array $params an optional array of parameters        if (isset($params['attr1'])) {            $this->attr1 = $params['attr1'] ;        if (isset($params['attr2'])) {            $this->attr2 = $params['attr2'] ;        if (null !== $this->attr1) {        if (null !== $this->attr2) {     * // below we specify the name of our test, if not specified it default     * // to "method ClassName::methodName()" (here "method Foo::testString")     * // doctest: my test for method Foo::testString     * echo $foo->testString();     * var_dump($foo->testBool());     * var_dump($foo->testBool(false));     * @param bool $ret return value     * var_dump($foo->testInt());     * var_dump($foo->testFloat());     * print_r($foo->testArray());     * $foo = new Foo(array('attr1'=>'foo', 'attr2'=>'bar'));    // Foo::testResource() {{{     * var_dump(is_resource($foo->testResource()));     * echo get_resource_type($foo->testResource());        return fopen(__FILE__, 'r') ;    // Foo::testException() {{{     * } catch (Exception $exc) {     *     echo $exc->getMessage();     * // Some descriptive message        throw new Exception('Some descriptive message') ;     * When an instruction does not return a value or return the value NULL,     * echo $foo->testError(E_USER_ERROR);     * // Fatal error: Foo ! in [...] on line [...]     * // ini-set: display_errors=Off     * $foo = new Foo(E_USER_ERROR);     * echo $foo->testError();     * echo $foo->testError(E_USER_WARNING);     * // Warning: Foo ! in [...] on line [...]     * echo $foo->testError(E_USER_NOTICE);     * // Notice: Foo ! in [...] on line [...]     * @param int $level error level    // Foo::testBug16372pre() {{{     * echo $foo->testBug16372pre();    // Foo::testBug16372() {{{     * echo $foo->testBug16372(); * 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: FLAG_1, FLAG_2 , ... , FLAG_N * Here are some examples: * // flags: NORMALIZE_WHITESPACE * echo testFlags('   fo  o        '); * // flags: CASE_INSENSITIVE * // don't care too much... * // function [...]: [...] * @param string $foo some string * 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 ;) * printf("%01.2f\n", multiply(3, 4)); * printf("%01.2f\n", multiply(3.2, 4)); * printf("%01.2f\n", multiply(3.2, 4.2)); * } catch (Exception $exc) { *     echo $exc->getMessage() . "\n"; * } catch (Exception $exc) { *     echo $exc->getMessage() . "\n"; * // Wrong type for first argument. * // Wrong type for second argument. * @param mixed $a an int or a float * @param mixed $b an int or a float * @return float the result of the multiplication * @throws Exception if arguments given have a wrong type        throw new Exception("Wrong type for first argument.") ;        throw new Exception("Wrong type for second argument.") ; * 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 * @param mixed $a an int or a float * @param mixed $b an int or a float * @return float the result of the multiplication * @throws Exception if arguments given have a wrong type        throw new Exception("Wrong type for first argument.") ;        throw new Exception("Wrong type for second argument.") ; * A simple function that return a simple or multidimensional array. * print_r(testArray(true)); * // note that here we must add a blank line at the end because we are using * // STRICT_WHITESPACE flag. * // flags: NORMALIZE_WHITESPACE * // Array([0]=>foo [1]=>bar) * @param bool $multi return a multidimensional array if set to true. * @return array multidimensionnal array    return $multi ? array('foo' =>'1', 'bar' =>'2') : array('foo', 'bar') ; * 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 * // A string that cannot be predicted [...]. * // an example on how we can wrap long text * @return array multidimensionnal array * This is another file level test. * // doctest: file-level doctest 2 * // $_REQUEST['foo'] = 'bar'; * var_dump(defined('FOO'));if (isset($_REQUEST['foo']) && $_REQUEST['foo'] == 'bar') { * simple test of tmplCode flag * // doctest: tmpl-code doctest * // tmpl-code: docs/tmpl_code.doctest.php
		    
 
		    Documentation generated on Mon, 11 Mar 2019 15:52:27 -0400 by phpDocumentor 1.4.4 . PEAR Logo Copyright ©  PHP Group 2004.
	       |