- Issue created by @mondrake
- ๐ฎ๐ณIndia pradhumanjainOSL
pradhumanjain2311 โ made their first commit to this issueโs fork.
- Status changed to Needs review
8 months ago 8:02pm 20 April 2024 - ๐ฎ๐นItaly mondrake ๐ฎ๐น
Fixes the Kernel tests + one Unit test that was missed in ๐ Fix string array keys in data sets returned by data provider methods that do not match the parameter names in Unit tests Fixed .
- Status changed to Needs work
8 months ago 2:36pm 24 April 2024 - Status changed to Needs review
8 months ago 6:44pm 24 April 2024 - Status changed to RTBC
8 months ago 2:46pm 28 April 2024 - ๐บ๐ธUnited States smustgrave
Reviewing the changes and they appear to make sense. Assuming these would be caught automatically once we upgrade?
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
Yes, they result in deprecation errors in PHPUnit 10. See test failures in the upgrade issue.
- ๐ฎ๐ณIndia pravesh_poonia
Updating PHPUnit compatibility due to the deprecation in version 10.5.18, which now requires string array keys in data sets returned by data provider methods to match parameter names in Kernel tests. This change ensures continued compatibility with the latest PHPUnit version and maintains best practices for data provider usage
- ๐บ๐ธUnited States xjm
The scope of this MR is kind of big (500ish LOC to review), especially given that one has to open up the file to check that that the parameter names actually match the keys. That said, I don't have a better suggestion, so going ahead with reviewing it now.
@mondrake I assume you programmatically scanned for these somehow? Could you document it on the issue for posterity?
- ๐บ๐ธUnited States xjm
If I were to rescope this issue, I would put all the migrate stuff in one issue (since the expected parameters aren't even in the same file), and the rest of the changes in the first issue.
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
#11 PHPUnit 10.5.18 triggers a deprecation for any key not matching the test method argument name. We do not see it in this MR but that is visible in the latest test run of ๐ Upgrade PHPUnit to 10, drop Symfony PHPUnit-bridge dependency Fixed which is the input to this MR.
- ๐บ๐ธUnited States xjm
So far, I reviewed all the non-Migrate changes and confirmed that each change matches the expected parameters. I did not check for missed invalid keys.
- ๐บ๐ธUnited States xjm
Paused in my review based on feedback from @larowlan.
- ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
I think we should press ahead on this, so we can get to phpunit 10, but we should open a followup to remove these keys.
I don't think they provide value like the cases names do.
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
#16 is the opposite of #3443535-9: Change @dataprovider to static in SqlContentEntityStorageSchemaTest โ , so before any follow up there needs to be a decision made IMHO. A coding standard issue this one?
Personally I think they can help in some cases, especially when data providers pass booleans, like @longwave said in the other issue.
- ๐บ๐ธUnited States xjm
@mondrake Which job is it on the linked issue? (Sorry, GitLab CI is a scavenger hunt sometimes.)
- ๐บ๐ธUnited States xjm
FWIW I also find keys helpful, so agreed that we need to have a coding-standards-level discussion about it. I just defer to @larowlan in this since he's a framework manager and also involved in coding standards. :)
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
- ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
I think we need to have the discussion, which is another reason not to hold this up. We can always come back afterwards. I'll add to the agenda for next coding standards meeting.
- ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
- ๐บ๐ธUnited States xjm
Thanks @mondrake. So e.g.:
1) Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest::testCreate with data set #0 ('test_bundle') * Providing invalid named argument $scalar for method Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest::testCreate() is deprecated and will not be supported in PHPUnit 11.0. * Providing invalid named argument $scalar for method Drupal\KernelTests\Core\Entity\ContentEntityStorageBaseTest::testCreate() is deprecated and will not be supported in PHPUnit 11.0.
- ๐บ๐ธUnited States xjm
Docblock and signature from the
MigrateSqlSourceTestBase
base class for several of the updated tests:/** * Tests the source plugin against a particular data set. * * @param array $source_data * The source data that the plugin will read. See getDatabase() for the * expected format. * @param array $expected_data * The result rows the plugin is expected to return. * @param int $expected_count * (optional) How many rows the source plugin is expected to return. * @param array $configuration * (optional) Configuration for the source plugin. * @param mixed $high_water * (optional) The value of the high water field. * @param string|null $expected_cache_key * (optional) The expected cache key. * * @dataProvider providerSource * * @requires extension pdo_sqlite */ public function testSource(array $source_data, array $expected_data, $expected_count = NULL, array $configuration = [], $high_water = NULL, $expected_cache_key = NULL) {
- ๐บ๐ธUnited States xjm
core/modules/migrate_drupal/tests/src/Kernel/NodeMigrationTypePluginAlterTest.php
is weird and breaks the pattern, but that is becausetestMigrationPluginAlter($type, array $migration_definitions, array $expected)
names its parameters in a way that's inconsistent with the above base class.I finished reviewing all the files to make sure the new keys match what's expected for the test method parameter.
I didn't search to validate that all instances have been changed. If any were missed, or additional ones crop up, they'll show up when we adopt PHPUnit 10 and can be cleaned up at that time.
Untagged for followup since it's been added to the coding standards agenda.
@pradhumanjain2311, to get credit for resolving a merge conflict, you need to document the merge conflict on the issue. Reference: https://www.drupal.org/about/core/policies/maintainers/how-is-credit-gra... โ
Resolving a merge conflict when rerolling, rebasing, or merging HEAD
Document the merge conflict diff on the issue in a <code> tag.Saving issue credits.
- ๐บ๐ธUnited States xjm
Committed to 11.x. Thanks! I also cherry-picked it to 10.3.x as a no-op change to tests.
I considered whether this needed a CR, but since PHPUnit will enforce this for us in the future, there's no needs.
Thanks everyone!
- Status changed to Fixed
8 months ago 11:33pm 29 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.