Recommend this page to a friend! |
Download .zip |
Info | View files (4) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2012-10-12 (4 years ago) | Not yet rated by the users | Total: 279 | All time: 7,170 This week: 1,040 |
Version | License | PHP version | Categories | |||
inline-testing 0.1.0 | GNU General Publi... | 5.4 | PHP 5, Testing |
Description | Author | |||
This class can test classes and fuctions using docblock comments. Innovation Award
|
=== What are you doing here? === [?] What are lnline tests? [!] That's an simple test case that is done directly at the runtime(certainly must be only in dev environment). Test data is parsed from docblock === The goal === Except expensive unit tests, you can also test in very simple way without running any daemon or even console application. You should only use docblock sections and add class testing to your autoloader or use testable trait. $inlineTester = Testing\InlineTesting::getInstance(/* false to avoid testing, for ex. in prod environment */); $inlineTester->testClass("Foo"); // this will test all methods from the class where are docblock @assert sections found $inlineTester->testFunction("myFunc"); // this will test the function if any docblock entry there In order to use Testable trait you have to add it o_O: class Foo { use Testing\Traits\Testable; /** * This method will be tested * Note: the inline test will pass, but if not it will trigger an informative error * * @param int $foo * @param int $bar * @param array $things * @return int * * @assert 2 and "2" and [1, 2, 3] equals 7 */ private /* or protected even public */ function myMethod($foo, $bar, array $things = []){ return (int) $foo + (int) $bar + count($things); } private /* or public, does not matter */ function onAfterDestruct(){ // that is your destructor from now, because __destruct() is preserved by the Testable trait // now you do not have to call testClass method each time you wanna test your classes } } |
Files |
File | Role | Description | ||
---|---|---|---|---|
Traits (2 files) | ||||
InlineTesting.php | Class | Class source | ||
README.md | Doc. | Documentation |
Files | / | Traits |
File | Role | Description |
---|---|---|
Singleton.php | Class | Class source |
Testable.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.