Test.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2015 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\testing\command;
  12. use PHPUnit_TextUI_Command;
  13. use PHPUnit_Util_Blacklist;
  14. use think\console\Command;
  15. use think\console\Input;
  16. use think\console\Output;
  17. use think\Loader;
  18. use think\Session;
  19. class Test extends Command
  20. {
  21. public function configure()
  22. {
  23. $this->setName('unit')->setDescription('phpunit')->ignoreValidationErrors();
  24. }
  25. public function execute(Input $input, Output $output)
  26. {
  27. //注册命名空间
  28. Loader::addNamespace('tests', ROOT_PATH . 'tests');
  29. Session::init();
  30. $argv = $_SERVER['argv'];
  31. array_shift($argv);
  32. array_shift($argv);
  33. array_unshift($argv, 'phpunit');
  34. PHPUnit_Util_Blacklist::$blacklistedClassNames = [];
  35. $code = (new PHPUnit_TextUI_Command())->run($argv, false);
  36. return $code;
  37. }
  38. }