You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adr/testing/2022-10-20-deprecation-handling-during-phpunit-test-execution.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,21 @@
2
2
3
3
## Context
4
4
5
-
To stay innovative and on the bleeding edge of technology it is important, that to don't rely on deprecated functionality, as it prevents you from using the latest and greatest versions of libraries, that may include important bug fixes, performance improvements or new features.
5
+
To stay innovative and on the bleeding edge of technology it is important, that we don't rely on deprecated functionality, as it prevents us from using the latest and greatest versions of libraries, that may include important bug fixes, performance improvements or new features.
6
6
Relying on deprecated functionality makes continuously upgrading the dependencies harder, as you have a lot of work to remove the deprecated usages before being able to do the upgrades.
7
-
This is not just important for external dependencies, but also for internal deprecations, as when we still rely on some deprecated functionality it makes removing the deprecation very hard.
7
+
This is not just important for external dependencies, but also for internal deprecations, that is we still rely on some deprecated functionality it makes removing the deprecation very hard.
8
8
9
9
One opportunity is to rely on our PHPUnit test suite to detect usages of deprecated functionality, so we can continuously remove them as they appear and ensure that the code base is always forward compatible.
10
10
11
11
## Solution
12
12
13
13
Because the handling for internal and external deprecations is quite different we probably need different solutions for those cases.
14
-
Especially as for internal deprecations we still want to ensure that they continue working and that those deprecated code paths are also covered by tests.
14
+
Especially as for internal deprecations we still want to ensure that they continue to work and that those deprecated code paths are also covered by tests.
15
15
16
16
### Using Symfony's Deprecation Helper for external deprecations
17
17
18
18
Symfony offers a tool to report all deprecations that are encountered when running the test inside their [PHPUnit Bridge](https://symfony.com/doc/current/components/phpunit_bridge.html).
19
-
With enabling the [`SYMFONY_DEPRECATIONS_HELPER`](https://symfony.com/doc/current/components/phpunit_bridge.html#trigger-deprecation-notices)fo our testsuite we can ensure that no deprecations are triggered while executing the tests.
19
+
With enabling the [`SYMFONY_DEPRECATIONS_HELPER`](https://symfony.com/doc/current/components/phpunit_bridge.html#trigger-deprecation-notices)for our testsuite we can ensure that no deprecations are triggered while executing the tests.
20
20
Previously we could not enable this as it also reported all deprecation usages for internal deprecations and also reported on deprecations that were triggered from inside external dependencies that we could not fix from inside shopware.
21
21
22
22
But since lately a feature was added to use a [`ignoreFile`](https://symfony.com/doc/current/components/phpunit_bridge.html#ignoring-deprecations), in order to ignore specific deprecations by regex.
@@ -28,9 +28,9 @@ We leverage this feature by using it in a way to ignore all deprecations that we
28
28
29
29
### Using our Feature Flag system for internal deprecations
30
30
31
-
Internally we use the feature flag system to trigger deprecations messages, or throw exceptions if the major feature flag is activated as explained in the [deprecation handling ADR](../workflow/2022-02-28-consistent-deprecation-notices-in-core.md).
31
+
Internally we use the feature flag system to trigger deprecation messages, or throw exceptions if the major feature flag is activated as explained in the [deprecation handling ADR](../workflow/2022-02-28-consistent-deprecation-notices-in-core.md).
32
32
We already use that system in our new unit test suite with a custom `@ActiveFeatures()` annotations, that allows us to run single test cases with a specific set of feature flags.
33
-
But the current implementation has the big drawback that feature flags have to actively be enabled, this leads to following problems:
33
+
But the current implementation has the big drawback that feature flags have to be actively enabled, this leads to following problems:
34
34
1. There are already tests that are not passing after all deprecations are removed, because they rely on deprecated behaviour.
35
35
2. We can't check automatically that our implementation is forward compatible, as the default way of executing tests is without any major flag activated.
36
36
3. It is hard to directly see which test cases are there only to cover legacy/deprecated functionality and can safely be removed after the deprecations are removed.
@@ -39,5 +39,5 @@ Therefore, the workflow is updated in the following way:
39
39
1. All unit tests get executed with all major feature flags activated.
40
40
2. The `@ActiveFeatures()` will be removed, and we introduce a `@DisableFeatures` annotation, that works in the exact opposite way => disabling all feature flags that are passed.
41
41
42
-
This has the upside that now the default behaviour of our test suite is the new/not-deprecated behaviour, and the deprecated code paths are treated as teh exceptional case instead the other way around.
42
+
This has the upside that now the default behaviour of our test suite is the new/not-deprecated behaviour, and the deprecated code paths are treated as the exceptional case instead the other way around.
43
43
Additionally, all tests that are relying on deprecated behaviour are marked with the `@DisableFeatures` annotations, so it is easy to detect them and simply remove them, if the underlying deprecation was removed.
// Can occur if the resolved value is a nested array. This prevents the implode() from being executed. We ignore this error at this point to allow some error tolerance in the configuration
44
+
$nonScalarValues = array_filter($values, function ($value) {
// Can occur if the resolved value is a nested array. This prevents the string cast from being executed (Array to string conversion). We ignore this error at this point to allow some error tolerance in the configuration
62
+
// even the field is non tokenize, if it reached 500 chars, we should break it anyway
0 commit comments