PHP Classes
elePHPant
Icontem

File: lib/ITest/Example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of AlexanderC  >  ITest v2  >  lib/ITest/Example.php  >  Download  
File: lib/ITest/Example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ITest v2
Run tests on classes defined in comments
Author: By
Last change:
Date: 2 years ago
Size: 1,838 bytes
 

Contents

Class file image Download
<?php

/**
 * @author AlexanderC
 */

namespace Pyha\Libs\ITest;

/**
 * This is an test example to test the
 * inline testing lib o_O
 *
 * @assert {
 * @params {
 * 'i like strings'
 * }
 * @assertions {
 * $result->foo == 'i like strings'
 * $result->foo->baz == 'hey, we do not have such property'
 * !is_string($result->foo)
 * $result instanceof Pyha\Libs\ITest\Example
 * }
 * }
 */
class Example
{
   
/**
     * @var mixed
     */
   
public $foo;

   
/**
     * @param Application $foo
     */
   
public function __construct($foo)
    {
       
$this->foo = $foo;
    }

   
/**
     * Note that for the method testing is reused class
     * instance from the class test case if method cases
     * are added during the class test case(isset testMethods flag)
     *
     * @param mixed $a
     * @param callable $b
     * @param array $c
     *
     * @assert {
     * @params {
     * 2
     * function(array $arr) { return $arr[0]; }
     * [2]
     * }
     * @assertions {
     * $result == 4
     * segswegw // this is messed thing, but don't worry about!!!
     * is_int($result)
     * !is_scalar($result)
     * }
     * }
     */
   
public function simpleTest($a, callable $b, array $c)
    {
        return
call_user_func($b, $c) + $a;
    }
}

/**
 * @param int $a
 * @param int $b
 * @param array $c
 *
 * @assert {
 * @params {
 * 2
 * 2
 * [2]
 * }
 * @assertions {
 * $result == 6
 * segswegw // this is messed thing, but don't worry about!!!
 * !is_int($result)
 * is_scalar($result)
 * }
 * }
 */
function exampleTestFunction($a, $b, array $c)
{
    return
$a + $b + $c[0];
}