Skip to content

Commit 64ddeec

Browse files
authored
chore: tests recommendations (#5983)
1 parent 002c8b2 commit 64ddeec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Examples:
113113
test(doctrine): mongodb disambiguation
114114

115115
We strongly recommend the use of a scope on API Platform core.
116+
Only the first commit on a Pull Request need to use a conventional commit, other commits will be squashed.
116117

117118
### Tests
118119

@@ -122,6 +123,16 @@ Note that we stopped using `prophesize` for new tests since 3.2, use `phpunit` s
122123

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

126+
Recommendations:
127+
- don't change existing tests if possible
128+
- always add a new `ApiResource` or a new `Entity/Document` to add a new test instead of changing an existing class
129+
- as of API Platform 3 each component has it's own test directory, avoid the `tests/` directory except for functional tests
130+
- dependencies between components must be kept at its minimal (`api-platform/metadata`, `api-platform/state`) except for bridges (Doctrine, Symfony, Laravel etc.)
131+
132+
Note that in most of the testing, you don't need Doctrine take a look at how we write fixtures at:
133+
134+
https://github.com/api-platform/core/blob/002c8b25283c9c06a085945f6206052a99a5fb1e/tests/Fixtures/TestBundle/Entity/Issue5926/TestIssue5926.php#L20-L26
135+
125136
#### PHPUnit and Coverage Generation
126137

127138
To launch unit tests:

0 commit comments

Comments
 (0)