Task_Runner_Local_Test.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * PhpUnderControl_TaskRunnerLocal_Test
  4. *
  5. * 针对 ../../Runner/Local.php Task_Runner_Local 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20150516
  8. */
  9. require_once dirname(__FILE__) . '/../bootstrap.php';
  10. include_once dirname(__FILE__) . '/testtaskdemo.php';
  11. class PhpUnderControl_TaskRunnerLocal_Test extends PHPUnit_Framework_TestCase
  12. {
  13. public $taskRunnerLocal;
  14. public $mq;
  15. protected function setUp()
  16. {
  17. parent::setUp();
  18. $this->mq = new PhalApi\Task\MQ\ArrayMQ();
  19. $this->taskRunnerLocal = new PhalApi\Task\Runner\LocalRunner($this->mq);
  20. }
  21. protected function tearDown()
  22. {
  23. }
  24. public function testHere()
  25. {
  26. $service1 = 'TestTaskDemo.Update1';
  27. $this->mq->add($service1, array('name' => 'phalapi'));
  28. $this->mq->add($service1, array('name' => 'net'));
  29. $service2 = 'TestTaskDemo.Update2';
  30. $this->mq->add($service2, array('id' => 1));
  31. $rs = $this->taskRunnerLocal->go($service1);
  32. $this->assertEquals(2, $rs['total']);
  33. $this->assertEquals(0, $rs['fail']);
  34. $rs = $this->taskRunnerLocal->go($service2);
  35. $this->assertEquals(1, $rs['total']);
  36. $this->assertEquals(1, $rs['fail']);
  37. $rs = $this->taskRunnerLocal->go('TestTaskDemo.Update3');
  38. $this->assertEquals(0, $rs['total']);
  39. $this->assertEquals(0, $rs['fail']);
  40. }
  41. }