Problem/Motivation

At one point when Karen S. refactored tests she reduced the amount of code duplication happening there by creating a base date testcase. There are some really old tests that were not refactored to take advantage of this, though: the basic tests happening in date.test still use its own separate createField() method unnecessarily.

Proposed resolution

Refactor the the test in date.test to use DateFieldBasic, making somewhat easier to maintain the tests in the future.

Also use a loop for most of the testing in testFieldUI(), to make code more concise.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wwedding’s picture

Assigned: Unassigned » wwedding

I have a patch on the way, I was writing up some tests to catch some reported issues and thought a little cleaning up would be nice, too.

wwedding’s picture

Assigned: wwedding » Unassigned
Status: Active » Needs review
FileSize
9.3 KB

I almost feel like the test in date.test should be in date_field.test, but here's a patch that just refactors date.test.

wwedding’s picture

Formatting issues in the first patch.

vijaycs85’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +sprint

great cleanup @stickywes. Nothing to complain, just few mentions out of manual review. It is good to go.

  1. +++ b/tests/date.test
    @@ -39,83 +31,34 @@ class DateUITestCase extends DrupalWebTestCase {
    -    $edit = array();
    -    $edit['name'] = 'Story';
    -    $edit['type'] = 'story';
    -    $this->drupalPost('admin/structure/types/add', $edit, t('Save content type'));
    -    $this->assertText('The content type Story has been added.', 'Content type added.');
    

    I see this is now part of DateFieldBasic::setup()

  2. +++ b/tests/date.test
    @@ -39,83 +31,34 @@ class DateUITestCase extends DrupalWebTestCase {
    -    // Creates select list field stored as a date with default settings.
    ...
    -    // Creates text field stored as a date with default settings.
    ...
    -    // Creates popup field stored as a date with default settings.
    ...
    -    // Creates select list field stored as a datestamp with default settings.
    ...
    -    // Creates text field stored as a datestamp with default settings.
    ...
    -    // Creates popup field stored as a datestamp with default settings.
    ...
    -    // Creates select list field stored as a datetime with default settings.
    ...
    -    // Creates text field stored as a datetime with default settings.
    ...
    -    // Creates popup field stored as a datetime with default settings.
    

    Nice, cleanup and can see all 9 of them covered with 3x3 foreach

  3. +++ b/tests/date.test
    @@ -128,44 +71,21 @@ class DateUITestCase extends DrupalWebTestCase {
    -
    -  /**
    -   * @todo.
    -   */
    -  function createDateField($type, $widget) {
    -    $edit = array();
    -    $edit['fields[_add_new_field][label]'] = 'Test';
    -    $edit['fields[_add_new_field][field_name]'] = 'test';
    -    $edit['fields[_add_new_field][weight]'] = '-4';
    -    $edit['fields[_add_new_field][type]'] = $type;
    -    $edit['fields[_add_new_field][widget_type]'] = $widget;
    -    $this->drupalPost('admin/structure/types/manage/story/fields', $edit, t('Save'));
    -  }
    -
    -  /**
    -   * @todo.
    -   */
    -  function deleteDateField() {
    -    $this->drupalGet('admin/structure/types/manage/story/fields');
    -    $this->clickLink('delete');
    -    $this->drupalPost(NULL, NULL, t('Delete'));
    -    $this->assertText('The field Test has been deleted from the Story content type.', 'Removed date field.');
    -  }
     }
    

    Nice cleanup.

podarok’s picture

Status: Reviewed & tested by the community » Fixed

#3 commited
Thanks!

  • Commit 1c2de2f on 7.x-2.x authored by stickywes, committed by podarok:
    Issue #2198807 by stickywes: Refactor field tests to utilize...
vijaycs85’s picture

Issue tags: -sprint

yay! thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.