This adds better documentation and IDE support.

CommentFileSizeAuthor
#9 getInfo-1999512-9.patch1.86 KBtim.plunkett

Comments

ebrowet’s picture

Hello,
i don't find any GetInfo class in my project. could you explain more.

dawehner’s picture

Oh right I haven't explained it really. The goal of the issue is to add a new method where we put the information on there.

tim.plunkett’s picture

Title: GetInfo should be an abstract class with docs on TestBase/UnitTestCase » getInfo() should be an abstract method with docs on TestBase/UnitTestCase
ebrowet’s picture

Ok i look at this ;).

jhodgdon’s picture

I think we also need to add setUp(). tearDown() seems to exist on TestBase, but I do not see setUp().

dawehner’s picture

Do we need one if there is one on both UnitTestBase and WebTestBase.

jhodgdon’s picture

I don't know... Are people allowed to extend TestBase or do they need to use UnitTestBase/WebTestBase?

dawehner’s picture

No it's not intended.

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new1.86 KB

How about this?

Status: Needs review » Needs work

The last submitted patch, getInfo-1999512-9.patch, failed testing.

jhodgdon’s picture

That looks reasonable to me.

Hmmm... There was a comment in the old documentation saying "Also, this method is empty because you can't have an abstract static method.". If that is true, this won't work?

So... I finally made some time to take a look at TestBase, WebTestBase, and UnitTestBase, to see what's up.

a) At the top of TestBase, it says to use WebTestBaseBase or UnitTestBaseBase, neither of which exist (?!?). Can we fix that in this patch too, or should we file another issue? While we're at it, the namespaces need to start with \ there too. (I checked this because of an assertion above that it would be OK not to have the methods on TestBase if they were on both UnitTestBase and WebTestBase, so I wanted to verify that TestBase actually said "don't extend this class", and it does -- it's just pointing people to the wrong actual classes to use). (So I think it's actually part of this issue to fix these typos, and no kittens will be harmed? :) ).

b) TestBase currently has tearDown(), but not setUp() or getInfo().

c) UnitTestBase currently has setUp() and would inherit tearDown() from TestBase. No getInfo().

d) WebTestBase -- same as (c).

So... This patch would indeed make it so that all of the classes that properly extend one of the two sanctioned base classes would have setUp(), tearDown(), and getInfo(), and if we also fix (a), we'd also ensure that everyone knows that they should extend one of the two actually sanctioned base classes.

As far as the second part of this patch, which replaces doc in UnitTestCase [not UnitTestBase!] with {#inheritdoc}... That won't work. This class doesn't extend TestBase -- it extends \PHPUnit_Framework_TestCase.

The follow-ups to the patch in this issue would be:
- Put an inheritdoc doc block in all setUp(), tearDown(), and getInfo() methods on all test classes extending TestBase
- Fix the online documentation for writing tests to say to use inheritdoc (https://drupal.org/node/325974)

klausi’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.