Comments

effulgentsia created an issue. See original summary.

jaxxed’s picture

I ran into this issue from a different one, and noticed that there is a @todo in there that was easy to act on.

I noticed that randomString() is already in the Testing class generator trait, so I just had to swap out the random string calls, and remove your local function. This patch is your patch, but pointing to that generator method. All "migrate" tests run without error, auto-testing should check D6, and Drp migration tests for me (there are a lot of passes involved.)

I have to say that the randomString() method is very poorly named.

jaxxed’s picture

StatusFileSize
new2.62 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2567793-1-migrate_random_from_generator.patch, failed testing.

The last submitted patch, 2: 2567793-1-migrate_random_from_generator.patch, failed testing.

jaxxed’s picture

Assigned: Unassigned » jaxxed

I will fix this.

jaxxed’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 KB
new2.53 KB
new1.93 KB

found out what I did wrong and updated.

2 interdiffs added here, one to the original patch #0, and one to my previous patch from #2

jaxxed’s picture

jaxxed’s picture

Status: Needs review » Needs work

tests failed locally. I am back looking at it again.

jaxxed’s picture

Status: Needs work » Needs review
StatusFileSize
new3.62 KB
new1.71 KB

Previous patch fails because the UnitTestCase (or perhaps the MigrateTestCase) never use/include the RandomGenertor trait.
This patch makes the UnitTestCase use the RandomGenerator trait, and removed functions from the UnitTestCase that are duplicates of functions in the RandomGenerator trait.

Reviewer should consider:

1. the RandomGenerator trait is a part of the simpletest module, but the UnitTestCase is a core unit test component. If UnitTestCase uses that trait, it should be certain that the simpletest module is enabled, or the trait will not be available and we'll get a PHP error. UnitTestCase was chosen as the RandomGenerator bind point, because it had some of the RandomGenerator functionality in it already (some methods and a variable.)
Should the RandomGenerator Trait be kept outside of simpletest?

2. If MigrateTestCase was where we use/bind the RandomGeneratorTrait, then we have to consider and review every other test that uses the UnitTestCase deprecated methods.

Clarification:

i. RandomGenerator trait already exists, and has functions that are copypasta from the UnitTestCase (plus more). It is clearly meant to replace those functions;
ii. It is unclear if RandomGenerator was meant to be included in UnitTestCase, or if every Unit test that needs random generation was supposed to use it themselves.

The last submitted patch, 7: 2567793-7-migrate_random_from_generator.patch, failed testing.

The last submitted patch, 7: 2567793-7-migrate_random_from_generator.patch, failed testing.

jaxxed’s picture

StatusFileSize
new3.73 KB
new503 bytes

This patch makes one small change on top of #10: it removes the include/use for the Random class, which is no longer being directly used inside the class.

jaxxed’s picture

I am going to try to add that simpletest trait only to migrate classes, and run all tests to see if anything else breaks.

jaxxed’s picture

A simple check shows that there are plenty of cases where the randomgenerator trait methods get used:

For example, just the random-generator method itself:

\./core/modules/file/src/Tests/FileItemTest.php:55:    $this->directory = $this->getRandomGenerator()->name(8);
./core/modules/simpletest/tests/src/Unit/TestBaseTest.php:463:   * @covers ::getRandomGenerator
./core/modules/simpletest/tests/src/Unit/TestBaseTest.php:469:        $this->invokeProtectedMethod($test_base, 'getRandomGenerator', array())
./core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php:555:    $value = $this->getRandomGenerator()->string();
./core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php:815:    $field_name = $this->getRandomGenerator()->name();
./core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php:960:    $field_name = $this->getRandomGenerator()->name();
./core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php:28:      '#lazy_builder' => ['Drupal\Tests\Core\Render\PlaceholdersTest::callback', [$this->getRandomGenerator()->string()]],

Moving the random-generator methods/trait out of the core unit tests would require a lot of additional effort.

mikeryan’s picture

Status: Needs review » Needs work

I think we're overthinking this... I don't really see a reason the test exception message needs to be a random string, we can just make "here is the expected exception message" or something like that. If there were some reason for it to be random, then we could use name() instead of string().

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikeryan’s picture

Status: Needs work » Postponed (maintainer needs more info)

Am I correct in assuming that the fact there's been no further follow-up here means there've been no more random test failures?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)