PHP Test Class

Source: Internet
Author: User
Today wrote a test of the PHP class.

This is convenient for unit testing. But for the parameter processing, I feel the code is very ugly, there is no expert to help, beautify it.

Parameters are always not dynamic.

Call Test ("365", $className, "DateDiff", Array ("2013-8-4", "2012-8-4"));

1#region Test 2 3
4 function Test ($expected, $className, $functionName, $parameteres)
5 {
6
7 switch (s Izeof ($parameteres))
8 {
9 case 0:
Ten $actual = Call_user_func (Array ($className, $functionName));
Break one by one;
Case 1:
$actual = Call_user_func (Array ($className, $functionName), $parameteres [0]);
break;
Case 2:
$actual = Call_user_func (Array ($className, $functionName), $parameteres [0], $parameteres [1]);
break;
Case 3:
$actual = Call_user_func (Array ($className, $functionName), $parameteres [0], $parameteres [1],$ PARAMETERES[2]);
break;
+
($expected = = $actual)
@
echo "passed Result: $functionName Expected: $expected vs actual $actual
";
"
"
{
echo "failed Result: $functionName expected: $expected vs AC Tual $actual
";


to

#endregion

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.