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
40 changes: 40 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PHP type checking and unit testing

on: [push]

jobs:
build:
strategy:
matrix:
php: ['7.2', '7.3', '7.4']
phpunit: ['8.0', '9.0']
exclude:
- php: '7.2'
phpunit: '9.0'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, json
coverage: pcov

- name: Validate composer.json and composer.lock
run: composer validate

- name: Declare required PHPUnit version
run: |
composer require --no-update --dev phpunit/phpunit ~${{ matrix.phpunit }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

#- name: Run type checker
# run: ./vendor/bin/psalm

- name: Run unit tests
run: ./vendor/bin/phpunit --testdox
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ This library is [MIT-licensed](LICENSE.txt).

There are several release branches of this library, each of these being compatible with different releases of PHPUnit and PHP. The following table should give an easy overview:

| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 |
| ------------------------ | --------- | --------- | --------- | --------- | --------- |
| v1 (branch `v1`), **unsupported** | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
| v2 (branch `v2`) | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: |
| v3 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: |
| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 |
| ------------------------ | --------- | --------- | --------- | --------- | --------- | --------- |
| v1 (branch `v1`), **unsupported** | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
| v2 (branch `v2`) | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: |
| v3 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: |

When you are using `composer require` and have already declared a dependency to `phpunit/phpunit` in your `composer.json` file, Composer should pick latest compatible version automatically.

Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"justinrainbow/json-schema": "^5.0"
},
"conflict": {
"phpunit/phpunit": "<8.0 || >= 9.0"
"phpunit/phpunit": "<8.0 || >= 10.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
"phpunit/phpunit": "^8.0 || ^9.0"
},
"autoload": {
"psr-4": {
Expand All @@ -26,11 +26,10 @@
},
"autoload-dev": {
"files": [
"vendor/phpunit/phpunit/src/Framework/Assert/Functions.php",
"src/Functions.php"
]
},
"config": {
"sort-packages": true
}
}
}
12 changes: 6 additions & 6 deletions tests/Functional/JsonValueMatchesFluentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ class JsonValueMatchesFluentTest extends TestCase

public function testAssertThatJsonDocumentContainsJsonValue()
{
assertThat(self::$exampleDocument, containsJsonValue('$.identifier', 1234));
$this->assertThat(self::$exampleDocument, containsJsonValue('$.identifier', 1234));
}

public function testAssertThatJsonDocumentMatchesJsonConstraints()
{
assertThat(
$this->assertThat(
self::$exampleDocument,
matchesJsonConstraints(
[
'$.owner.name' => equalTo('Max Mustermann'),
'$.products[*].identifier' => greaterThanOrEqual(500),
'$.products[*].name' => logicalNot(equalTo('Weißbrot'))
'$.owner.name' => $this->equalTo('Max Mustermann'),
'$.products[*].identifier' => $this->greaterThanOrEqual(500),
'$.products[*].name' => $this->logicalNot($this->equalTo('Weißbrot'))
]
)
);
}
}
}
4 changes: 2 additions & 2 deletions tests/Functional/JsonValueMatchesSchemaFluentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class JsonValueMatchesSchemaFluentTest extends TestCase

public function testJsonDocumentMatchesSchema()
{
assertThat(static::$exampleDocument, matchesJsonSchema([
$this->assertThat(static::$exampleDocument, matchesJsonSchema([
'type' => 'object',
'required' => ['identifier', 'owner', 'products'],
'properties' => [
Expand Down Expand Up @@ -64,7 +64,7 @@ public function testJsonDocumentDoesNotMatchSchema()
{
$this->expectException(AssertionFailedError::class);

assertThat(static::$exampleDocument, matchesJsonSchema([
$this->assertThat(static::$exampleDocument, matchesJsonSchema([
'type' => 'object',
'required' => ['foobar'],
'properties' => [
Expand Down