Commit fc3cd266 authored by jhodgdon's avatar jhodgdon

Issue #1431658 by Albert Volkman, kid_icarus, ChinggizKhan, xjm, rgristroph,...

Issue #1431658 by Albert Volkman, kid_icarus, ChinggizKhan, xjm, rgristroph, connork: Clean up API docs for many system tests
parent deab5f51
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Base test system for AJAX tests.
* Provides a base class for Ajax tests.
*/
abstract class AjaxTestBase extends WebTestBase {
......
......@@ -27,7 +27,7 @@ function setUp() {
}
/**
* 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.
......
......@@ -69,7 +69,7 @@ function testAJAXRenderError() {
}
/**
* 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 @@ function testLazyLoad() {
$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 @@ function testLazyLoad() {
$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 @@ function testLazyLoad() {
$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.
......
......@@ -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 @@ function setUp() {
}
/**
* 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
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Tests for the Batch API Progress page.
* Tests the Batch API Progress page.
*/
class PageTest extends WebTestBase {
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Tests for the Batch API.
* Tests the Batch API.
*/
class ProcessingTest extends WebTestBase {
......@@ -166,6 +166,7 @@ function testBatchLargePercentage() {
* Array of raw strings to look for .
* @param $message
* Message to display.
*
* @return
* TRUE on pass, FALSE on fail.
*/
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Test bundle registration to the DIC.
* Tests bundle registration to the DIC.
*/
class BundleTest extends WebTestBase {
......@@ -30,7 +30,7 @@ public static function getInfo() {
}
/**
* 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');
......
......@@ -41,7 +41,7 @@ protected function checkCacheExists($cid, $var, $bin = NULL) {
}
/**
* Assert or a cache entry exists.
* Asserts that a cache entry exists.
*
* @param $message
* Message to display.
......@@ -67,7 +67,7 @@ protected function assertCacheExists($message, $var = NULL, $cid = NULL, $bin =
}
/**
* Assert or a cache entry has been removed.
* Asserts that a cache entry has been removed.
*
* @param $message
* Message to display.
......
......@@ -22,14 +22,26 @@ public static function getInfo() {
);
}
/**
* 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');
}
......
......@@ -13,8 +13,10 @@
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 @@ protected function getTestBin() {
}
/**
* Create a cache backend to test.
* Creates a cache backend to test.
*
* Override this method to test a CacheBackend.
*
......@@ -73,21 +75,22 @@ protected function getTestBin() {
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 @@ public function testDeleteMultiple() {
}
/**
* Test Drupal\Core\Cache\CacheBackendInterface::flush().
* Tests Drupal\Core\Cache\CacheBackendInterface::flush().
*/
public function testFlush() {
$backend = $this->getCacheBackend();
......
......@@ -22,6 +22,12 @@ public static function getInfo() {
);
}
/**
* Creates a new instance of MemoryBackend.
*
* @return
* A new MemoryBackend object.
*/
protected function createCacheBackend($bin) {
return new MemoryBackend($bin);
}
......
......@@ -91,7 +91,9 @@ function urlToRSSLinkPattern($url, $title = '') {
}
/**
* 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();
......
......@@ -82,7 +82,7 @@ function testAddExternal() {
}
/**
* 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');
......
......@@ -74,7 +74,7 @@ function testAdminDefinedFormatDate() {
}
/**
* Tests for the format_date() function.
* Tests the format_date() function.
*/
function testFormatDate() {
global $user;
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\UnitTestBase;
/**
* Test for cleaning HTML identifiers.
* Tests cleaning HTML identifiers.
*/
class HtmlIdentifierUnitTest extends UnitTestBase {
public static function getInfo() {
......
......@@ -13,9 +13,10 @@
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 @@ public static function getInfo() {
}
/**
*
* Tests database interactions.
*/
function testSchema() {
// Try creating a table.
......@@ -144,6 +145,15 @@ function testSchema() {
$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 @@ function testUnsignedColumns() {
* 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 @@ function tryUnsignedInsert($table_name, $column_name) {
}
/**
* Test adding columns to an existing table.
* Tests adding columns to an existing table.
*/
function testSchemaAddField() {
// Test varchar types.
......@@ -300,7 +311,7 @@ function testSchemaAddField() {
}
/**
* 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 @@ protected function assertFieldAdditionRemoval($field_spec) {
}
/**
* 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.
......
......@@ -61,7 +61,7 @@ function testErrorCollect() {
}
/**
* 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
......
......@@ -10,7 +10,7 @@
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 @@ function tearDown() {
}
/**
* Test tablesort_init().
* Tests tablesort_init().
*/
function testTableSortInit() {
......
......@@ -53,6 +53,17 @@ function testLCustomClass() {
$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);
}
......
......@@ -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
......
......@@ -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 {
......
......@@ -128,7 +128,7 @@ function testInsertFieldOnlyDefinintion() {
}
/**
* Test that inserts return the proper auto-increment ID.
* Tests that inserts return the proper auto-increment ID.
*/
function testInsertLastInsertID() {
$id = db_insert('test')
......
......@@ -98,7 +98,7 @@ function testMergeUpdateExcept() {
}
/**
* 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();
......
......@@ -204,6 +204,9 @@ function testCountQuery() {
$this->assertEqual($record->$age_field, 27, 'Correct data retrieved.');
}
/**
* Tests having queries.
*/
function testHavingCountQuery() {
$query = db_select('test')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
......
......@@ -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 {
......
......@@ -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 @@ function testTableSortQueryFirst() {
}
/**
* 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');
......
......@@ -368,7 +368,7 @@ function testRandomOrder() {
}
/**
* Tests that aliases are renamed when duplicates.
* Tests that aliases are renamed when they are duplicates.
*/
function testSelectDuplicateAlias() {
$query = db_select('test', 't');
......
......@@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Database;
/**
* Updates builder tests.
* Tests the update query builder.
*/
class UpdateTest extends DatabaseTestBase {
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Tests for the theme interface functionality.
* Tests the theme interface functionality.
*/
class ThemeTest extends WebTestBase {
......
......@@ -11,7 +11,7 @@
use Drupal\Core\Utility\ThemeRegistry;
/**
* Tests for the ThemeRegistry class.
* Tests the ThemeRegistry class.
*/
class RegistryTest extends WebTestBase {
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Tests for the invocation of hook_update_dependencies().
* Tests the invocation of hook_update_dependencies().
*/
class DependencyHookInvocationTest extends WebTestBase {
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Tests for the update dependency ordering system.
* Tests the update dependency ordering system.
*/
class DependencyOrderingTest extends WebTestBase {
......
......@@ -10,7 +10,7 @@
use Drupal\simpletest\WebTestBase;
/**
* Tests for the update system functionality.
* Tests the update system functionality.
*/
class UpdateScriptTest extends WebTestBase {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment