Skip to content

Commit c92efe2

Browse files
loevgaardNyholm
authored andcommitted
Updating readme to a more 2019 ish code style (#61)
1 parent 4877914 commit c92efe2

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

README.md

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SymfonyConfigTest
1+
# Symfony Config Test
22

33
*By Matthias Noback and contributors*
44

@@ -12,7 +12,7 @@ validity of the resulting config node tree, this library provides a PHPUnit test
1212

1313
Using Composer:
1414

15-
php composer.phar require --dev matthiasnoback/symfony-config-test
15+
$ composer require --dev matthiasnoback/symfony-config-test
1616

1717
## Usage
1818

@@ -22,11 +22,15 @@ Then implement ``getConfiguration()``:
2222
```php
2323
<?php
2424

25-
class ConfigurationTest extends \PHPUnit_Framework_TestCase
25+
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
26+
use PHPUnit\Framework\TestCase;
27+
use App\Configuration;
28+
29+
class ConfigurationTest extends TestCase
2630
{
2731
use ConfigurationTestCaseTrait;
2832

29-
protected function getConfiguration()
33+
protected function getConfiguration(): Configuration
3034
{
3135
return new Configuration();
3236
}
@@ -45,7 +49,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
4549

4650
class ConfigurationWithRequiredValue implements ConfigurationInterface
4751
{
48-
public function getConfigTreeBuilder()
52+
public function getConfigTreeBuilder(): TreeBuilder
4953
{
5054
$treeBuilder = new TreeBuilder();
5155

@@ -70,16 +74,22 @@ When you provide an empty array as the value for this configuration, you would e
7074
```php
7175
<?php
7276

73-
class ConfigurationTest extends \PHPUnit_Framework_TestCase
77+
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
78+
use PHPUnit\Framework\TestCase;
79+
80+
class ConfigurationTest extends TestCase
7481
{
7582
use ConfigurationTestCaseTrait;
7683

77-
public function testValuesAreInvalidIfRequiredValueIsNotProvided()
84+
/**
85+
* @test
86+
*/
87+
public function values_are_invalid_if_required_value_is_not_provided(): void
7888
{
7989
$this->assertConfigurationIsInvalid(
80-
array(
81-
array() // no values at all
82-
),
90+
[
91+
[] // no values at all
92+
],
8393
'required_value' // (part of) the expected exception message - optional
8494
);
8595
}
@@ -93,18 +103,24 @@ You may also want to verify that after processing an array of configuration valu
93103
```php
94104
<?php
95105

96-
class ConfigurationTest extends \PHPUnit_Framework_TestCase
106+
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
107+
use PHPUnit\Framework\TestCase;
108+
109+
class ConfigurationTest extends TestCase
97110
{
98111
use ConfigurationTestCaseTrait;
99112

100-
public function testProcessedValueContainsRequiredValue()
113+
/**
114+
* @test
115+
*/
116+
public function processed_value_contains_required_value(): void
101117
{
102-
$this->assertProcessedConfigurationEquals(array(
103-
array('required_value' => 'first value'),
104-
array('required_value' => 'last value')
105-
), array(
118+
$this->assertProcessedConfigurationEquals([
119+
['required_value' => 'first value'],
120+
['required_value' => 'last value']
121+
], [
106122
'required_value'=> 'last value'
107-
));
123+
]);
108124
}
109125
}
110126
```
@@ -127,7 +143,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
127143

128144
class ConfigurationWithTwoBranches implements ConfigurationInterface
129145
{
130-
public function getConfigTreeBuilder()
146+
public function getConfigTreeBuilder(): TreeBuilder
131147
{
132148
$treeBuilder = new TreeBuilder();
133149

@@ -164,18 +180,18 @@ provide `array_node_1` as the argument for the `$breadcrumbPath` parameter of th
164180
/**
165181
* @test
166182
*/
167-
public function processed_configuration_for_array_node_1()
183+
public function processed_configuration_for_array_node_1(): void
168184
{
169185
$this->assertProcessedConfigurationEquals(
170186
array(
171-
array('array_node_1' => array('required_value_1' => 'original value')),
172-
array('array_node_1' => array('required_value_1' => 'final value'))
187+
['array_node_1' => ['required_value_1' => 'original value']],
188+
['array_node_1' => ['required_value_1' => 'final value']]
173189
),
174-
array(
175-
'array_node_1' => array(
190+
[
191+
'array_node_1' => [
176192
'required_value_1' => 'final value'
177-
)
178-
),
193+
]
194+
],
179195
// the path of the nodes you want to focus on in this test:
180196
'array_node_1'
181197
);
@@ -201,7 +217,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
201217

202218
class PrototypedConfiguration implements ConfigurationInterface
203219
{
204-
public function getConfigTreeBuilder()
220+
public function getConfigTreeBuilder(): TreeBuilder
205221
{
206222
$treeBuilder = new TreeBuilder();
207223

@@ -231,19 +247,19 @@ requirements on `required_value` node, you can define its path as `array_node.*.
231247
/**
232248
* @test
233249
*/
234-
public function processed_configuration_for_array_node_1()
250+
public function processed_configuration_for_array_node_1(): void
235251
{
236252
$this->assertProcessedConfigurationEquals(
237-
array(
238-
array('array_node' => array('prototype_name' => null)),
239-
),
240-
array(
241-
'array_node' => array(
242-
'prototype_name' => array(
253+
[
254+
['array_node' => ['prototype_name' => null]],
255+
],
256+
[
257+
'array_node' => [
258+
'prototype_name' => [
243259
'default_value' => 'foobar'
244-
)
245-
)
246-
),
260+
]
261+
]
262+
],
247263
// the path of the nodes you want to focus on in this test:
248264
'array_node.*.default_value'
249265
);

0 commit comments

Comments
 (0)