Issue #1431658 by Albert Volkman, kid_icarus, ChinggizKhan, xjm, rgristroph, connork: Clean up API docs for many system tests

8.0.x
Jennifer Hodgdon 2012-10-17 09:46:44 -07:00
parent deab5f5173
commit fc3cd2665b
33 changed files with 102 additions and 53 deletions

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Ajax;
use Drupal\simpletest\WebTestBase;
/**
* Base test system for AJAX tests.
* Provides a base class for Ajax tests.
*/
abstract class AjaxTestBase extends WebTestBase {

View File

@ -27,7 +27,7 @@ class FormValuesTest extends AjaxTestBase {
}
/**
* Submits forms with select and checkbox elements via AJAX.
* Submits forms with select and checkbox elements via Ajax.
*/
function testSimpleAjaxFormValue() {
// Verify form values of a select element.

View File

@ -69,7 +69,7 @@ class FrameworkTest extends AjaxTestBase {
}
/**
* Tests that new JavaScript and CSS files are returned on an AJAX request.
* Tests that new JavaScript and CSS files are returned on an Ajax request.
*/
function testLazyLoad() {
$expected = array(
@ -103,7 +103,7 @@ class FrameworkTest extends AjaxTestBase {
$this->assertTrue(!isset($original_settings[$expected['css']]), format_string('Page originally lacks the %css file, as expected.', array('%css' => $expected['css'])));
$this->assertTrue(!isset($original_settings[$expected['js']]), format_string('Page originally lacks the %js file, as expected.', array('%js' => $expected['js'])));
// Submit the AJAX request without triggering files getting added.
// Submit the Ajax request without triggering files getting added.
$commands = $this->drupalPostAJAX(NULL, array('add_files' => FALSE), array('op' => t('Submit')));
$new_settings = $this->drupalGetSettings();
@ -124,7 +124,7 @@ class FrameworkTest extends AjaxTestBase {
$this->assertFalse($found_settings_command, format_string('Page state still lacks the %css and %js files, as expected.', array('%css' => $expected['css'], '%js' => $expected['js'])));
$this->assertFalse($found_markup_command, format_string('Page still lacks the %css and %js files, as expected.', array('%css' => $expected['css'], '%js' => $expected['js'])));
// Submit the AJAX request and trigger adding files.
// Submit the Ajax request and trigger adding files.
$commands = $this->drupalPostAJAX(NULL, array('add_files' => TRUE), array('op' => t('Submit')));
$new_settings = $this->drupalGetSettings();
$new_css = $new_settings['ajaxPageState']['css'];
@ -134,12 +134,12 @@ class FrameworkTest extends AjaxTestBase {
$this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', array('%setting' => $expected['setting_name'])));
// Verify the expected CSS file was added, both to Drupal.settings, and as
// an AJAX command for inclusion into the HTML.
// an Ajax command for inclusion into the HTML.
$this->assertEqual($new_css, $original_css + array($expected['css'] => 1), format_string('Page state now has the %css file.', array('%css' => $expected['css'])));
$this->assertCommand($commands, array('data' => $expected_css_html), format_string('Page now has the %css file.', array('%css' => $expected['css'])));
// Verify the expected JS file was added, both to Drupal.settings, and as
// an AJAX command for inclusion into the HTML. By testing for an exact HTML
// an Ajax command for inclusion into the HTML. By testing for an exact HTML
// string containing the SCRIPT tag, we also ensure that unexpected
// JavaScript code, such as a jQuery.extend() that would potentially clobber
// rather than properly merge settings, didn't accidentally get added.

View File

@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Ajax;
/**
* Tests that Ajax-enabled forms work when multiple instances of the same form are on a page.
* Tests Ajax-enabled forms functionality with multiple instances of the form.
*/
class MultiFormTest extends AjaxTestBase {
@ -53,7 +53,7 @@ class MultiFormTest extends AjaxTestBase {
}
/**
* Tests that pages with the 'page_node_form' included twice works correctly.
* Tests that pages with the 'page_node_form' included twice work correctly.
*/
function testMultiForm() {
// HTML IDs for elements within the field are potentially modified with

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Batch;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the Batch API Progress page.
* Tests the Batch API Progress page.
*/
class PageTest extends WebTestBase {

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Batch;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the Batch API.
* Tests the Batch API.
*/
class ProcessingTest extends WebTestBase {
@ -166,6 +166,7 @@ class ProcessingTest extends WebTestBase {
* Array of raw strings to look for .
* @param $message
* Message to display.
*
* @return
* TRUE on pass, FALSE on fail.
*/

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Bundle;
use Drupal\simpletest\WebTestBase;
/**
* Test bundle registration to the DIC.
* Tests bundle registration to the DIC.
*/
class BundleTest extends WebTestBase {
@ -30,7 +30,7 @@ class BundleTest extends WebTestBase {
}
/**
* Test that services provided by module bundles get registered to the DIC.
* Tests that services provided by module bundles get registered to the DIC.
*/
function testBundleRegistration() {
$this->assertTrue(drupal_container()->getDefinition('file.usage')->getClass() == 'Drupal\\bundle_test\\TestFileUsage', 'Class has been changed');

View File

@ -41,7 +41,7 @@ abstract class CacheTestBase extends WebTestBase {
}
/**
* Assert or a cache entry exists.
* Asserts that a cache entry exists.
*
* @param $message
* Message to display.
@ -67,7 +67,7 @@ abstract class CacheTestBase extends WebTestBase {
}
/**
* Assert or a cache entry has been removed.
* Asserts that a cache entry has been removed.
*
* @param $message
* Message to display.

View File

@ -22,14 +22,26 @@ class DatabaseBackendUnitTest extends GenericCacheBackendUnitTestBase {
);
}
/**
* Creates a new instance of DatabaseBackend.
*
* @return
* A new DatabaseBackend object.
*/
protected function createCacheBackend($bin) {
return new DatabaseBackend($bin);
}
/**
* Installs system schema.
*/
public function setUpCacheBackend() {
drupal_install_schema('system');
}
/**
* Uninstalls system schema.
*/
public function tearDownCacheBackend() {
drupal_uninstall_schema('system');
}

View File

@ -13,8 +13,10 @@ use Drupal\simpletest\UnitTestBase;
use stdClass;
/**
* Tests any cache backend.
*
* Full generic unit test suite for any cache backend. In order to use it for a
* cache backend implementation extend this class and override the
* cache backend implementation, extend this class and override the
* createBackendInstace() method to return an object.
*
* @see DatabaseBackendUnitTestCase
@ -44,7 +46,7 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
protected $defaultValue;
/**
* Get testing bin.
* Gets the testing bin.
*
* Override this method if you want to work on a different bin than the
* default one.
@ -60,7 +62,7 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
}
/**
* Create a cache backend to test.
* Creates a cache backend to test.
*
* Override this method to test a CacheBackend.
*
@ -73,21 +75,22 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
protected abstract function createCacheBackend($bin);
/**
* Allow specific implementation to change the environement before test run.
* Allows specific implementation to change the environment before a test run.
*/
public function setUpCacheBackend() {
}
/**
* Allow specific implementation to alter the environement after test run but
* before the real tear down, which will changes things such as the database
* prefix.
* Allows alteration of environment after a test run but before tear down.
*
* Used before the real tear down because the tear down will change things
* such as the database prefix.
*/
public function tearDownCacheBackend() {
}
/**
* Get backend to test, this will get a shared instance set in the object.
* Gets a backend to test; this will get a shared instance set in the object.
*
* @return Drupal\Core\Cache\CacheBackendInterface
* Cache backend to test.
@ -335,7 +338,7 @@ abstract class GenericCacheBackendUnitTestBase extends UnitTestBase {
}
/**
* Test Drupal\Core\Cache\CacheBackendInterface::flush().
* Tests Drupal\Core\Cache\CacheBackendInterface::flush().
*/
public function testFlush() {
$backend = $this->getCacheBackend();

View File

@ -22,6 +22,12 @@ class MemoryBackendUnitTest extends GenericCacheBackendUnitTestBase {
);
}
/**
* Creates a new instance of MemoryBackend.
*
* @return
* A new MemoryBackend object.
*/
protected function createCacheBackend($bin) {
return new MemoryBackend($bin);
}

View File

@ -91,7 +91,9 @@ class AddFeedTest extends WebTestBase {
}
/**
* Check that special characters are correctly escaped. Test for issue #1211668.
* Checks that special characters are correctly escaped.
*
* @see http://drupal.org/node/1211668
*/
function testFeedIconEscaping() {
$variables = array();

View File

@ -82,7 +82,7 @@ class CascadingStylesheetsTest extends WebTestBase {
}
/**
* Makes sure that reseting the CSS empties the cache.
* Makes sure that resetting the CSS empties the cache.
*/
function testReset() {
drupal_static_reset('drupal_add_css');

View File

@ -74,7 +74,7 @@ class FormatDateTest extends WebTestBase {
}
/**
* Tests for the format_date() function.
* Tests the format_date() function.
*/
function testFormatDate() {
global $user;

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Common;
use Drupal\simpletest\UnitTestBase;
/**
* Test for cleaning HTML identifiers.
* Tests cleaning HTML identifiers.
*/
class HtmlIdentifierUnitTest extends UnitTestBase {
public static function getInfo() {

View File

@ -13,9 +13,10 @@ use Drupal\simpletest\WebTestBase;
use Exception;
/**
* Unit tests for the Schema API.
* Tests the Schema API.
*/
class SchemaTest extends WebTestBase {
/**
* A global counter for table and field creation.
*/
@ -30,7 +31,7 @@ class SchemaTest extends WebTestBase {
}
/**
*
* Tests database interactions.
*/
function testSchema() {
// Try creating a table.
@ -144,6 +145,15 @@ class SchemaTest extends WebTestBase {
$this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
}
/**
* Tests inserting data into an existing table.
*
* @param $table
* The database table to insert data into.
*
* @return
* TRUE if the insert succeeded, FALSE otherwise.
*/
function tryInsert($table = 'test_table') {
try {
db_insert($table)
@ -209,11 +219,12 @@ class SchemaTest extends WebTestBase {
* Tries to insert a negative value into columns defined as unsigned.
*
* @param $table_name
* The table to insert
* The table to insert.
* @param $column_name
* The column to insert
* The column to insert.
*
* @return
* TRUE if the insert succeeded, FALSE otherwise
* TRUE if the insert succeeded, FALSE otherwise.
*/
function tryUnsignedInsert($table_name, $column_name) {
try {
@ -228,7 +239,7 @@ class SchemaTest extends WebTestBase {
}
/**
* Test adding columns to an existing table.
* Tests adding columns to an existing table.
*/
function testSchemaAddField() {
// Test varchar types.
@ -300,7 +311,7 @@ class SchemaTest extends WebTestBase {
}
/**
* Assert that a given field can be added and removed from a table.
* Asserts that a given field can be added and removed from a table.
*
* The addition test covers both defining a field of a given specification
* when initially creating at table and extending an existing table.
@ -357,7 +368,7 @@ class SchemaTest extends WebTestBase {
}
/**
* Assert that a newly added field has the correct characteristics.
* Asserts that a newly added field has the correct characteristics.
*/
protected function assertFieldCharacteristics($table_name, $field_name, $field_spec) {
// Check that the initial value has been registered.

View File

@ -61,7 +61,7 @@ class SimpleTestErrorCollectorTest extends WebTestBase {
}
/**
* Error handler that collects errors in an array.
* Stores errors into an array.
*
* This test class is trying to verify that simpletest correctly sees errors
* and warnings. However, it can't generate errors and warnings that

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Common;
use Drupal\simpletest\UnitTestBase;
/**
* Test unicode handling features implemented in unicode.inc.
* Tests unicode handling features implemented in unicode.inc.
*/
class TableSortExtenderUnitTest extends UnitTestBase {
@ -44,7 +44,7 @@ class TableSortExtenderUnitTest extends UnitTestBase {
}
/**
* Test tablesort_init().
* Tests tablesort_init().
*/
function testTableSortInit() {

View File

@ -53,6 +53,17 @@ class UrlTest extends WebTestBase {
$this->assertTrue($this->hasClass($link, 'active'), format_string('Class @class is present on link to the current page', array('@class' => 'active')));
}
/**
* Checks for class existence in link.
*
* @param $link
* URL to search.
* @param $class
* Element class to search for.
*
* @return bool
* TRUE if the class is found, FALSE otherwise.
*/
private function hasClass($link, $class) {
return preg_match('|class="([^\"\s]+\s+)*' . $class . '|', $link);
}

View File

@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Database;
/**
* Delete/Truncate tests.
* Tests delete and truncate queries.
*
* The DELETE tests are not as extensive, as all of the interesting code for
* DELETE queries is in the conditional which is identical to the UPDATE and

View File

@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Database;
/**
* Insert tests using LOB fields, which are weird on some databases.
* Tests inserts using LOB fields, which are weird on some databases.
*/
class InsertLobTest extends DatabaseTestBase {

View File

@ -128,7 +128,7 @@ class InsertTest extends DatabaseTestBase {
}
/**
* Test that inserts return the proper auto-increment ID.
* Tests that inserts return the proper auto-increment ID.
*/
function testInsertLastInsertID() {
$id = db_insert('test')

View File

@ -98,7 +98,7 @@ class MergeTest extends DatabaseTestBase {
}
/**
* Confirms that we can merge-update a record successfully, with alternate replacement.
* Confirms that we can merge-update a record, with alternate replacement.
*/
function testMergeUpdateExplicit() {
$num_records_before = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField();

View File

@ -204,6 +204,9 @@ class SelectComplexTest extends DatabaseTestBase {
$this->assertEqual($record->$age_field, 27, 'Correct data retrieved.');
}
/**
* Tests having queries.
*/
function testHavingCountQuery() {
$query = db_select('test')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')

View File

@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Database;
/**
* Test case for subselects in a dynamic SELECT query.
* Tests for subselects in a dynamic SELECT query.
*/
class SelectSubqueryTest extends DatabaseTestBase {

View File

@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Database;
/**
* Tests the tablesort query extender
* Tests the tablesort query extender.
*/
class SelectTableSortDefaultTest extends DatabaseTestBase {
@ -77,7 +77,7 @@ class SelectTableSortDefaultTest extends DatabaseTestBase {
}
/**
* 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 set in a tableselect.
*/
function testTableSortDefaultSort() {
$this->drupalGet('database_test/tablesort_default_sort');

View File

@ -368,7 +368,7 @@ class SelectTest extends DatabaseTestBase {
}
/**
* Tests that aliases are renamed when duplicates.
* Tests that aliases are renamed when they are duplicates.
*/
function testSelectDuplicateAlias() {
$query = db_select('test', 't');

View File

@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Database;
/**
* Updates builder tests.
* Tests the update query builder.
*/
class UpdateTest extends DatabaseTestBase {

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\System;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the theme interface functionality.
* Tests the theme interface functionality.
*/
class ThemeTest extends WebTestBase {

View File

@ -11,7 +11,7 @@ use Drupal\simpletest\WebTestBase;
use Drupal\Core\Utility\ThemeRegistry;
/**
* Tests for the ThemeRegistry class.
* Tests the ThemeRegistry class.
*/
class RegistryTest extends WebTestBase {

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Update;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the invocation of hook_update_dependencies().
* Tests the invocation of hook_update_dependencies().
*/
class DependencyHookInvocationTest extends WebTestBase {

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Update;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the update dependency ordering system.
* Tests the update dependency ordering system.
*/
class DependencyOrderingTest extends WebTestBase {

View File

@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Update;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the update system functionality.
* Tests the update system functionality.
*/
class UpdateScriptTest extends WebTestBase {