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