diff --git a/composer.json b/composer.json index a99f644..6a9bc6f 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "behat/mink-browserkit-driver": "^2.2", "dantleech/gherkin-lint": "^0.2.3", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "drevops/phpcs-standard": "^0.6", "drupal/coder": "^8.3", "dvdoug/behat-code-coverage": "^5.3", "ergebnis/composer-normalize": "^2.45", @@ -64,11 +65,11 @@ "lint": [ "phpcs", "phpstan", - "rector --clear-cache --dry-run", + "rector --dry-run", "gherkinlint lint tests/behat/features" ], "lint-fix": [ - "rector --clear-cache", + "rector", "phpcbf" ], "reset": "rm -Rf vendor composer.lock", diff --git a/phpcs.xml b/phpcs.xml index 20e227c..e6a3245 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -6,6 +6,7 @@ + diff --git a/tests/phpunit/Unit/ApiServerContextTest.php b/tests/phpunit/Unit/ApiServerContextTest.php index fde29e8..4157daf 100644 --- a/tests/phpunit/Unit/ApiServerContextTest.php +++ b/tests/phpunit/Unit/ApiServerContextTest.php @@ -39,12 +39,12 @@ public function testCreateHttpClient(string $server_url, array $additional_optio ->willReturn($server_url); // Use reflection to call protected createHttpClient method. - $reflectionClass = new \ReflectionClass(ApiServerContext::class); - $createHttpClient = $reflectionClass->getMethod('createHttpClient'); - $createHttpClient->setAccessible(TRUE); + $reflection_class = new \ReflectionClass(ApiServerContext::class); + $create_http_client = $reflection_class->getMethod('createHttpClient'); + $create_http_client->setAccessible(TRUE); // Call the method. - $client = $createHttpClient->invoke($context, $additional_options); + $client = $create_http_client->invoke($context, $additional_options); // Assert the result is a Client instance. $this->assertInstanceOf(Client::class, $client); @@ -86,12 +86,12 @@ public function testPrepareResponse(string $json_input, array $expected_values): ->getMock(); // Use reflection to call protected prepareResponse method. - $reflectionClass = new \ReflectionClass(ApiServerContext::class); - $prepareResponse = $reflectionClass->getMethod('prepareResponse'); - $prepareResponse->setAccessible(TRUE); + $reflection_class = new \ReflectionClass(ApiServerContext::class); + $prepare_response = $reflection_class->getMethod('prepareResponse'); + $prepare_response->setAccessible(TRUE); // Call the method with the test input. - $result = $prepareResponse->invoke($context, $json_input); + $result = $prepare_response->invoke($context, $json_input); // Basic assertions for all cases. $this->assertIsArray($result); @@ -179,15 +179,15 @@ public function testPrepareResponseInvalid(string $json_input, string $exception ->getMock(); // Use reflection to call protected prepareResponse method. - $reflectionClass = new \ReflectionClass(ApiServerContext::class); - $prepareResponse = $reflectionClass->getMethod('prepareResponse'); - $prepareResponse->setAccessible(TRUE); + $reflection_class = new \ReflectionClass(ApiServerContext::class); + $prepare_response = $reflection_class->getMethod('prepareResponse'); + $prepare_response->setAccessible(TRUE); // Test with the given invalid input. if (class_exists($exception_class)) { $this->expectException($exception_class); $this->expectExceptionMessage($exception_message); - $prepareResponse->invoke($context, $json_input); + $prepare_response->invoke($context, $json_input); } else { $this->fail(sprintf('Exception class %s does not exist', $exception_class)); @@ -239,7 +239,7 @@ public function testApiWillRespondWithJson(string $json_content, ?string $code, ->getMock(); // Create a PyStringNode. - $pyStringNode = new PyStringNode([$json_content], 1); + $py_string_node = new PyStringNode([$json_content], 1); // Setup the mock expectation. $context->expects($this->once()) @@ -256,7 +256,7 @@ public function testApiWillRespondWithJson(string $json_content, ?string $code, }); // Call the method. - $context->apiWillRespondWithJson($pyStringNode, $code); + $context->apiWillRespondWithJson($py_string_node, $code); } /** diff --git a/tests/phpunit/Unit/PhpServerContextTest.php b/tests/phpunit/Unit/PhpServerContextTest.php index 08fedb2..8fce8ce 100644 --- a/tests/phpunit/Unit/PhpServerContextTest.php +++ b/tests/phpunit/Unit/PhpServerContextTest.php @@ -66,12 +66,12 @@ public function testIsRunning( } // Use reflection to call protected isRunning method. - $reflectionClass = new \ReflectionClass(PhpServerContext::class); - $isRunningMethod = $reflectionClass->getMethod('isRunning'); - $isRunningMethod->setAccessible(TRUE); + $reflection_class = new \ReflectionClass(PhpServerContext::class); + $is_running_method = $reflection_class->getMethod('isRunning'); + $is_running_method->setAccessible(TRUE); // Call the method and check results. - $result = $isRunningMethod->invoke($mock, $timeout, $retry_delay); + $result = $is_running_method->invoke($mock, $timeout, $retry_delay); $this->assertEquals($expected_result, $result); }