While working on another issue, I've found there's a lot of tests that create a flag using the form. This seems excessive to me. Admittedly, each link type plugin needs to work with the flag form to check its own stuff is there, but aside from that, the flag form only needs to be tested once. The rest of the time, flags should be getting created/edited programmatically so tests run quicker.

CommentFileSizeAuthor
#3 2558503.2.refactorTests.patch5.69 KBsocketwench
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

socketwench’s picture

From my poking around, there's only three places where this issue would apply:

  • FlagFieldEntryTest
  • FlagServiceTest
  • FlagEnableDisableTest

There are larger refactoring problems elsewhere. FlagServiceTest creates the flag programmatically without using FlagTestBase::createFlag(). FlagConfirmFormTest, FlagFieldEntryTest, and FlagSimpleTest call drupal_post_form() directly instead of using FlagTestBase::createFlagWithForm(). Many of these classes don't take advantage of FlagTestBase now that it's in the repo. These will need new issues.

socketwench’s picture

Did a few refactors, by no means finished.

joachim’s picture

> There are larger refactoring problems elsewhere

Agreed! After filing this, I had another think and figured we need a meta-task to think about the complete picture of the tests we have, but life intervened and I've not filed it yet.

joachim’s picture

+++ b/src/Tests/FlagConfirmFormTest.php
@@ -108,7 +92,7 @@ class FlagConfirmFormTest extends WebTestBase {
-    $this->drupalPostForm(NULL, $edit, t('Create Flag'));
+    $this->flag = $this->createFlagWithForm('node', $edit, 'confirm');

We shouldn't be creating the flag with the form at all here -- the test isn't about the Flag admin UI, so we should create the flag programatically.

socketwench’s picture

We shouldn't be creating the flag with the form at all here -- the test isn't about the Flag admin UI, so we should create the flag programatically.

Then when where do we test the Confirm Form link type form?

joachim’s picture

Ah right, yes, sorry. I see what you mean -- we need to test the admin form elements for the link type we're testing.

I'd prefer it if the patch were split up -- with tests I feel it's very easy to remove too much and then never notice it's gone because tests pass. Also, the time I have to review these days is usually too early in the morning or too late at night :/ so simpler patches are preferable for reasons of limited brain power too!

socketwench’s picture

Status: Active » Needs work