Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhhui committed Mar 9, 2018
1 parent 797a81e commit 9ed9341
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 88 deletions.
6 changes: 2 additions & 4 deletions src/Pool/Config/DbSlavePoolConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Value;
use Swoft\Db\Driver\Driver;
use Swoft\Sg\BalancerSelector;
use Swoft\Sg\ProviderSelector;

/**
* the slave config of database
Expand Down Expand Up @@ -85,15 +83,15 @@ class DbSlavePoolConfig extends DbPoolProperties
* @Value(name="${config.db.slave.balancer}", env="${DB_SLAVE_BALANCER}")
* @var string
*/
protected $balancer = BalancerSelector::TYPE_RANDOM;
protected $balancer = 'random';

/**
* the default provider is consul provider
*
* @Value(name="${config.db.slave.provider}", env="${DB_SLAVE_PROVIDER}")
* @var string
*/
protected $provider = ProviderSelector::TYPE_CONSUL;
protected $provider = 'consul';

/**
* the default driver is mysql
Expand Down
41 changes: 20 additions & 21 deletions test/Testing/Pool/DbEnvPoolConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,97 @@

use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Value;
use Swoft\Sg\BalancerSelector;
use Swoft\Pool\PoolProperties;
use Swoft\Sg\ProviderSelector;

/**
* db env pool config
*
* @Bean()
* @uses DbEnvPoolConfig
* @version 2017年12月18日
* @author stelin <[email protected]>
* @copyright Copyright 2010-2016 swoft software
* @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt}
*/
class DbEnvPoolConfig extends PoolProperties
{
/**
* the name of pool
*
* @Value(env="${DB_NAME}")
*
* @var string
*/
protected $name = "";
protected $name = '';

/**
* the maximum number of idle connections
*
* @Value(env="${DB_MAX_IDEL}")
*
* @var int
*/
protected $maxIdel = 6;

/**
* the maximum number of active connections
*
* @Value(env="${DB_MAX_ACTIVE}")
*
* @var int
*/
protected $maxActive = 50;

/**
* the maximum number of wait connections
*
* @Value(env="${DB_MAX_WAIT}")
*
* @var int
*/
protected $maxWait = 100;

/**
* the time of connect timeout
*
* @Value(env="${DB_TIMEOUT}")
*
* @var int
*/
protected $timeout = 200;

/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
* @Value(env="${DB_URI}")
*
* @var array
*/
protected $uri = [];

/**
* whether to user provider(consul/etcd/zookeeper)
*
* @Value(env="${DB_USE_PROVIDER}")
*
* @var bool
*/
protected $useProvider = false;

/**
* the default balancer is random balancer
*
* @Value(env="${DB_BALANCER}")
*
* @var string
*/
protected $balancer = BalancerSelector::TYPE_RANDOM;
protected $balancer = 'random';

/**
* the default provider is consul provider
*
* @Value(env="${DB_PROVIDER}")
*
* @var string
*/
protected $provider = ProviderSelector::TYPE_CONSUL;
protected $provider = 'consul';

/**
* @return int
*/
public function getMaxIdel(): int
{
return $this->maxIdel;
}
}
43 changes: 22 additions & 21 deletions test/Testing/Pool/DbPptPoolConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,99 @@

use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Value;
use Swoft\Sg\BalancerSelector;
use Swoft\Pool\PoolProperties;
use Swoft\Sg\ProviderSelector;

/**
* db properties pool config
*
* @Bean()
* @uses DbPptPoolConfig
* @version 2017年12月18日
* @author stelin <[email protected]>
* @copyright Copyright 2010-2016 swoft software
* @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt}
*/
class DbPptPoolConfig extends PoolProperties
{
/**
* the name of pool
*
* @Value(name="${config.db.master.name}")
*
* @var string
*/
protected $name = "";
protected $name = '';

/**
* the maximum number of idle connections
*
* @Value(name="${config.db.master.maxIdel}")
*
* @var int
*/
protected $maxIdel = 6;

/**
* the maximum number of active connections
*
* @Value(name="${config.db.master.maxActive}")
*
* @var int
*/
protected $maxActive = 50;

/**
* the maximum number of wait connections
*
* @Value(name="${config.db.master.maxWait}")
*
* @var int
*/
protected $maxWait = 100;

/**
* the time of connect timeout
*
* @Value(name="${config.db.master.timeout}")
*
* @var int
*/
protected $timeout = 200;

/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
* @Value(name="${config.db.master.uri}")
*
* @var array
*/
protected $uri = [];

/**
* whether to user provider(consul/etcd/zookeeper)
*
* @Value(name="${config.db.master.useProvider}")
*
* @var bool
*/
protected $useProvider = false;

/**
* the default balancer is random balancer
*
* @Value(name="${config.db.master.balancer}")
*
* @var string
*/
protected $balancer = BalancerSelector::TYPE_RANDOM;
protected $balancer = 'random';

/**
* the default provider is consul provider
*
* @Value(name="${config.db.master.provider}")
*
* @var string
*/
protected $provider = ProviderSelector::TYPE_CONSUL;
protected $provider = 'consul';

/**
* @return int
*/
public function getMaxIdel(): int
{
return $this->maxIdel;
}


}
41 changes: 20 additions & 21 deletions test/Testing/Pool/DbSlaveEnvPoolConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,97 @@

use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Value;
use Swoft\Sg\BalancerSelector;
use Swoft\Pool\PoolProperties;
use Swoft\Sg\ProviderSelector;

/**
* db slave env pool config
*
* @Bean()
* @uses DbSlaveEnvPoolConfig
* @version 2017年12月18日
* @author stelin <[email protected]>
* @copyright Copyright 2010-2016 swoft software
* @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt}
*/
class DbSlaveEnvPoolConfig extends PoolProperties
{
/**
* the name of pool
*
* @Value(env="${DB_SLAVE_NAME}")
*
* @var string
*/
protected $name = "";
protected $name = '';

/**
* the maximum number of idle connections
*
* @Value(env="${DB_SLAVE_MAX_IDEL}")
*
* @var int
*/
protected $maxIdel = 6;

/**
* the maximum number of active connections
*
* @Value(env="${DB_SLAVE_MAX_ACTIVE}")
*
* @var int
*/
protected $maxActive = 50;

/**
* the maximum number of wait connections
*
* @Value(env="${DB_SLAVE_MAX_WAIT}")
*
* @var int
*/
protected $maxWait = 100;

/**
* the time of connect timeout
*
* @Value(env="${DB_SLAVE_TIMEOUT}")
*
* @var int
*/
protected $timeout = 200;

/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
* @Value(env="${DB_SLAVE_URI}")
*
* @var array
*/
protected $uri = [];

/**
* whether to user provider(consul/etcd/zookeeper)
*
* @Value(env="${DB_SLAVE_USE_PROVIDER}")
*
* @var bool
*/
protected $useProvider = false;

/**
* the default balancer is random balancer
*
* @Value(env="${DB_SLAVE_BALANCER}")
*
* @var string
*/
protected $balancer = BalancerSelector::TYPE_RANDOM;
protected $balancer = 'random';

/**
* the default provider is consul provider
*
* @Value(env="${DB_SLAVE_PROVIDER}")
*
* @var string
*/
protected $provider = ProviderSelector::TYPE_CONSUL;
protected $provider = 'consul';

/**
* @return int
*/
public function getMaxIdel(): int
{
return $this->maxIdel;
}
}
Loading

0 comments on commit 9ed9341

Please sign in to comment.