Task_Runner_Remote_Test.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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__) . '/../bootstrap.php';
  10. class PhpUnderControl_TaskRunnerRemote_Test extends PHPUnit_Framework_TestCase
  11. {
  12. public $taskRunnerRemote;
  13. protected $mq;
  14. protected function setUp()
  15. {
  16. parent::setUp();
  17. $this->mq = new PhalApi\Task\MQ\ArrayMQ();
  18. $this->taskRunnerRemote = new PhalApi\Task\Runner\RemoteRunner($this->mq);
  19. }
  20. protected function tearDown()
  21. {
  22. }
  23. public function testHere()
  24. {
  25. $service1 = 'Default.Index';
  26. $this->mq->add($service1, array('username' => 'phalapi'));
  27. $this->mq->add($service1, array('username' => 'net'));
  28. $service2 = 'WrongUser.GetBaseInfo';
  29. $this->mq->add($service2, array('userId' => 1));
  30. $rs = $this->taskRunnerRemote->go($service1);
  31. $this->assertEquals(2, $rs['total']);
  32. $this->assertEquals(0, $rs['fail']);
  33. $rs = $this->taskRunnerRemote->go($service2);
  34. $this->assertEquals(1, $rs['total']);
  35. $this->assertEquals(1, $rs['fail']);
  36. $rs = $this->taskRunnerRemote->go('TestTaskDemo.Update');
  37. $this->assertEquals(0, $rs['total']);
  38. $this->assertEquals(0, $rs['fail']);
  39. }
  40. }