/var/www/hkosl.com/imusiccircle/webadmin/libraies/php-console/php-console/tests/Test/Dispatcher.php


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
<?php

namespace PhpConsole\Test;

abstract class 
Dispatcher extends Test {

    
/** @var \PhpConsole\Connector|\PHPUnit_Framework_MockObject_MockObject */
    
protected $connector;
    
/** @var \PhpConsole\Dispatcher|\PHPUnit_Framework_MockObject_MockObject */
    
protected $dispatcher;
    protected 
$isDispatcherActive true;

    
/**
     * @param \PhpConsole\Connector $connector
     * @return \PHPUnit_Framework_MockObject_MockObject
     */
    
abstract protected function initDispatcher(\PhpConsole\Connector $connector);

    protected function 
setUp() {
        
parent::setUp();
        
$this->connector $this->initConnectorMock();
        
$this->dispatcher $this->initDispatcher($this->connector);
    }

    protected function 
initConnectorMock() {
        
$connector $this->getMockBuilder('\PhpConsole\Connector')
            ->
disableOriginalConstructor()
            ->
setMethods(array('sendMessage''isActiveClient'))
            ->
getMock();

        
$isDispatcherActive =& $this->isDispatcherActive;
        
$connector->expects($this->any())
            ->
method('isActiveClient')
            ->
will($this->returnCallback(function () use (&$isDispatcherActive) {
                return 
$isDispatcherActive;
            }));

        return 
$connector;
    }
}