From 946cd65ee687787fa1f4aedf797260c8fe478230 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Tue, 12 Sep 2017 16:18:24 +0200 Subject: [PATCH] [TEST] add PHPStan to build (#628) * PHPUnit 5.7.21 + update config + fix risky tests * PHPUnit 6.3.0 * use $this->expectException instead of annotation * [TEST] fixes of issues detected by phpstan * phpstan setup --- phpstan.neon | 9 +++++++++ .../Tests/ConnectionPool/StaticConnectionPoolTest.php | 3 +++ tests/Elasticsearch/Tests/YamlRunnerTest.php | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..8c29546c7 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,9 @@ +parameters: + ignoreErrors: + - '#Mockery\\MockInterface::shouldReceive\(\)#' + - '#Mockery\\MockInterface given#' + - '#Mockery\\MockInterface\[\] given#' + + # because of \Elasticsearch\Tests\RegisteredNamespaceTest + - '#Call to an undefined method Elasticsearch\\Client::foo\(\)#' + - '#Call to an undefined method Elasticsearch\\Client::bar\(\)#' diff --git a/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php b/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php index 25223c95c..a87768869 100644 --- a/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php +++ b/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php @@ -126,6 +126,9 @@ public function testAllHostsFailPing() $this->expectException(\Elasticsearch\Common\Exceptions\NoNodesAvailableException::class); $this->expectExceptionMessage('No alive nodes found in your cluster'); + $this->expectException(\Elasticsearch\Common\Exceptions\NoNodesAvailableException::class); + $this->expectExceptionMessage('No alive nodes found in your cluster'); + $connectionPool->nextConnection(); } diff --git a/tests/Elasticsearch/Tests/YamlRunnerTest.php b/tests/Elasticsearch/Tests/YamlRunnerTest.php index 9348059d2..be8bf2fb4 100644 --- a/tests/Elasticsearch/Tests/YamlRunnerTest.php +++ b/tests/Elasticsearch/Tests/YamlRunnerTest.php @@ -169,7 +169,7 @@ public function testAsyncIntegration($testProcedure, $skip, $setupProcedure, $fi } if (null !== $setupProcedure) { - $this->processProcedure(current($setupProcedure), 'setup'); + $this->processProcedure(current($setupProcedure), 'setup', $fileName); $this->waitForYellow(); } @@ -326,6 +326,9 @@ public function operationDo($operation, $lastOperationResult, &$context, $testNa $endpointParams->client['headers'] = $headers; } + if (!is_string($method)) { + throw new \Exception('$method must be string'); + } list($method, $namespace) = $this->mapEndpoint($method, $namespace); if (null !== $namespace) { @@ -404,7 +407,7 @@ public function executeRequest($caller, $method, $endpointParams, $expectedError * * @throws \Exception * - * @return bool + * @return bool|mixed[] */ public function executeAsyncExistRequest($caller, $method, $endpointParams, $expectedError, $expectedWarnings, $testName) {