t('api_link_documentation()'), 'description' => t('Test the api_link_documentation() function.'), 'group' => 'API Module', ); } function testApiLinkDocumentation() { $tests = array( // Should be linked array( 'message' => 'Function name linking', 'data' => 'sample_function(', 'expected' => 'sample_function(', ), array( 'message' => 'Function name linking with preceding space', 'data' => ' sample_function(', 'expected' => ' sample_function(', ), array( 'message' => 'Function @link', 'data' => '@link sample_function A sample function. @endlink', 'expected' => 'A sample function.', ), // Should not be linked array( 'message' => 'Function name linking with preceding non-space character', 'data' => '.sample_function(', 'expected' => '.sample_function(', ), array( 'message' => 'Function name linking with preceding letter', 'data' => 'asample_function(', 'expected' => 'asample_function(', ), array( 'message' => 'Function name linking without parenthesis', 'data' => 'sample_function', 'expected' => 'sample_function', ), array( 'message' => 'Function name linking inside a HTML tag', 'data' => '', 'expected' => '', ), array( 'message' => 'Function \\@link', 'data' => '\\@link sample_function A sample function. @endlink', 'expected' => '@link sample_function A sample function. @endlink', ), // Should be linked array( 'message' => 'File name linking', 'data' => 'sample.php', 'expected' => 'sample.php', ), array( 'message' => 'File name linking with preceding space', 'data' => ' sample.php', 'expected' => ' sample.php', ), array( 'message' => 'File name linking with following space', 'data' => 'sample.php ', 'expected' => 'sample.php ', ), array( 'message' => 'File name linking with following punctuation', 'data' => 'sample.php.', 'expected' => 'sample.php.', ), array( 'message' => 'File @link', 'data' => '@link sample.php A sample file. @endlink', 'expected' => 'A sample file.', ), // Should not be linked array( 'message' => 'File name linking with preceding non-space character', 'data' => '.sample.php', 'expected' => '.sample.php', ), array( 'message' => 'File name linking with preceding letter', 'data' => 'asample.php', 'expected' => 'asample.php', ), array( 'message' => 'File name linking inside a HTML tag', 'data' => '', 'expected' => '', ), array( 'message' => 'File \\@link, does fill in file link', 'data' => '\\@link sample.php A sample file. @endlink', 'expected' => '@link sample.php A sample file. @endlink', ), array( 'message' => 'Escaped @tag is not unescaped.', 'data' => 'Escaped \\@stuff.', 'expected' => 'Escaped @stuff.', ), array( 'message' => 'Double-escaped @tag is not unescaped.', 'data' => 'Double-escaped \\\\@stuff.', 'expected' => 'Double-escaped \\@stuff.', ), ); foreach ($tests as $test) { $result = api_link_documentation($test['data'], 6); $this->assertEqual($result, $test['expected'], $test['message']); } } }