Posted by sun on November 11, 2011 at 7:41pm
4 followers
Jump to:
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | simpletest.module |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | API clean-up, Testing system |
Issue Summary
getInfo() is undocumented currently.
abstract public static getInfo() would make sense for this purpose, but that's not possible, not only in PHP.
So it looks like there should be an interface for DrupalTestCase.
Since this is probably right, but highly debatable, I'm just throwing out the proposal in attached patch, not changing actual tests.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| drupal8.test-interface.0.patch | 2.31 KB | Idle | PASSED: [[SimpleTest]]: [MySQL] 1,335 pass(es). | View details | Re-test |
Comments
#1
Ahem, okay, that could lead to problems down the line ;)
It means that all test cases are ignored unless they explicitly implement the interface. We'd have to be extremely careful and check that patches adding test cases actually implement the interface.
Investigating the idea of just fixing the documentation issue, I tried "implements" on the interface on the root class like this:
abstract class DrupalTestCase implements DrupalTestCaseInferface {}
However, that means that the interface is automatically inherited. Hence, all child classes implement the interface, so this is always TRUE:
in_array('DrupalTestCaseInferface', class_implements($class))Going further, I tried whether additionally checking for getInfo() could resolve it:
if (in_array('DrupalTestCaseInferface', class_implements($class)) && method_exists($class, 'getInfo')) {but that still throws a fatal error for all base test classes:
Fatal error: Class ModuleTestCase contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (DrupalTestCaseInferface::getInfo)Hence, the only option to document getInfo() is the patch in #0.