Skip to content

不带use \Think\PhpUnit;时测model会报错 #8

Open
@robbinhan

Description

@robbinhan

按照文档上写usermodel测试类,起初没有带use \Think\PhpUnit;,是有抛异常的应该


PHP Fatal error:  Uncaught TypeError: Argument 2 passed to PHPUnit_Framework_TestResult::addError() must be an instance of Exception, instance of Error given, called in /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestSuite.php on line 699 and defined in /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestResult.php:195
Stack trace:

#0 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestSuite.php(699): PHPUnit_Framework_TestResult->addError(Object(PHPUnit_Framework_TestSuite), Object(Error), 0)

Fatal error: Uncaught TypeError: Argument 2 passed to PHPUnit_Framework_TestResult::addError() must be an instance of Exception, instance of Error given, called in /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestSuite.php on line 699 and defined in /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestResult.php:195#1 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
Stack trace:
#0 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestSuite.php(699): PHPUnit_Framework_TestResult->addError(Object(PHPUnit_Framework_TestSuite), Object(Error), 0)

#1 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))#2 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#2 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#3 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/TextUI/Command.ph in /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestResult.php on line 195
#3 /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/TextUI/Command.ph in /Users/robbin/Downloads/thinkphp_3.2.3_full/vendor/phpunit/phpunit/src/Framework/TestResult.php on line 195

带上后测试就没问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions