Skip to content

Commit

Permalink
[TEST] convert array() to [] syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mhujer committed Aug 11, 2017
1 parent 9ecf827 commit aef3821
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 74 deletions.
12 changes: 6 additions & 6 deletions tests/Elasticsearch/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ public function testConstructorIllegalPort()

public function testCustomQueryParams()
{
$params = array();
$params = [];

$client = Elasticsearch\ClientBuilder::create()->setHosts([$_SERVER['ES_TEST_HOST']])->build();

$getParams = array(
$getParams = [
'index' => 'test',
'type' => 'test',
'id' => 1,
'parent' => 'abc',
'custom' => array('customToken' => 'abc', 'otherToken' => 123),
'custom' => ['customToken' => 'abc', 'otherToken' => 123],
'client' => ['ignore' => 400]
);
];
$exists = $client->exists($getParams);
}

Expand Down Expand Up @@ -227,15 +227,15 @@ public function testMaxRetriesException()
->setRetries(0)
->build();

$searchParams = array(
$searchParams = [
'index' => 'test',
'type' => 'test',
'body' => [
'query' => [
'match_all' => []
]
]
);
];

$client = Elasticsearch\ClientBuilder::create()
->setHosts(["localhost:1"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testTenConnections()
{
$roundRobin = new Elasticsearch\ConnectionPool\Selectors\RoundRobinSelector();

$mockConnections = array();
$mockConnections = [];
foreach (range(0, 10) as $index) {
$mockConnections[$index] = $this->getMockBuilder('\Elasticsearch\Connections\CurlMultiConnection')
->disableOriginalConstructor()
Expand All @@ -56,7 +56,7 @@ public function testAddTenConnectionsestFiveTRemoveThree()
{
$roundRobin = new Elasticsearch\ConnectionPool\Selectors\RoundRobinSelector();

$mockConnections = array();
$mockConnections = [];
foreach (range(0, 10) as $index) {
$mockConnections[$index] = $this->getMockBuilder('\Elasticsearch\Connections\CurlMultiConnection')
->disableOriginalConstructor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testTenConnections()
{
$roundRobin = new Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector();

$mockConnections = array();
$mockConnections = [];
$mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection')
->shouldReceive('isAlive')->times(16)->andReturn(true)->getMock();

Expand All @@ -47,7 +47,7 @@ public function testTenConnectionsFirstDies()
{
$roundRobin = new Elasticsearch\ConnectionPool\Selectors\StickyRoundRobinSelector();

$mockConnections = array();
$mockConnections = [];
$mockConnections[] = m::mock('\Elasticsearch\Connections\GuzzleConnection')
->shouldReceive('isAlive')->once()->andReturn(false)->getMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testAddOneHostThenGetConnection()
->andReturn(true)
->getMock();

$connections = array($mockConnection);
$connections = [$mockConnection];

$selector = m::mock(RoundRobinSelector::class)
->shouldReceive('select')
Expand All @@ -47,7 +47,7 @@ public function testAddOneHostThenGetConnection()

$connectionFactory = m::mock(ConnectionFactory::class);

$connectionPoolParams = array('randomizeHosts' => false);
$connectionPoolParams = ['randomizeHosts' => false];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -65,7 +65,7 @@ public function testAddOneHostAndTriggerSniff()
->shouldReceive('getTransportSchema')->once()->andReturn('http')->getMock()
->shouldReceive('sniff')->once()->andReturn($clusterState)->getMock();

$connections = array($mockConnection);
$connections = [$mockConnection];
$mockNewConnection = m::mock(Connection::class)
->shouldReceive('isAlive')->andReturn(true)->getMock();

Expand All @@ -75,12 +75,12 @@ public function testAddOneHostAndTriggerSniff()
->getMock();

$connectionFactory = m::mock(ConnectionFactory::class)
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9200))->andReturn($mockNewConnection)->getMock();
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9200])->andReturn($mockNewConnection)->getMock();

$connectionPoolParams = array(
$connectionPoolParams = [
'randomizeHosts' => false,
'sniffingInterval' => -1
);
];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -98,7 +98,7 @@ public function testAddOneHostAndForceNext()
->shouldReceive('getTransportSchema')->once()->andReturn('http')->getMock()
->shouldReceive('sniff')->once()->andReturn($clusterState)->getMock();

$connections = array($mockConnection);
$connections = [$mockConnection];
$mockNewConnection = m::mock(Connection::class)
->shouldReceive('isAlive')->andReturn(true)->getMock();

Expand All @@ -107,11 +107,11 @@ public function testAddOneHostAndForceNext()
->shouldReceive('select')->once()->andReturn($mockNewConnection)->getMock();

$connectionFactory = m::mock(ConnectionFactory::class)
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9200))->andReturn($mockNewConnection)->getMock();
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9200])->andReturn($mockNewConnection)->getMock();

$connectionPoolParams = array(
$connectionPoolParams = [
'randomizeHosts' => false
);
];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection(true);
Expand All @@ -121,7 +121,7 @@ public function testAddOneHostAndForceNext()

public function testAddTenNodesThenGetConnection()
{
$connections = array();
$connections = [];

foreach (range(1, 10) as $index) {
$mockConnection = m::mock(Connection::class)
Expand All @@ -142,7 +142,7 @@ public function testAddTenNodesThenGetConnection()

$connectionFactory = m::mock(ConnectionFactory::class);

$connectionPoolParams = array('randomizeHosts' => false);
$connectionPoolParams = ['randomizeHosts' => false];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -152,7 +152,7 @@ public function testAddTenNodesThenGetConnection()

public function testAddTenNodesTimeoutAllButLast()
{
$connections = array();
$connections = [];

foreach (range(1, 9) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down Expand Up @@ -183,7 +183,7 @@ public function testAddTenNodesTimeoutAllButLast()

$connectionFactory = m::mock(ConnectionFactory::class);

$connectionPoolParams = array('randomizeHosts' => false);
$connectionPoolParams = ['randomizeHosts' => false];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -196,7 +196,7 @@ public function testAddTenNodesTimeoutAllButLast()
*/
public function testAddTenNodesAllTimeout()
{
$connections = array();
$connections = [];

foreach (range(1, 10) as $index) {
$mockConnection = m::mock(Connection::class)
Expand All @@ -217,7 +217,7 @@ public function testAddTenNodesAllTimeout()

$connectionFactory = m::mock(ConnectionFactory::class);

$connectionPoolParams = array('randomizeHosts' => false);
$connectionPoolParams = ['randomizeHosts' => false];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -233,9 +233,9 @@ public function testAddOneHostSniffTwo()
->shouldReceive('getTransportSchema')->twice()->andReturn('http')->getMock()
->shouldReceive('sniff')->twice()->andReturn($clusterState)->getMock();

$connections = array($mockConnection);
$connections = [$mockConnection];

$newConnections = array();
$newConnections = [];
$newConnections[] = m::mock(Connection::class)
->shouldReceive('isAlive')->andReturn(true)->getMock();

Expand All @@ -244,21 +244,21 @@ public function testAddOneHostSniffTwo()

$selector = m::mock(RoundRobinSelector::class)
->shouldReceive('select')
->andReturnValues(array( //selects provided node first, then the new cluster list
->andReturnValues([ //selects provided node first, then the new cluster list
$mockConnection,
$newConnections[0],
$newConnections[1]
))
])
->getMock();

$connectionFactory = m::mock(ConnectionFactory::class)
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9200))->andReturn($newConnections[0])->getMock()
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9201))->andReturn($newConnections[1])->getMock();
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9200])->andReturn($newConnections[0])->getMock()
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9201])->andReturn($newConnections[1])->getMock();

$connectionPoolParams = array(
$connectionPoolParams = [
'randomizeHosts' => false,
'sniffingInterval' => -1
);
];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -281,9 +281,9 @@ public function testAddSeed_SniffTwo_TimeoutTwo()
->shouldReceive('getTransportSchema')->once()->andReturn('http')->getMock()
->shouldReceive('sniff')->once()->andReturn($clusterState)->getMock();

$connections = array($mockConnection);
$connections = [$mockConnection];

$newConnections = array();
$newConnections = [];
$newConnections[] = m::mock(Connection::class)
->shouldReceive('isAlive')->andReturn(false)->getMock()
->shouldReceive('ping')->andReturn(false)->getMock();
Expand All @@ -294,21 +294,21 @@ public function testAddSeed_SniffTwo_TimeoutTwo()

$selector = m::mock(RoundRobinSelector::class)
->shouldReceive('select')
->andReturnValues(array( //selects provided node first, then the new cluster list
->andReturnValues([ //selects provided node first, then the new cluster list
$mockConnection,
$newConnections[0],
$newConnections[1]
))
])
->getMock();

$connectionFactory = m::mock(ConnectionFactory::class)
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9200))->andReturn($newConnections[0])->getMock()
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9201))->andReturn($newConnections[1])->getMock();
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9200])->andReturn($newConnections[0])->getMock()
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9201])->andReturn($newConnections[1])->getMock();

$connectionPoolParams = array(
$connectionPoolParams = [
'randomizeHosts' => false,
'sniffingInterval' => -1
);
];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -319,7 +319,7 @@ public function testTen_TimeoutNine_SniffTenth_AddTwoAlive()
{
$clusterState = json_decode('{"ok":true,"cluster_name":"elasticsearch_zach","nodes":{"node1":{"name":"Vesta","transport_address":"inet[/192.168.1.119:9300]","hostname":"zach-ThinkPad-W530","version":"0.90.5","http_address":"inet[/192.168.1.119:9200]"}, "node2":{"name":"Vesta","transport_address":"inet[/192.168.1.119:9301]","hostname":"zach-ThinkPad-W530","version":"0.90.5","http_address":"inet[/192.168.1.119:9201]"}}}', true);

$connections = array();
$connections = [];

foreach (range(1, 10) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down Expand Up @@ -353,13 +353,13 @@ public function testTen_TimeoutNine_SniffTenth_AddTwoAlive()
->getMock();

$connectionFactory = m::mock(ConnectionFactory::class)
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9200))->andReturn($newConnections[10])->getMock()
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9201))->andReturn($newConnections[11])->getMock();
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9200])->andReturn($newConnections[10])->getMock()
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9201])->andReturn($newConnections[11])->getMock();

$connectionPoolParams = array(
$connectionPoolParams = [
'randomizeHosts' => false,
'sniffingInterval' => -1
);
];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand All @@ -376,7 +376,7 @@ public function testTen_TimeoutNine_SniffTenth_AddTwoDead_TimeoutEveryone()
{
$clusterState = json_decode('{"ok":true,"cluster_name":"elasticsearch_zach","nodes":{"node1":{"name":"Vesta","transport_address":"inet[/192.168.1.119:9300]","hostname":"zach-ThinkPad-W530","version":"0.90.5","http_address":"inet[/192.168.1.119:9200]"}, "node2":{"name":"Vesta","transport_address":"inet[/192.168.1.119:9301]","hostname":"zach-ThinkPad-W530","version":"0.90.5","http_address":"inet[/192.168.1.119:9201]"}}}', true);

$connections = array();
$connections = [];

foreach (range(1, 10) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down Expand Up @@ -415,13 +415,13 @@ public function testTen_TimeoutNine_SniffTenth_AddTwoDead_TimeoutEveryone()
$RRConnections = $newConnections;
//array_push($connections);
$connectionFactory = m::mock(ConnectionFactory::class)
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9200))->andReturn($newConnections[10])->getMock()
->shouldReceive('create')->with(array('host' => '192.168.1.119', 'port' => 9201))->andReturn($newConnections[11])->getMock();
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9200])->andReturn($newConnections[10])->getMock()
->shouldReceive('create')->with(['host' => '192.168.1.119', 'port' => 9201])->andReturn($newConnections[11])->getMock();

$connectionPoolParams = array(
$connectionPoolParams = [
'randomizeHosts' => false,
'sniffingInterval' => -1
);
];
$connectionPool = new SniffingConnectionPool($connections, $selector, $connectionFactory, $connectionPoolParams);

$retConnection = $connectionPool->nextConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testAddOneHostThenGetConnection()
->getMock()
->shouldReceive('markDead')->once()->getMock();

$connections = array($mockConnection);
$connections = [$mockConnection];

$selector = m::mock(RoundRobinSelector::class)
->shouldReceive('select')
Expand All @@ -58,7 +58,7 @@ public function testAddOneHostThenGetConnection()

public function testAddMultipleHostsThenGetFirst()
{
$connections = array();
$connections = [];

foreach (range(1, 10) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down Expand Up @@ -93,7 +93,7 @@ public function testAddMultipleHostsThenGetFirst()
*/
public function testAllHostsFailPing()
{
$connections = array();
$connections = [];

foreach (range(1, 10) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down Expand Up @@ -125,7 +125,7 @@ public function testAllHostsFailPing()

public function testAllExceptLastHostFailPingRevivesInSkip()
{
$connections = array();
$connections = [];

foreach (range(1, 9) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down Expand Up @@ -171,7 +171,7 @@ public function testAllExceptLastHostFailPingRevivesInSkip()

public function testAllExceptLastHostFailPingRevivesPreSkip()
{
$connections = array();
$connections = [];

foreach (range(1, 9) as $index) {
$mockConnection = m::mock(Connection::class)
Expand Down
Loading

0 comments on commit aef3821

Please sign in to comment.