Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add command controller to create test data #1297

Merged
merged 23 commits into from
Dec 21, 2024

Conversation

kanow
Copy link
Contributor

@kanow kanow commented May 7, 2024

Simple command to add test data for tea model with a console command. It's just the first try and should be extended by more data, translations, etc.

Resolves: #1120

@kanow kanow added this to the 4.0.0: Breaking changes milestone May 7, 2024
@kanow kanow self-assigned this May 7, 2024
@kanow kanow linked an issue May 7, 2024 that may be closed by this pull request
2 tasks
@coveralls
Copy link

coveralls commented May 7, 2024

Pull Request Test Coverage Report for Build 10167965078

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 34 of 34 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 10166538431: 0.0%
Covered Lines: 80
Relevant Lines: 80

💛 - Coveralls

@sbuerk
Copy link
Contributor

sbuerk commented May 7, 2024

I know this is WIP, but I wanted to provide an early feedback on this.

Basically, I would recommend to avoid using QueryBuilder or Connection
methods (low-level api) for such tasks, until absolutly needed. Usually,
it's more recommandable to use DataHandler for operation, as it takes
care of a lot of stuff. For example:

  • Default value handling (TCA)
  • TYPO3 system field handling
  • soft-delete/hard-delete of records based on TCA configuration
  • record history for changes (soft-delete, creation, updating, ...)
  • automatically exeucte hooks configured by extensions/core
  • workspace support if workspace is installed etc without the need to handle system fields directly
  • system field for localization of records (l18n_diff, l18n_source) etc
  • access verification (if not executed with admin permissions)

albeit eventually not having all in place right now.

Thus I highly recommend to switch to DataHandler for the deletion
and data creation/update part.

@kanow kanow force-pushed the 1120-add-a-command-to-create-test-data branch 2 times, most recently from 60272f9 to f28c1a3 Compare May 8, 2024 09:51
@kanow kanow changed the title [WIP] Add command controller to create test data Add command controller to create test data Jul 26, 2024
@kanow
Copy link
Contributor Author

kanow commented Jul 26, 2024

We are aware to the usage of DataHandler or not. Daniel means that Command Controller should be an simple example to work with database actions. Maybe later we can extend that existing command or create a second command controller that shows an advanced example to work with the DataHandler.
For example adding more data with relations to images.

@kanow kanow force-pushed the 1120-add-a-command-to-create-test-data branch from bad530a to c3821cd Compare July 29, 2024 15:29
@kanow kanow requested a review from oliverklee July 29, 2024 15:33
@oliverklee oliverklee changed the title Add command controller to create test data [FEATURE] Add command controller to create test data Jul 29, 2024
@oliverklee oliverklee added the enhancement New feature or request label Jul 29, 2024
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Outdated Show resolved Hide resolved
Classes/Command/CreateTestDataCommand.php Show resolved Hide resolved
@kanow kanow force-pushed the 1120-add-a-command-to-create-test-data branch 2 times, most recently from a2f9011 to 9902677 Compare July 30, 2024 17:14
Copy link
Contributor

@oliverklee oliverklee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the functional tests are failing. Also, we currently have some style warnings and PHPStan warnings which we'll need to fix first.

Configuration/Services.php Outdated Show resolved Hide resolved
@kanow kanow force-pushed the 1120-add-a-command-to-create-test-data branch 2 times, most recently from 6327a94 to 73b8069 Compare August 20, 2024 06:56
Copy link
Contributor

@oliverklee oliverklee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, some tests are red. Could you please fix these and also rename the Composer script key as requested in an earlier review? Thanks! 🙏

@kanow kanow force-pushed the 1120-add-a-command-to-create-test-data branch from a7101db to 055a2f0 Compare October 20, 2024 10:04
@lukaszuznanski
Copy link
Contributor

Hi,

We've implemented a policy to close pull requests that have been inactive for over six months. If you're still interested in contributing and would like to continue working on this pull request, we're more than happy to keep it open.

Please take a moment to review your pull request and let us know if you'd like to proceed with it. If we don't receive a response within the next 30 days, we'll assume that you no longer wish to pursue it, and we'll proceed with closing the pull request.

Feel free to reach out if you have any questions or need further assistance.

@kanow
Copy link
Contributor Author

kanow commented Dec 13, 2024

Oh, shit. And yes, I still try to make this PR ready to review/merge ;-).

@kanow kanow force-pushed the 1120-add-a-command-to-create-test-data branch from 055a2f0 to 3c9a5b7 Compare December 13, 2024 16:00
@coveralls
Copy link

coveralls commented Dec 13, 2024

Pull Request Test Coverage Report for Build 12447292792

Details

  • 34 of 34 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 12349403373: 0.0%
Covered Lines: 101
Relevant Lines: 101

💛 - Coveralls

@oliverklee oliverklee force-pushed the 1120-add-a-command-to-create-test-data branch from aa090fc to 4662572 Compare December 21, 2024 17:54
kanow and others added 21 commits December 21, 2024 18:57
SQLite does reset the UID autoincrement during deletion.
That way the assertions do not match.
We now use a different set up and remove the uids from assertions.

That way we still ensure that the imported data is removed and new data
is imported. We do not need to care about UID.
In php 7.4 error occured:
`Cannot unpack array with string keys`

Related #1120
functional test are failing all with that assert

Related: #1120
With the usage of an integer in functional test for the command
we get rid of the issue with asert is int or cast mixed variable to int.
Test are running fine locally. The page id should be just an integer
and nobody will be set that in '' right?

Related: #1120
@oliverklee oliverklee force-pushed the 1120-add-a-command-to-create-test-data branch from 4662572 to c7f3aff Compare December 21, 2024 17:57
@oliverklee oliverklee merged commit 565666b into main Dec 21, 2024
56 checks passed
@oliverklee oliverklee deleted the 1120-add-a-command-to-create-test-data branch December 21, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a command to create test data
7 participants