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
7 changes: 6 additions & 1 deletion docs/en/appendices/5-5-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ Coming soon

## New Features

Coming soon
### TestSuite

- `Cake\TestSuite\Fixture\DeleteStrategy` was added. This fixture strategy
cleans fixtures with `DELETE` instead of `TRUNCATE` which can be more
performant on MySQL, with the trade off of auto increment values not being
reset between tests.
17 changes: 13 additions & 4 deletions docs/en/development/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,16 @@ public function getFixtures(): array

By default, CakePHP resets fixture state at the end of each test by truncating
all the tables in the database. This operation can become expensive as your
application grows. By using `TransactionStrategy` each test method will be run
inside a transaction that is rolled back at the end of the test. This can yield
improved performance but requires your tests not heavily rely on static fixture
data, as auto-increment values are not reset before each test.
application grows. CakePHP also provides two other fixture management strategies:

- `TransactionStrategy` - each test method will be run inside a transaction that
is rolled back at the end of the test. This can yield improved performance but
requires your tests not heavily rely on static fixture data, as auto-increment
values are not reset before each test.
- `DeleteStrategy` - after each test, foreign keys are disabled and records are
removed with `DELETE` queries. This can yield improved performance but
requires your tests not heavily rely on static fixture data, as auto-increment
values are not reset before each test.

The fixture state management strategy can be defined within the test case:

Expand Down Expand Up @@ -778,6 +784,9 @@ To switch out the general default strategy, use Configure key `TestSuite.fixture

The recommended strategy for medium and large applications is the `TransactionStrategy`, as using rollbacks to undo changes from tests is simpler to maintain, and reduces the chances of cross-contamination and side-effects between tests.

::: info DeleteStategy was added in version 5.5.0
:::

### Fixture Factories

As your application grows, so does the number and the size of your test
Expand Down
Loading