Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Title: Clean up API docs for simpletest/tests, A-H » Clean up API docs for simpletest/tests, A-D

Actually, we're splitting this up a bit more. Just A-D on this issue.

jhodgdon’s picture

Issue tags: +Novice
xjm’s picture

Title: Clean up API docs for simpletest/tests, A-D » Clean up API docs for simpletest/tests, A-D, including subdirectories
connorwk’s picture

Status: Active » Needs review
FileSize
728 bytes

Here is my patch for just actions.test
My first patch :D
More to come!

jhodgdon’s picture

Status: Needs review » Needs work

hi connork, thanks for the patch!

So... First you need to read through
http://drupal.org/node/1354
(especially the part about verbs on the first line of function/class docs).

And there are some specific standards for test classes that say you should not put a documentation block on the setUp(), getInfo(), or shutDown() functions at all. Which I'm not happy about, but that was the community decision.

connorwk’s picture

Status: Needs work » Needs review
FileSize
517 bytes

Ok my second try at the patch i think i understand now!
If not let me know and I will try, try again.

connorwk’s picture

Ok another patch for another file!

connorwk’s picture

IGNORE PREVIOUS PATCHES THIS IS THE FINAL.
This is the final patch that I'm doing for this I've done a 3651 line patch file.
NO MORE!!!
Jk I'm a beginner and I've done what I can.

rgristroph’s picture

This is a big patch, but I read through all of it, nice work.

I changed a small handful of things and rolled a new patch. I think this is good, and the only changes are in comments.

--Rob

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Just a quick review of two common mistakes to keep you moving! I realize you did not introduce these things, but since you are changing the stuff anyway, fixing it would be an ideal scenario.

+++ b/core/modules/simpletest/tests/actions.testundefined
@@ -10,7 +18,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase {
   /**
-   * Test the configuration of advanced actions through the administration
+   * Tests the configuration of advanced actions through the administration
    * interface.
    */
   function testActionConfiguration() {

+++ b/core/modules/simpletest/tests/actions_loop_test.moduleundefined
@@ -52,8 +57,9 @@ function actions_loop_test_log() {
 /**
- * Replacement of the watchdog() function that eliminates the use of semaphores
- * so that we can test the abortion of an action loop.
+ * Replaces the watchdog() function so that we can test the abortion of an
+ * action loop.  This function is like the watchdog() function except that it
+ * does not use semaphores.
  */
 function watchdog_skip_semaphore($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {

Intro comments on functions/methods should be on a single line. If you modify an existing one, "unfortunately" it would be ideally coupled with fixing the multiline-ness of it too.

Good twitter skills pay off big time here.

There might be other instances of this problem, I just found these at the top.

+++ b/core/modules/simpletest/tests/ajax.testundefined
@@ -10,7 +18,7 @@ class AJAXTestCase extends DrupalWebTestCase {
   /**
-   * Assert that a command with the required properties exists within the array of Ajax commands returned by the server.
+   * Asserts that a command with the required properties exists within the array of Ajax commands returned by the server.

@@ -67,7 +75,7 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
   /**
-   * Test that ajax_render() returns JavaScript settings generated during the page request.
+   * Tests that ajax_render() returns JavaScript settings generated during the page request.

@@ -116,7 +124,7 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
   /**
-   * Test that new JavaScript and CSS files added during an AJAX request are returned.
+   * Tests that new JavaScript and CSS files added during an AJAX request are returned.

These and possibly others are above 80 chars. That is another typical problem (which is an attempt to avoid the multilines), but should not be used.

This is even tougher than twitter, you have much less space here...

jhodgdon’s picture

Thanks Gabor! Those two review comments are correct. See
http://drupal.org/node/1354#general (80-character lines in comments)
http://drupal.org/node/1354#functions (first-line description in one sentence)

iamcarrico’s picture

I went through the patch one more time and fixed the common errors from jhodgdon and Gàbor. This patch should fix the 2-line issues as well as all the 80-column issues from the previous patches.

iamcarrico’s picture

Status: Needs work » Needs review
FileSize
117.96 KB

--forgot to change the status of the issue.

xjm’s picture

Title: Clean up API docs for simpletest/tests, A-D, including subdirectories » Clean up API docs for system/tests, A-D, including subdirectories

Thanks @ChinggizKhan!

Updating for #1299424: Allow one module per directory and move system tests to core/modules/system. This patch will probably need a rebase.

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Novice, +Needs backport to D7, +docs-cleanup-2011

The last submitted patch, simpletest-cleanup_api_a_to_d-1431658-13.patch, failed testing.

Anonymous’s picture

Issue summary: View changes

Mention subdirectories

kid_icarus’s picture

Status: Needs work » Needs review
FileSize
212.08 KB
119.17 KB

Re-rolled. Attached is a giant interdiff as well.

xjm’s picture

I think your interdiff is backwards. :) Edit: To be clear, that's just an observation--don't worry about making another in this case. Starting a review on this now.

xjm’s picture

Status: Needs review » Needs work

Thanks @connork, @rgristroph, @ChinggizKhan, and @kid_icarus for all your work on this patch. It's a big one!

I reviewed about 20% of the patch, starting from the bottom up, but stopped there because there are just too many outstanding issues. (It's already taken me an hour reviewing that much.) Couple general observations:

  • I'm guessing maybe the patch here used a script to append an S to the first word of docblocks if it didn't have one? That's actually a fine strategy as a first pass, but please review the changes before submitting the patch to make sure they're valid.
  • Many of the updated docblocks are too long. They should be a single line of 80 characters or fewer. Additional information can be placed in subsequent paragraphs. Reference: http://drupal.org/node/1354#functions

Specifics from as much as I got through:

  1. +++ b/core/modules/system/tests/bootstrap.testundefined
    @@ -389,8 +409,8 @@ class BootstrapTimerTestCase extends DrupalUnitTestCase {
    -   * Test timer_read() to ensure it properly accumulates time when the timer
    -   * started and stopped multiple times.
    +   * Tests timer_read() to ensure it properly accumulates time when the timer
    +   * is started and stopped multiple times.
    
    @@ -424,7 +444,7 @@ class BootstrapResettableStaticTestCase extends DrupalUnitTestCase {
    -   * Test that a variable reference returned by drupal_static() gets reset when
    +   * Tests that a variable reference returned by drupal_static() gets reset when
        * drupal_static_reset() is called.
    
    +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -756,7 +756,7 @@ class DatabaseUpdateTestCase extends DatabaseTestCase {
    -   * Confirm that we can update a multiple records with a non-equality condition.
    +   * Confirms that we can update a multiple records with a non-equality condition.
    
    @@ -1134,7 +1134,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
    -   * Confirm that we can merge-update a record successfully, with different insert and update.
    +   * Confirms that we can merge-update a record successfully, with different insert and update.
    
    @@ -1155,7 +1155,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
    -   * Confirm that we can merge-update a record successfully, with alternate replacement.
    +   * Confirms that we can merge-update a record successfully, with alternate replacement.
    
    @@ -1261,7 +1261,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
    -   * Test that an invalid merge query throws an exception like it is supposed to.
    +   * Tests that an invalid merge query throws an exception like it is supposed to.
    
    @@ -1508,7 +1508,7 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
    -   * Test that we can UNION multiple Select queries together. This is
    +   * Tests that we can UNION multiple Select queries together. This is
        * semantically equal to UNION DISTINCT, so we don't explicity test that.
    
    @@ -2096,7 +2096,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
    -   * Test that countQuery properly removes 'all_fields' statements and
    +   * Tests that countQuery properly removes 'all_fields' statements and
        * ordering clauses.
    
    @@ -2464,8 +2469,8 @@ class DatabaseSelectTableSortDefaultTestCase extends DatabaseTestCase {
    -   * Confirm that if a tablesort's orderByHeader is called before another orderBy, that the header happens first.
    -   *
    +   * Confirms that if a tablesort's orderByHeader is called before another
    +   * orderBy, that the header happens first.
    
    @@ -2490,7 +2495,8 @@ class DatabaseSelectTableSortDefaultTestCase extends DatabaseTestCase {
    -   * Confirm that if a sort is not set in a tableselect form there is no error thrown when using the default.
    +   * Confirms that if a sort is not set in a tableselect form there is no error
    +   * thrown when using the default.
    
    @@ -2700,7 +2706,7 @@ class DatabaseAlterTestCase extends DatabaseTestCase {
    -   * Test that we can remove a range() value from a query. This also tests hook_query_TAG_alter().
    +   * Tests that we can remove a range() value from a query. This also tests hook_query_TAG_alter().
    
    @@ -2853,7 +2859,7 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
    -   * Test that we can log queries against multiple targets on the same connection.
    +   * Tests that we can log queries against multiple targets on the same connection.
    
    @@ -2875,7 +2881,7 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
    -   * Test that logs to separate targets collapse to the same connection properly.
    +   * Tests that logs to separate targets collapse to the same connection properly.
    
    @@ -3179,7 +3185,8 @@ class DatabaseInvalidDataTestCase extends DatabaseTestCase {
    -   * Traditional SQL database systems abort inserts when invalid data is encountered.
    +   * Traditional SQL database systems abort inserts when invalid data is
    +   * encountered.
    

    All these summaries need to be one line of fewer than 80 characters, beginning with a third-person verb. If there's additional information to add, we can add it in a subsequent paragraph (as in the case of several here include a second sentence).

  2. +++ b/core/modules/system/tests/bootstrap.testundefined
    @@ -389,8 +409,8 @@ class BootstrapTimerTestCase extends DrupalUnitTestCase {
        * @return
        */
       function testTimer() {
    

    The @return here should be removed. Test methods don't return anything.

  3. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2346,7 +2349,7 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
    -   * Confirm that a pager query with inner pager query returns valid results.
    +   * Confirms that a pager query with inner pager query returns valid results.
    

    Can we fit "an" before "inner pager query" here, or otherwise reword this? It's a little confusing.

  4. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2367,7 +2370,7 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
    -   * Confirm that a paging query with a having expression returns valid results.
    +   * Confirms that a paging query with a having expression returns valid results.
    
    @@ -3422,7 +3429,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
    -   * Test transaction rollback on a database that does not support transactions.
    +   * Tests transaction rollback on a database that does not support transactions.
    

    The correction for the verb forms here puts these line over 80 characters, so we need to reword them to be shorter.

  5. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2387,7 +2390,7 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
    -   * Confirm that every pager gets a valid non-overlaping element ID.
    +   * Confirms that every pager gets a valid non-overlaping element ID.
    

    Let's add a comma after "valid" here.

  6. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2500,7 +2506,7 @@ class DatabaseSelectTableSortDefaultTestCase extends DatabaseTestCase {
    - * Select tagging tests.
    + * Selects tagging tests.
    
    @@ -2584,7 +2590,7 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
    - * Select alter tests.
    + * Selects alter tests.
    

    These are not selecting anything. They are testing select query alters and tagging.

  7. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2516,7 +2522,7 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
    -   * Confirm that a query has a "tag" added to it.
    +   * Confirms that a query has a "tag" added to it.
    

    I don't think "tag" needs to be in quotes here.

  8. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2559,7 +2565,7 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
    -   * Test that we can attach meta data to a query object.
    +   * Tests that we can attach meta data to a query object.
    

    "Metadata" should be one word.

  9. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2700,7 +2706,7 @@ class DatabaseAlterTestCase extends DatabaseTestCase {
    -   * Test that we can remove a range() value from a query. This also tests hook_query_TAG_alter().
    +   * Tests that we can remove a range() value from a query. This also tests hook_query_TAG_alter().
    
    @@ -2853,7 +2859,7 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
    -   * Test that we can log queries against multiple targets on the same connection.
    +   * Tests that we can log queries against multiple targets on the same connection.
    
    @@ -2875,7 +2881,7 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
    -   * Test that logs to separate targets collapse to the same connection properly.
    +   * Tests that logs to separate targets collapse to the same connection properly.
    
    @@ -3248,7 +3255,7 @@ class DatabaseQueryTestCase extends DatabaseTestCase {
    -   * Test that we can specify an array of values in the query by simply passing in an array.
    +   * Tests that we can specify an array of values in the query by simply passing in an array.
    

    These needs to be reworded to be under 80 characters.

  10. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2741,7 +2747,7 @@ class DatabaseAlterTestCase extends DatabaseTestCase {
    - * Regression tests.
    + * Tests regressions.
    

    I don't think this is testing regressions. I think it's testing to make sure that there aren't regressions... However, I think the naming of the class itself is kind of questionable, so I'm not sure what to change this to. I might look at what the setUp() method does and what all the methods are, and try to draw a picture from that.

  11. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2758,7 +2764,7 @@ class DatabaseRegressionTestCase extends DatabaseTestCase {
    -   * Regression test for #310447.
    +   * Tests regression for #310447.
        *
        * Tries to insert non-ascii UTF-8 data in a database column and checks
        * if its stored properly.
    

    The rewording here is inaccurate. However, this docblock is bad to begin with, because the summary should explain what the function does, not reference something somewhere on the internet. How about replacing both these sentences with:
    "Ensures that non-ASCII UTF-8 data is stored in the database properly."

  12. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2929,7 +2935,7 @@ class DatabaseLoggingTestCase extends DatabaseTestCase {
    - * Query serialization tests.
    + * Querys serialization tests.
    

    Aside from the fact that "queries" is spelled incorrectly, the function isn't querying serialization tests, it's testing query serialization. So let's change this to:
    "Tests query serialization."

  13. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2956,7 +2962,7 @@ class DatabaseSerializeQueryTestCase extends DatabaseTestCase {
    - * Range query tests.
    + * Ranges query tests.
    

    I am pretty sure we are not ranging anything here. :) Let's make this "Tests range queries."

  14. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -2972,7 +2978,7 @@ class DatabaseRangeQueryTestCase extends DrupalWebTestCase {
    -   * Confirm that range query work and return correct result.
    +   * Confirms that range query work and return correct result.
    

    This contains grammatical errors. It should be:
    "Confirms that range queries work and return the correct result"

  15. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -3049,7 +3055,7 @@ class DatabaseBasicSyntaxTestCase extends DatabaseTestCase {
    -   * Test for string concatenation.
    +   * Tests for string concatenation.
    
    @@ -3063,7 +3069,7 @@ class DatabaseBasicSyntaxTestCase extends DatabaseTestCase {
    -   * Test for string concatenation with field values.
    +   * Tests for string concatenation with field values.
    

    The word "for" here either makes "Tests" a noun, or changes the meaning of the sentence. Simply removing the word "for" fixes this.

  16. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -3102,7 +3108,7 @@ class DatabaseBasicSyntaxTestCase extends DatabaseTestCase {
    -   * Test LIKE query containing a backslash.
    +   * Tests LIKE query containing a backslash.
    
    @@ -3448,7 +3455,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
    -   * Test committed transaction.
    +   * Tests committed transaction.
    

    These need articles (a committed transaction, a LIKE query, etc.) (This likely applies elsewhere in the patch as well.)

  17. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -3288,12 +3295,12 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
    -   * Helper method for transaction unit test. This "outer layer" transaction
    -   * starts and then encapsulates the "inner layer" transaction. This nesting
    -   * is used to evaluate whether the the database transaction API properly
    -   * supports nesting. By "properly supports," we mean the outer transaction
    -   * continues to exist regardless of what functions are called and whether
    -   * those functions start their own transactions.
    +   * This is a helper method for transaction unit tests. This "outer layer"
    +   * transaction starts and then encapsulates the "inner layer" transaction.
    +   * This nesting is used to evaluate whether the the database transaction API
    +   * properly supports nesting. By "properly supports," we mean the outer
    +   * transaction continues to exist regardless of what functions are called
    +   * and whether those functions start their own transactions.
    

    This method still needs a one-line summary at the top above this paragraph.

  18. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -3630,7 +3637,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
    -   * Test transaction stacking and commit / rollback.
    +   * Tests transaction stacking and commit / rollback.
    

    How about, "Tests transaction stacking, commit, and rollback"?

  19. +++ b/core/modules/system/tests/modules/database_test/database_test.testundefined
    @@ -3757,7 +3764,7 @@ class DatabaseNextIdCase extends DrupalWebTestCase {
    -   * Test that the sequences API work.
    +   * Tests that the sequences API work.
    

    I think this needs to be "works"? API is singular.

Let's get a reroll to fix these specific points, and to also apply these suggestions elsewhere in the files. Please be sure to include an interdiff from the previous patch. Thanks!

Albert Volkman’s picture

Assigned: Unassigned » Albert Volkman
Albert Volkman’s picture

Status: Needs work » Needs review
FileSize
131.69 KB

Here's what I did (sorry I can't create an interdiff due to PSR-0ification of tests):

  • Cleaned up patch to apply to new PSR-0 tests.
  • Applied @xjm's suggestions.
  • Reviewed patch manually and fixed errors grammatical and code style errors. However, I believe there are a few outstanding >80 character definitions that I wasn't sure how to summarize further.
jhodgdon’s picture

Status: Needs review » Needs work
Issue tags: +Novice, +Needs backport to D7, +docs-cleanup-2011

The last submitted patch, simpletest-cleanup_api_a_to_d-1431658-21.patch, failed testing.

Albert Volkman’s picture

Status: Needs work » Needs review
FileSize
129.59 KB

Re-rolled.

jhodgdon’s picture

Status: Needs review » Needs work

This is very close, thanks!

I reviewed the entire patch (wow!) and I found just a couple of spots that need minor clean-up and then we should be able to get this committed... Two things that could be done:
1. Make a patch that just removes these errors and do the rest in a follow-up.
2. Make a patch that fixes these errors.

Either way... please provide an interdiff! :)

Anyway, here are the commit blockers:

a) This one-liner needs some attention (it doesn't quite make grammatical sense):

+++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FormValuesTest.php

   /**
-   * Create a simple form, then POST to system/ajax to change to it.
+   * Creates a simple form, then POST to system/ajax to change to it.
    */
   function testSimpleAjaxFormValue() {

b)

+++ b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php

/**
-   * Test batches that return $context['finished'] > 1 do in fact complete.
+   * Tests batches that return $context['finished'] > 1 do in fact complete.
    * See http://drupal.org/node/600836
    */
   function testBatchLargePercentage() {

Needs a blank line in there.

c)

+++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/IpAddressTest.php

+  /**
+   * Resets the static IP address.
+   */
   function tearDown() {

Our test coding standard is that setUp(), tearDown(), and getInfo() methods do not have documentation.

d) And in the same file:

/**
-   * test IP Address and hostname
+   * Tests IP Address and hostname.
    */
   function testIPAddressHost() {

Address should not be capitalized.

e)

/**
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php

-   * Test Drupal\Core\Cache\CacheBackendInterface::get() and
+   * Tests Drupal\Core\Cache\CacheBackendInterface::get() and
    * Drupal\Core\Cache\CacheBackendInterface::set().
    */
   public function testSetGet() {

Needs a one-line summary, maybe something like "Tests cache get and set.".

f)

+  /**
+   * Tests if the theme has been altered.
+   *
+   * @global string $theme
+   * @global array $base_theme_info
+   */
   function testDrupalAlter() {

We don't have an @global docs tag... not sure where those lines came from? Just remove them. There are some elsewhere in the patch as well in files:
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/AlterTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/HttpRequestTest.php

g)

+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php

/**
-   * Test url() with/without query, with/without fragment, absolute on/off and
+   * Tests url() functionality.
+   *
+   * Tests url() with/without query, with/without fragment, absolute on/off and
    * assert all that works when clean URLs are on and off.
    */
   function testUrl() {

assert -> asserts in the last line for verb agreement.

h) There were a couple of places where in-code comments' verb tense was changed and it shouldn't be, such as:

+++ b/core/modules/system/lib/Drupal/system/Tests/Database/FetchTest.php

-  // Confirm that we can fetch a record into an indexed array explicitly.
+  // Confirms that we can fetch a record into an indexed array explicitly.

i)

+++ b/core/modules/system/lib/Drupal/system/Tests/Database/InsertDefaultsTest.php
@@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Database;
 use Drupal\Core\Database\Query\NoFieldsException;
 
 /**
- * Insert tests for "database default" values.
+ * Inserts tests for "database default" values.
  */
 class InsertDefaultsTest extends DatabaseTestBase {

Actually, "insert" here wasn't a verb... This should probably be "Tests insertion for database default values".

j)

+++ b/core/modules/system/lib/Drupal/system/Tests/Database/TransactionTest.php

/**
+   * Helper method for transaction unit tests.

First-line for function doc -- needs to start with a verb. (there are two in this file)

k)

+++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module

/**
- * Form to display the Ajax Commands.
+ * Forms to display the Ajax Commands.
  */
 function ajax_forms_test_ajax_commands_form($form, &$form_state) {

/**
+ * Builds AJAX validation form.
+ *

/**
- * Submit handler for the validation form.
+ * Tests submit handler for the validation form.
  */
 function ajax_forms_test_validation_form_submit($form, $form_state) {

These look like form constructors/submit handlers and should be documented as in http://drupal.org/node/1354#forms

l)

+++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module
@@ -50,7 +50,7 @@ function ajax_test_render() {
 }
 
 /**
- * Menu callback; Returns Ajax element with #error property set.
+ * Menu callback: Returns AJAX element with #error property set.

We need to be consistent here... Elsewhere in this patch, I see "Ajax" and here it's "AJAX". I think the proper term for Drupal is "Ajax".

m)

+++ b/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc

/**
- * Common 'finished' callbacks for batches 1 to 4.
+ * Performs a common 'finished' callbacks for batches 1 to 4.
  */
 function _batch_test_finished_helper($batch_id, $success, $results, $operations) {

Maybe "Provides" instead of "Performs"?

n)

+++ b/core/modules/system/tests/modules/batch_test/batch_test.module

/**
- * Simple form.
+ * Performs a simple form.
  */
 function batch_test_simple_form() {

/**
- * Submit handler for the simple form.
+ * Triggers submit handler for the simple form.
  */
 function batch_test_simple_form_submit($form, &$form_state) {

Performs is not the right verb here either... Actually I think this are form constructur/submission handlers and should be documented as in http://drupal.org/node/1354#forms -- same with the multi-step and chained forms and mock form later in this file.

o) same file:

+ * Batch operation: Submits form_test_mock_form using drupal_form_submit().
  */
 function _batch_test_nested_drupal_form_submit_callback($value) {

form_test_mock_form() needs ()

p) same file

/**
- * Batch 0: no operation.
+ * Batch 0: Operates nothing.
  */
 function _batch_test_batch_0() {

How about "Does nothing"?

q)

+++ b/core/modules/system/tests/modules/common_test/common_test.module

/**
- * Landing page for drupal_goto().
+ * This is a landing a page for drupal_goto().
  */
 function common_test_drupal_goto_land() {

Needs to start with a verb... How about "Provides a landing page..."? Also it's probably a page callback, so it should probably be "Page callback: Provides a landing..." and should have @see common_test_menu() [assuming it really is a page callback].

Same applies to the goto_land_fail() function just after this one.

r)

/**
- * Theme function for testing drupal_render() theming.
+ * Testing a theme function for drupal_render() theming.
  */
 function theme_common_test_foo($variables) {

Maybe "Provides a theme function..."?

Albert Volkman’s picture

Status: Needs work » Needs review
FileSize
14.99 KB
127.11 KB

Thanks for the review @jhodgdon! This patch is a monster.

l) I've actually seen both. Even k) has inconsistencies. Perhaps this should be handled in another issue?

New patch and interdiff attached!

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

l) Our standard for Drupal is to call it "Ajax", so a line that changes that to AJAX in the patch isn't too cool. But yes, let's check that in a follow-up.
k) We can do the form constructor docs in a follow-up patch on this issue... looks like you took care of them in your new patch anyway.

Anyway... this looks good! I'll commit it shortly.

jhodgdon’s picture

Title: Clean up API docs for system/tests, A-D, including subdirectories » Clean up API docs for system module tests, A-D, including subdirectories
Status: Reviewed & tested by the community » Active

COMMITTED!!! Many thanks to all who contributed to this massive patch!

So... Let's go back and take a look at what else needs updating... well in D8 we're now talking about core/modules/system/lib/Drupal/system/Tests/, so let's see what needs to be cleaned up still in Ajax, Batch, Bootstrap, Bundle, Cache, Common, and Database directories...

a) Standardize on Ajax not AJAX.

b) Class docs one-liners that need attention: Note that ones that say "Tests for the ..." can probably be fixed by just removing the "for":
- Ajax/AjaxTestBase: Should start with verb, like: "Provides a base class for Ajax tests" maybe?
- Ajax/MultiformTest: needs to be <= 80 characters
- Batch/PageTest: start with verb
- Batch/ProcessingTest: start with verb
- Batch/PercentagesUnitTest: start with verb
- Bootstrap::OverrideServerVariablesUnitTest: start with verb
- Bundle/BundleTest - verb tense
- Common/HtmlIdentifierUnitTest: Should start with verb
- Common/SchemaTest: should start with verb
- Common/TableSortExtenderUnitTest: verb tense
- Common/XssUnitTest: should start with a verb
- Database/DatabaseTestBase: should start with verb
- Database/DeleteTruncateTest: should start with verb
- Database/InsertLobTest: Should start with a verb
- Database/SelectSubqueryTest: should start with verb
- Database/SelectTableSortDefaultTest: doesn't end in .
- Database/UpdateTest - class one-liner doesn't make sense, should be "Tests the update query builder" I think?

c) Method docs one-liners that need attention:
- Bundle/BundleTest::testBundleRegistration() - verb tense
- Cache/CacheTestBase::assertCacheExists(), assertCacheRemoved() - verb tense and what's that "or" word?
- Cache/GenericCacheBackendUnitTestBase:: [most methods] - verb tense, and some need one-line summary
- Cache/GenericDatabaseBackendUnitTestBase:: several methods have no docs
- Cache/MemoryBackendUnitTest::createCacheBackend() - needs docs
- Common/AddFeedTest::testFeedIconEscaping - verb tense, one sentence, second sentence in new paragraph
- Common/FormatDateTest::testFormatDate() - should start with verb
- Common/SchemaTest::testSchema(), tryInsert() - needs docs
- Common/SchemaTest::assertFieldAdditionRemoval(), assertFieldCharacteristics() - verb tense
- Common/SimpleTestErrorCollectorTest::error - should start with a verb
- Common/TableSortExtenderUnitTest::testTableSortInit() - verb tense
- Common/UrlTest::hasClass() - needs docs
- Database/InsertTest::testInsertLastInsertID() - verb tense
- Database/MergeTest::testMergeUpdateExplicit() - needs to be <= 80 characters
- Database/SelectComplexTest::testHavingCountQuery() - doesn't have docs
- Database/SelectTableSortDefaultTest::testTableSortDefaultSort() - needs to be <= 80 characters

d) Other grammar/wording/spelling/misc issues
- Ajax/MultiformTest::testMultiForm() - "Tests that pages ... works correctly" should be "work".
- Batch/ProcessingTest::assertBatchMessages() - needs blank line between param/return
- Common/CascadingStylesheetsTest::testReset - reseting should be resetting I think?
- Database/SelectTest::testSelectDuplicateAlias() - doesn't quite make sense to me, maybe should say "are renamed when they are duplicates"?

Albert Volkman’s picture

Status: Active » Needs review
FileSize
27.13 KB

I *think* I got 'em all :)

jhodgdon’s picture

Status: Needs review » Needs work

Thanks, this patch is mostly excellent! The only things I think ought to be fixed are a few grammar/punctuation nitpicks:

a) More a/an/the in the following lines:

+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php

// the testing bin
+   * Gets testing bin.

// a specific implementation
+   * Allows specific implementation to change the environement before test run.

// the environment, the test run
+   * Allows alteration of environment after test run but before tear down.

b) This one needs to be split into summary (up to comma) and a separate paragraph. Or else the comma needs to be changed to ; -- and it also needs "a" added: "Gets a backend to test.":

+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
+   * Gets backend to test, this will get a shared instance set in the object.

c)

+++ b/core/modules/system/lib/Drupal/system/Tests/Common/HtmlIdentifierUnitTest.php
 /**
- * Test for cleaning HTML identifiers.
+ * Tests the cleaning HTML identifiers.

Seems like it would be better without "the".

d) Needs @param docs added:

+++ b/core/modules/system/lib/Drupal/system/Tests/Common/SchemaTest.php
+  /**
+   * Tests inserting data into an existing table.
+   */
   function tryInsert($table = 'test_table') {

+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+  /**
+   * Checks for class existence in link.
+   *
+   * @return bool
+   *   TRUE if the class is found, FALSE otherwise.
+   */
   private function hasClass($link, $class) {

e) Double negative, whoops!

+++ b/core/modules/system/lib/Drupal/system/Tests/Database/SelectTableSortDefaultTest.php
 
   /**
-   * Confirms that no error is thrown if a sort is not set in a default tableselect.
+   * Confirms that no error is thrown if no sort is not set in a tableselect.
    */
   function testTableSortDefaultSort() {
Albert Volkman’s picture

Status: Needs work » Needs review
FileSize
4.52 KB
27.89 KB

Fixed!

jhodgdon’s picture

Assigned: Albert Volkman » jhodgdon
Status: Needs review » Reviewed & tested by the community

Thanks, I think this one's ready to go! I'll commit it shortly.

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Assigned: jhodgdon » Unassigned
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 8.x -- thanks to all who worked on this!!

I guess we should probably try to port as many of the updates as possible to 7.x now. The tests are not in the same files, but it may be possible to port them anyway.

dcam’s picture

Status: Patch (to be ported) » Needs review
FileSize
119.76 KB

Backported #26 and #31 to D7.

dcam’s picture

Issue summary: View changes

.

jhodgdon’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

These issues are a lot of work with very little tangible payoff, so I'm closing the rest of them as "won't fix". Your efforts on working on this issue were appreciated... it was just my fault for starting a task that was very difficult to get right.

Let's instead put our effort into fixing and reviewing documentation that is really unclear and/or wrong, and I hope that the people who worked on these issues are not afraid to jump into a more reasonable issue!