<?php
/**
* Created by PhpStorm.
* User: code
* Date: 2018/10/30
* Time: 下午7:58
*/
namespace App\Pool;
use App\Helper\Vendor\PhpunitSyncServiceConnection;
use Swoft\App;
use Swoft\Pool\ConnectionInterface;
use Swoft\Rpc\Client\Service\ServiceConnection;
class ServicePool extends \Swoft\Rpc\Client\Pool\ServicePool
{
public static $phpunitBool = false;
public function createConnection(): ConnectionInterface
{
if (static::$phpunitBool){ // 兼容phpunit
if (!App::isCoContext()){ // 进入
return new PhpunitSyncServiceConnection($this);
}else if (App::isCoContext()) { // 照旧
return new ServiceConnection($this);
}
}
return parent::createConnection();
}
}