Problem/Motivation

Improve testing of createWithSampleValues(), currently it is rather limited and does not test all fields.

Trying to create sample nodes found the issues linked.

Proposed resolution

Add a test using at least one entity type with all the field types in core.

Remaining tasks

Figure out how best we test random. Or we could just hope eventually enough test runs and random fails happen to uncover all bugs...

Postponed on #2915034: \Drupal\Core\Entity\ContentEntityStorageBase::createWithSampleValues() does not handle language or bundles correctly
Patch
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Charlie ChX Negyesi created an issue. See original summary.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Title: createWithSampleValues is untested » Adds tests of createWithSampleValues
Issue tags: +Bug Smash Initiative

I do see tests for createWithSampeValues, \Drupal\KernelTests\Core\Entity\CreateSampleEntityTest::testSampleValueContentEntity. It validates entities, including node, and does test the randomly generate title. That test predates this issue so I am not sure what still needs to be tested. It was added in #2905527: Introduce a sample value entity method to ease plugin filtering via context.

I'll asked in #bugsmash, maybe I am missing something.

quietone’s picture

Category: Bug report » Task
Issue summary: View changes

I asked chx about this in #bugsmash. As I understand it what is needed is a test of createWithSampleValues using all the fields on an entity.

Writing tests is normally a task, changing category.

quietone’s picture

Issue summary: View changes
Status: Active » Postponed

chx posted some more in #bugsmash. He recommends that this should be postponed on #2915034: \Drupal\Core\Entity\ContentEntityStorageBase::createWithSampleValues() does not handle language or bundles correctly, "because the test changes in there are very, very good, namely saving and loading the sample back".

I've added the postponed issue to the Remaining tasks and setting this postponed.

ghost of drupal past’s picture

Issue summary: View changes

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.