Skip to content
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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<exclude name="Drupal.Files.LineLength.TooLong"/>
</rule>
<rule ref="Generic.PHP.RequireStrictTypes"/>
<rule ref="DrevOps"/>

<arg name="colors"/>
<arg value="sp"/>
Expand Down
28 changes: 14 additions & 14 deletions tests/phpunit/Unit/ApiServerContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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())
Expand All @@ -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);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/Unit/PhpServerContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down