Skip to content

Commit 907f0a8

Browse files
authored
Improve (#6)
1 parent 549fcd6 commit 907f0a8

File tree

9 files changed

+37
-35
lines changed

9 files changed

+37
-35
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
namespace Tests\Functional\BehatContext;
3+
4+
use Behat\Behat\Context\Context;
5+
6+
class AbstractContext implements Context
7+
{
8+
protected function jsonDecode($encodedData)
9+
{
10+
$decoded = json_decode($encodedData, true);
11+
12+
if (JSON_ERROR_NONE != json_last_error()) {
13+
throw new \Exception(
14+
json_last_error_msg(),
15+
json_last_error()
16+
);
17+
}
18+
19+
return $decoded;
20+
}
21+
}

features/bootstrap/DemoAppContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Defines application features from the specific context.
1717
*/
18-
class DemoAppContext implements Context
18+
class DemoAppContext extends AbstractContext
1919
{
2020
/** @var Response|null */
2121
private $lastResponse;
@@ -65,8 +65,8 @@ public function thenIShouldHaveAResponseFromDemoAppWithFollowingContent($httpCod
6565
Assert::assertInstanceOf(Response::class, $this->lastResponse);
6666
// Decode payload to get ride of indentation, spacing, etc
6767
Assert::assertEquals(
68-
json_decode($payload->getRaw(), true),
69-
json_decode($this->lastResponse->getContent(), true)
68+
$this->jsonDecode($payload->getRaw()),
69+
$this->jsonDecode($this->lastResponse->getContent())
7070
);
7171
Assert::assertSame((int) $httpCode, $this->lastResponse->getStatusCode());
7272
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
framework:
2-
secret: '%env(APP_SECRET)%'
2+
secret: '%env(APP_SECRET)%'
33

4-
json_rpc_http_server: ~
4+
json_rpc_http_server:
5+
endpoint: '/my-custom-endpoint'
56

67
json_rpc_http_server_doc:
7-
endpoint: '/my-custom-doc-endpoint'
8+
endpoint: '/my-custom-doc-endpoint'
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
framework:
2-
secret: '%env(APP_SECRET)%'
2+
secret: '%env(APP_SECRET)%'
33

4-
json_rpc_http_server: ~
4+
json_rpc_http_server:
5+
endpoint: '/my-custom-endpoint'
56

67
json_rpc_http_server_doc:
7-
endpoint: '/my-custom-doc-endpoint'
8+
endpoint: '/my-custom-doc-endpoint'

features/demo_app/config_with_server_doc_created_listener/services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
json_rpc_http_server.alias.method_resolver: '@resolver'
1616

1717
# MethodDocCreated Listener
18-
method_doc_created.listener:
18+
server_doc_created.listener:
1919
class: DemoApp\Listener\ServerDocCreatedListener
2020
tags:
2121
- name: 'kernel.event_listener'
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
framework:
2-
secret: '%env(APP_SECRET)%'
2+
secret: '%env(APP_SECRET)%'
33

4-
json_rpc_http_server: ~
4+
json_rpc_http_server:
5+
endpoint: '/my-custom-endpoint'
56

67
json_rpc_http_server_doc:
7-
endpoint: '/my-custom-doc-endpoint'
8+
endpoint: '/my-custom-doc-endpoint'

tests/Common/DependencyInjection/AbstractTestClass.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
abstract class AbstractTestClass extends AbstractExtensionTestCase
1313
{
1414
const EXPECTED_DOC_PROVIDER_TAG = 'json_rpc_server_doc.doc_provider';
15-
const EXPECTED_EXTENSION_IDENTIFIER = 'json_rpc_http_server_doc';
1615
const EXPECTED_NORMALIZED_DOC_FINDER_SERVICE_ID = 'json_rpc_http_server_doc.finder.normalized_doc';
1716

1817
// Public services

tests/Functional/DependencyInjection/ConfigFilesTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
*/
2222
class ConfigFilesTest extends AbstractTestClass
2323
{
24-
/**
25-
* {@inheritdoc}
26-
*/
27-
protected function getContainerExtensions()
28-
{
29-
return [
30-
new JsonRpcHttpServerDocExtension()
31-
];
32-
}
33-
3424
/**
3525
* @dataProvider provideSDKInfraServiceIdAndClass
3626
* @dataProvider provideBundlePublicServiceIdAndClass

tests/Functional/DependencyInjection/JsonRpcHttpServerDocExtensionTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
*/
1313
class JsonRpcHttpServerDocExtensionTest extends AbstractTestClass
1414
{
15-
/**
16-
* {@inheritdoc}
17-
*/
18-
protected function getContainerExtensions()
19-
{
20-
return [
21-
new JsonRpcHttpServerDocExtension()
22-
];
23-
}
24-
25-
2615
public function testShouldBeLoadable()
2716
{
2817
$this->load();

0 commit comments

Comments
 (0)