class CoderReviewCommentTest in Coder 7.2
Same name and namespace in other branches
- 7 coder_review/tests/coder_review_comment.test \CoderReviewCommentTest
Tests the functionality of comment review rules in Coder_review module.
Hierarchy
- class \CoderReviewCommentTest extends \CoderReviewTestCase
Expanded class hierarchy of CoderReviewCommentTest
File
- coder_review/
tests/ coder_review_comment.test, line 13
View source
class CoderReviewCommentTest extends CoderReviewTestCase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array(
'coder_review',
);
/**
* Constructs an instance of the CoderReviewCommentTest object.
*
* @param string|null $id
* (optional) The identifier string for this test. Defaults to NULL.
*/
function __construct($id = NULL) {
parent::__construct('comment', $id);
}
public static function getInfo() {
return array(
'name' => 'Coder Review Comment Style Tests',
'description' => 'Tests for the coder commenting standards review.',
'group' => 'CoderReview',
);
}
function setUp() {
parent::setUp();
$this->file_line = "/**\n * @file\n * Foo\n */\n";
$this->comment_header = $this->file_line;
}
/**
* ???
*/
function testGeneralCommentStyle() {
$this
->assertCoderReviewPass($this->comment_header . "/**\n * Comment.\n");
$this
->assertCoderReviewFail($this->comment_header . "/**\n* Comment.\n");
$this
->assertCoderReviewFail($this->comment_header . "/**\n *Comment.\n");
}
/**
* ???
*/
function testIdCommentLine() {
$this
->assertCoderReviewFail($this->comment_header . '// $Id$' . "\n");
$this
->assertCoderReviewFail($this->comment_header . '/* $Id$ */' . "\n");
}
/**
* ???
*/
function testHookImplementationComment() {
$this
->assertCoderReviewPass($this->comment_header . "/**\n * Implements hook_foo().\n */");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * Implements hook_foo()\n */");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * Implements hook_foo\n */");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * Implements hook_foo.\n */");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * implements hook_foo().\n */");
$this
->assertCoderReviewFail($this->comment_header . '// Implements hook_foo().');
$this
->assertCoderReviewFail($this->comment_header . "/* Implements hook_foo().\n */");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * Implementation of hook_foo().\n */");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * Implements of hook_foo().\n */");
}
/**
* ???
*/
function testFileDoxygenComment() {
$this
->assertCoderReviewPass("/**\n * @file\n * File description.");
$this
->assertCoderReviewFail("/**\n * @file File description.");
$this
->assertCoderReviewFail("/**\n * @file File description.");
}
/**
* ???
*/
function testSeeDoxygenComment() {
$this
->assertCoderReviewPass($this->comment_header . "/**\n * @see some_function()");
$this
->assertCoderReviewPass($this->comment_header . "/**\n * @see some_function(), foo.tpl.php");
$this
->assertCoderReviewPass($this->comment_header . "/**\n * @see some_function(), foo.tpl.php, bar.tpl.php");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * foo bar @see some_function()");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function, foo.tpl.php");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function(),foo.tpl.php");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function() foo.tpl.php");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function(), foo.tpl.php bar.tpl.php");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function(),");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function().");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see some_function(), foo.tpl.php.");
$this
->assertCoderReviewFail($this->comment_header . "/**\n * @see\n * some_function()");
$this
->assertCoderReviewPass($this->comment_header . "// @see some_function()");
$this
->assertCoderReviewPass($this->comment_header . "// @see foo.tpl.php");
$this
->assertCoderReviewPass($this->comment_header . "// @see some_function(), foo.tpl.php");
$this
->assertCoderReviewFail($this->comment_header . "// @see some_function");
}
/**
* Tests functionality to detect shell style comments.
*/
function testShellComment() {
$this
->assertCoderReviewFail($this->comment_header . "# function shell_comment() {\n");
}
/**
* Tests functionality to detect i.e. and e.g. phrases in comments.
*/
function testForExample() {
$this
->assertCoderReviewFail($this->comment_header . "// Whatever, e.g. this is wrong.\n");
$this
->assertCoderReviewPass($this->comment_header . "// Whatever, e.g., this is right.\n");
$this
->assertCoderReviewFail($this->comment_header . "// Whatever, (eg this is wrong).\n");
$this
->assertCoderReviewFail($this->comment_header . "// Whatever, (eg, this is wrong).\n");
$this
->assertCoderReviewPass($this->comment_header . "// Whatever, (e.g., this is right).\n");
$this
->assertCoderReviewFail($this->comment_header . "// Whatever, i.e., this is wrong.\n");
$this
->assertCoderReviewPass($this->comment_header . "// Whatever, i.e. this is right.\n");
$this
->assertCoderReviewFail($this->comment_header . "// Whatever, (ie this is wrong).\n");
$this
->assertCoderReviewFail($this->comment_header . "// Whatever, ie this is wrong.\n");
$this
->assertCoderReviewFail($this->comment_header . "// ie stands for example, and this is not OK.\n");
$this
->assertCoderReviewPass($this->comment_header . "// IE stands for Internet Explorer, and this is OK.\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('Whatever, e.g. this is wrong.');\n");
$this
->assertCoderReviewPass($this->comment_header . " return t('Whatever, e.g., this is right.');\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('Whatever, (eg this is wrong).');\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('Whatever, (eg, this is wrong).');\n");
$this
->assertCoderReviewPass($this->comment_header . " return t('Whatever, (e.g., this is right).');\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('Whatever, i.e., this is wrong.');\n");
$this
->assertCoderReviewPass($this->comment_header . " return t('Whatever, i.e. this is right.');\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('Whatever, (ie this is wrong).');\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('Whatever, ie this is wrong.');\n");
$this
->assertCoderReviewFail($this->comment_header . " return t('ie stands for example, and this is not OK.');\n");
$this
->assertCoderReviewPass($this->comment_header . " return t('IE stands for Internet Explorer, and this is OK.');\n");
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CoderReviewCommentTest:: |
public static | property | Modules to enable. | |
CoderReviewCommentTest:: |
public static | function | ||
CoderReviewCommentTest:: |
function | |||
CoderReviewCommentTest:: |
function | ??? | ||
CoderReviewCommentTest:: |
function | Tests functionality to detect i.e. and e.g. phrases in comments. | ||
CoderReviewCommentTest:: |
function | ??? | ||
CoderReviewCommentTest:: |
function | ??? | ||
CoderReviewCommentTest:: |
function | ??? | ||
CoderReviewCommentTest:: |
function | ??? | ||
CoderReviewCommentTest:: |
function | Tests functionality to detect shell style comments. | ||
CoderReviewCommentTest:: |
function | Constructs an instance of the CoderReviewCommentTest object. |