Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] improve code quality of tests #610

Merged
merged 5 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/Elasticsearch/Tests/ClientTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests;

use Elasticsearch;
use Elasticsearch\ClientBuilder;
use Elasticsearch\Connections\Connection;
use Mockery as m;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\ConnectionPool\Selectors;

use Elasticsearch;
Expand Down Expand Up @@ -43,7 +45,7 @@ public function testTenConnections()
}

/**
* Add Ten connections, select five, remove thre, test another 10 to check
* Add Ten connections, select five, remove three, test another 10 to check
* that the round-robining works after removing connections
*
* @covers \Elasticsearch\ConnectionPool\Selectors\RoundRobinSelector::select
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\ConnectionPool\Selectors;

use Elasticsearch;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\ConnectionPool;

use Elasticsearch\ClientBuilder;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
declare(strict_types = 1);

namespace Elasticsearch\Tests\ConnectionPool;

use Elasticsearch\ConnectionPool\SniffingConnectionPool;
use Mockery as m;

Expand Down Expand Up @@ -185,7 +188,7 @@ public function testAddTenNodesTimeoutAllButLast()
}

/**
* @expectedException Elasticsearch\Common\Exceptions\NoNodesAvailableException
* @expectedException \Elasticsearch\Common\Exceptions\NoNodesAvailableException
*/
public function testAddTenNodesAllTimeout()
{
Expand Down Expand Up @@ -262,7 +265,7 @@ public function testAddOneHostSniffTwo()
}

/**
* @expectedException Elasticsearch\Common\Exceptions\NoNodesAvailableException
* @expectedException \Elasticsearch\Common\Exceptions\NoNodesAvailableException
*/
public function testAddSeed_SniffTwo_TimeoutTwo()
{
Expand Down Expand Up @@ -363,7 +366,7 @@ public function testTen_TimeoutNine_SniffTenth_AddTwoAlive()
}

/**
* @expectedException Elasticsearch\Common\Exceptions\NoNodesAvailableException
* @expectedException \Elasticsearch\Common\Exceptions\NoNodesAvailableException
*/
public function testTen_TimeoutNine_SniffTenth_AddTwoDead_TimeoutEveryone()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\ConnectionPool;

use Elasticsearch;
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
use Mockery as m;

/**
Expand Down Expand Up @@ -84,7 +85,7 @@ public function testAddMultipleHostsThenGetFirst()
}

/**
* @expectedException Elasticsearch\Common\Exceptions\NoNodesAvailableException
* @expectedException \Elasticsearch\Common\Exceptions\NoNodesAvailableException
*/
public function testAllHostsFailPing()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/Elasticsearch/Tests/Endpoints/AbstractEndpointTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\Endpoints;

use Elasticsearch\Endpoints\AbstractEndpoint;
Expand All @@ -18,7 +20,7 @@ public static function invalidParameters()

/**
* @dataProvider invalidParameters
* @expectedException Elasticsearch\Common\Exceptions\UnexpectedValueException
* @expectedException \Elasticsearch\Common\Exceptions\UnexpectedValueException
*/
public function testInvalidParamsCauseErrorsWhenProvidedToSetParams(array $params)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\Helper\Iterators;

use Elasticsearch\Helper\Iterators\SearchResponseIterator;
Expand Down
4 changes: 3 additions & 1 deletion tests/Elasticsearch/Tests/RegisteredNamespaceTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests;

use Elasticsearch;
Expand Down Expand Up @@ -62,4 +64,4 @@ public function fooMethod()
{
return "123";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\Serializers;

use Elasticsearch\Serializers\ArrayToJSONSerializer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests\Serializers;

use Elasticsearch\Serializers\EverythingToJSONSerializer;
Expand Down
10 changes: 5 additions & 5 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace Elasticsearch\Tests;

use Doctrine\Common\Inflector\Inflector;
Expand All @@ -12,11 +14,9 @@
use Elasticsearch\Common\Exceptions\ServerErrorResponseException;
use Elasticsearch\Common\Exceptions\RoutingMissingException;
use GuzzleHttp\Ring\Future\FutureArrayInterface;
use stdClass;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Yaml;

/**
Expand All @@ -31,7 +31,7 @@
*/
class YamlRunnerTest extends \PHPUnit_Framework_TestCase
{
/** @var Parser Yaml parser for reading integrations tests */
/** @var \Symfony\Component\Yaml\Yaml Yaml parser for reading integrations tests */
private $yaml;

/** @var Elasticsearch\Client client used by elasticsearch */
Expand Down Expand Up @@ -1029,8 +1029,8 @@ private function waitForYellow()
++$counter;

if ($counter > 10) {
$this->log("Aborting test due to failure in clearing cluster.\n");
$this->log(print_r($response, true));
echo "Aborting test due to failure in clearing cluster.\n";
echo print_r($response, true);
exit;
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

error_reporting(E_ALL | E_STRICT);

// Set the default timezone. While this doesn't cause any tests to fail, PHP
Expand Down
2 changes: 2 additions & 0 deletions util/EnsureClusterAlive.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

error_reporting(E_ALL | E_STRICT);

// Set the default timezone. While this doesn't cause any tests to fail, PHP
Expand Down
2 changes: 2 additions & 0 deletions util/RestSpecRunner.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

error_reporting(E_ALL | E_STRICT);

// Set the default timezone. While this doesn't cause any tests to fail, PHP
Expand Down
2 changes: 2 additions & 0 deletions util/SpecParser.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

declare(strict_types = 1);

require_once '../vendor/autoload.php';

$loader = new Twig_Loader_Filesystem('templates');
Expand Down