Skip to content

Commit 44b215e

Browse files
committed
Highlight code examples
1 parent 43df498 commit 44b215e

File tree

1 file changed

+61
-55
lines changed

1 file changed

+61
-55
lines changed

README.md

Lines changed: 61 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ JSON assertions for PHPUnit includes traits/methods to help validate your JSON d
2020

2121
or in your `composer.json`:
2222

23-
{
24-
"require-dev": {
25-
"estahn/phpunit-json-assertions": "@stable"
26-
}
23+
```json
24+
{
25+
"require-dev": {
26+
"estahn/phpunit-json-assertions": "@stable"
2727
}
28+
}
29+
```
2830

2931
## Asserts
3032

@@ -40,70 +42,74 @@ You can either use the `trait` or `class` version.
4042

4143
### Trait
4244

43-
<?php
44-
45-
namespace EnricoStahn\JsonAssert\Tests;
46-
47-
use EnricoStahn\JsonAssert\Assert as JsonAssert;
45+
```php
46+
<?php
47+
48+
namespace EnricoStahn\JsonAssert\Tests;
49+
50+
use EnricoStahn\JsonAssert\Assert as JsonAssert;
51+
52+
class MyTestCase extends \PHPUnit_Framework_TestCase
53+
{
54+
use JsonAssert;
4855

49-
class MyTestCase extends \PHPUnit_Framework_TestCase
56+
public function testJsonDocumentIsValid()
5057
{
51-
use JsonAssert;
52-
53-
public function testJsonDocumentIsValid()
54-
{
55-
// my-schema.json
56-
//
57-
// {
58-
// "type" : "object",
59-
// "properties" : {
60-
// "foo" : {
61-
// "type" : "integer"
62-
// }
63-
// },
64-
// "required" : [ "foo" ]
65-
// }
58+
// my-schema.json
59+
//
60+
// {
61+
// "type" : "object",
62+
// "properties" : {
63+
// "foo" : {
64+
// "type" : "integer"
65+
// }
66+
// },
67+
// "required" : [ "foo" ]
68+
// }
69+
70+
$json = json_decode('{"foo":1}');
6671

67-
$json = json_decode('{"foo":1}');
68-
69-
$this->assertJsonMatchesSchemaString('./my-schema.json', $json);
70-
$this->assertJsonValueEquals(1, '* | [0]', $json);
71-
}
72+
$this->assertJsonMatchesSchemaString('./my-schema.json', $json);
73+
$this->assertJsonValueEquals(1, '* | [0]', $json);
7274
}
75+
}
76+
```
7377

7478
### Class
7579

7680
In case you don't want to use the `trait` you can use the provided class wich extends from `\PHPUnit_Framework_TestCase`.
7781
You can either extend your test case or use the static methods like below.
7882

79-
<?php
80-
81-
namespace EnricoStahn\JsonAssert\Tests;
82-
83-
use EnricoStahn\JsonAssert\AssertClass as JsonAssert;
84-
85-
class MyTestCase extends \PHPUnit_Framework_TestCase
83+
```php
84+
<?php
85+
86+
namespace EnricoStahn\JsonAssert\Tests;
87+
88+
use EnricoStahn\JsonAssert\AssertClass as JsonAssert;
89+
90+
class MyTestCase extends \PHPUnit_Framework_TestCase
91+
{
92+
public function testJsonDocumentIsValid()
8693
{
87-
public function testJsonDocumentIsValid()
88-
{
89-
// my-schema.json
90-
//
91-
// {
92-
// "type" : "object",
93-
// "properties" : {
94-
// "foo" : {
95-
// "type" : "integer"
96-
// }
97-
// },
98-
// "required" : [ "foo" ]
99-
// }
94+
// my-schema.json
95+
//
96+
// {
97+
// "type" : "object",
98+
// "properties" : {
99+
// "foo" : {
100+
// "type" : "integer"
101+
// }
102+
// },
103+
// "required" : [ "foo" ]
104+
// }
105+
106+
$json = json_decode('{"foo":1}');
100107

101-
$json = json_decode('{"foo":1}');
102-
103-
JsonAssert::assertJsonMatchesSchemaString('./my-schema.json', $json);
104-
JsonAssert::assertJsonValueEquals(1, '* | [0]', $json);
105-
}
108+
JsonAssert::assertJsonMatchesSchemaString('./my-schema.json', $json);
109+
JsonAssert::assertJsonValueEquals(1, '* | [0]', $json);
106110
}
111+
}
112+
```
107113

108114
## Tests
109115

0 commit comments

Comments
 (0)