Skip to content

Commit

Permalink
Merge pull request #2748 from teohhanhui/merge-2.4
Browse files Browse the repository at this point in the history
Merge 2.4 into master
  • Loading branch information
soyuka authored Apr 19, 2019
2 parents bc0806b + 433ce07 commit 26cfe16
Show file tree
Hide file tree
Showing 30 changed files with 714 additions and 422 deletions.
50 changes: 28 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

First of all, thank you for contributing, you're awesome!

To have your code integrated in the API Platform project, there is some rules to follow, but don't panic, it's easy!
To have your code integrated in the API Platform project, there are some rules to follow, but don't panic, it's easy!

## Reporting Bugs

If you happen to find a bug, we kindly request you to report it. However, before submitting it, please:

* Check the [project documentation available online](https://api-platform.com/docs/)

Then, if it appears that it's a real bug, you may report it using Github by following these 3 points:
Then, if it appears that it's a real bug, you may report it using GitHub by following these 3 points:

* Check if the bug is not already reported!
* A clear title to resume the issue
* A description of the workflow needed to reproduce the bug

> _NOTE:_ Dont hesitate giving as much information as you can (OS, PHP version extensions...)
> _NOTE:_ Don't hesitate giving as much information as you can (OS, PHP version extensions...)
### Security issues
### Security Issues

If you find a security issue, send a mail to Kévin Dunglas <dunglas@gmail.com>. **Please do not report security problems
publicly**. We will disclose details of the issue and credit you after having released a new version including a fix.

## Pull requests
## Pull Requests

### Writing a Pull Request

Expand All @@ -33,14 +33,14 @@ See [the dedicated documentation entry](https://api-platform.com/docs/extra/rele
### Matching Coding Standards

The API Platform project follows [Symfony coding standards](https://symfony.com/doc/current/contributing/code/standards.html).
But don't worry, you can fix CS issues automatically using the [PHP CS Fixer](http://cs.sensiolabs.org/) tool
But don't worry, you can fix CS issues automatically using the [PHP CS Fixer](http://cs.sensiolabs.org/) tool:

```bash
```shell
php-cs-fixer.phar fix
```

And then, add fixed file to your commit before push.
Be sure to add only **your modified files**. If another files are fixed by cs tools, just revert it before commit.
And then, add the fixed file to your commit before pushing.
Be sure to add only **your modified files**. If any other file is fixed by cs tools, just revert it before committing.

### Sending a Pull Request

Expand All @@ -52,7 +52,7 @@ When you send a PR, just make sure that:
* You make the PR on the same branch you based your changes on. If you see commits
that you did not make in your PR, you're doing it wrong.
* Also don't forget to add a comment when you update a PR with a ping to [the maintainers](https://github.com/orgs/api-platform/people), so he/she will get a notification.
* Squash your commits into one commit. (see the next chapter)
* Squash your commits into one commit (see the next chapter).

All Pull Requests must include [this header](.github/PULL_REQUEST_TEMPLATE.md).

Expand All @@ -62,23 +62,23 @@ On `api-platform/core` there are two kinds of tests: unit (`phpunit`) and integr

Both `phpunit` and `behat` are development dependencies and should be available in the `vendor` directory.

#### Phpunit and Coverage Generation
#### PHPUnit and Coverage Generation

To launch unit tests:

```
```shell
vendor/bin/phpunit --stop-on-failure -vvv
```

If you want coverage, you will need the `phpdbg` package and run:

```
```shell
phpdbg -qrr vendor/bin/phpunit --coverage-html coverage -vvv --stop-on-failure
```

Sometimes there might be an error with too many open files when generating coverage. To fix this, you can increase the `ulimit`, for example:

```
```shell
ulimit -n 4000
```

Expand All @@ -88,15 +88,21 @@ Coverage will be available in `coverage/index.html`.

The command to launch Behat tests is:

```
```shell
./vendor/bin/behat --suite=default --stop-on-failure -vvv
```

If you want to launch Behat tests for MongoDB, the command is:

```shell
APP_ENV=mongodb ./vendor/bin/behat --suite=mongodb --stop-on-failure -vvv
```

## Squash your Commits

If you have 3 commits. So start with:
If you have 3 commits, start with:

```bash
```shell
git rebase -i HEAD~3
```

Expand All @@ -106,18 +112,18 @@ Replace all `pick` prefixes by `fixup` (or `f`) **except the first commit** of t

Save and quit the editor.

After that, all your commits where squashed into the first one and the commit message of the first commit.
After that, all your commits will be squashed into the first one and the commit message will be the first one.

If you would like to rename your commit message type:
If you would like to rename your commit message, type:

```bash
```shell
git commit --amend
```

Now force push to update your PR:

```bash
git push --force
```shell
git push --force-with-lease
```

# License and Copyright Attribution
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"symfony/messenger": "^4.2",
"symfony/phpunit-bridge": "^3.4.5 || ^4.0.5",
"symfony/routing": "^3.4 || ^4.0",
"symfony/security": "^3.4 || ^4.0",
"symfony/security-bundle": "^3.4 || ^4.0",
"symfony/security-core": "^3.4 || ^4.0",
"symfony/twig-bundle": "^3.4 || ^4.0",
"symfony/validator": "^3.4 || ^4.0",
"symfony/web-profiler-bundle": "^4.2",
Expand Down
7 changes: 3 additions & 4 deletions features/graphql/input_output.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Feature: GraphQL DTO input and output
In order to use a hypermedia API
In order to use the GraphQL API
As a client software developer
I need to be able to use DTOs on my resources as Input or Output objects.

@createSchema
Scenario: Retrieve an Output with GraphQl
Scenario: Retrieve an Output with GraphQL
When I add "Content-Type" header equal to "application/ld+json"
And I send a "POST" request to "/dummy_dto_input_outputs" with body:
"""
Expand Down Expand Up @@ -162,8 +162,7 @@ Feature: GraphQL DTO input and output
}
"""

@!mongodb
Scenario: Use messenger with graphql and an input where the handler gives a synchronous result
Scenario: Use messenger with GraphQL and an input where the handler gives a synchronous result
When I send the following GraphQL request:
"""
mutation {
Expand Down
47 changes: 41 additions & 6 deletions features/jsonld/input_output.feature
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Feature: JSON-LD DTO input and output
"ipsum": "1"
}
"""
Then the response status code should be 201
Then the response status code should be 204
And the response should be empty

@createSchema
Expand Down Expand Up @@ -187,15 +187,50 @@ Feature: JSON-LD DTO input and output

@createSchema
Scenario: Create a resource with no input
When I send a "POST" request to "/dummy_dto_no_inputs" with body:
When I send a "POST" request to "/dummy_dto_no_inputs"
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
"""
{
"foo": "test",
"bar": 1
"@context": {
"@vocab": "http://example.com/docs.jsonld#",
"hydra": "http://www.w3.org/ns/hydra/core#",
"id": "OutputDto/id",
"baz": "OutputDto/baz",
"bat": "OutputDto/bat"
},
"@type": "DummyDtoNoInput",
"@id": "/dummy_dto_no_inputs/1",
"id": 1,
"baz": 1,
"bat": "test"
}
"""

Scenario: Update a resource with no input
When I send a "POST" request to "/dummy_dto_no_inputs/1/double_bat"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
"""
{
"@context": {
"@vocab": "http://example.com/docs.jsonld#",
"hydra": "http://www.w3.org/ns/hydra/core#",
"id": "OutputDto/id",
"baz": "OutputDto/baz",
"bat": "OutputDto/bat"
},
"@type": "DummyDtoNoInput",
"@id": "/dummy_dto_no_inputs/1",
"id": 1,
"baz": 1,
"bat": "testtest"
}
"""
Then the response status code should be 201
And the response should be empty

@!mongodb
Scenario: Use messenger with an input where the handler gives a synchronous result
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ parameters:
-
message: '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Util\\QueryBuilderHelper::mapJoinAliases() should return array<string, array<string>\|string> but returns array<int|string, mixed>\.#'
path: %currentWorkingDirectory%/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php
-
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'addRemovedBindingIds?' will always evaluate to false\\.#"
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php
- "#Call to method PHPUnit\\\\Framework\\\\Assert::assertSame\\(\\) with array\\('(collection_context|item_context|subresource_context)'\\) and array<Symfony\\\\Component\\\\VarDumper\\\\Cloner\\\\Data>\\|bool\\|float\\|int\\|string\\|null will always evaluate to false\\.#"
# https://github.com/doctrine/doctrine2/pull/7298/files
- '#Strict comparison using === between null and int will always evaluate to false\.#'
Expand Down
2 changes: 1 addition & 1 deletion src/Api/IdentifiersExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName
$this->resourceClassResolver = $resourceClassResolver;

if (null === $this->resourceClassResolver) {
@trigger_error(sprintf('Not injecting %s in the CachedIdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Not injecting %s in the IdentifiersExtractor might introduce cache issues with object identifiers.', ResourceClassResolverInterface::class), E_USER_DEPRECATED);
}
}

Expand Down
Loading

0 comments on commit 26cfe16

Please sign in to comment.