You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Task_Runner_Remote_Test.php 1.4 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * PhpUnderControl_TaskRunnerRemote_Test
  4. *
  5. * 针对 ../../Runner/Remote.php Task_Runner_Remote 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20150516
  8. */
  9. require_once dirname(__FILE__) . '/../test_env.php';
  10. if (!class_exists('Task_Runner_Remote')) {
  11. require dirname(__FILE__) . '/../../Runner/Remote.php';
  12. }
  13. class PhpUnderControl_TaskRunnerRemote_Test extends PHPUnit_Framework_TestCase
  14. {
  15. public $taskRunnerRemote;
  16. protected $mq;
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. $this->mq = new Task_MQ_Array();
  21. $this->taskRunnerRemote = new Task_Runner_Remote($this->mq);
  22. }
  23. protected function tearDown()
  24. {
  25. }
  26. public function testHere()
  27. {
  28. $service1 = 'Default.Index';
  29. $this->mq->add($service1, array('username' => 'phalapi'));
  30. $this->mq->add($service1, array('username' => 'net'));
  31. $service2 = 'WrongUser.GetBaseInfo';
  32. $this->mq->add($service2, array('userId' => 1));
  33. $rs = $this->taskRunnerRemote->go($service1);
  34. $this->assertEquals(2, $rs['total']);
  35. $this->assertEquals(0, $rs['fail']);
  36. $rs = $this->taskRunnerRemote->go($service2);
  37. $this->assertEquals(1, $rs['total']);
  38. $this->assertEquals(1, $rs['fail']);
  39. $rs = $this->taskRunnerRemote->go('TestTaskDemo.Update');
  40. $this->assertEquals(0, $rs['total']);
  41. $this->assertEquals(0, $rs['fail']);
  42. }
  43. }