FieldAttachTestCase::setUp() doesn't honor its argument, which makes the whole class useless to test alternative field storage implementations.

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new884 bytes

Here is the patch.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Right. The real solution would be #610072: setUp() function accepting array as arguments, though. The way setUp() currently uses its arguments is really not handy.

dries’s picture

This solution isn't quite elegant, IMO but I guess it does the trick.

yched’s picture

This solution isn't quite elegant

Fully agreed - that's why I think the change linked in #2 is the way forward. It's already been committed to simpletest contrib 7 branch (I'm not sure what's the status of this wrt D7 core's simpletest module). API change, though.

webchick’s picture

Hm. I personally lean towards won't fix on this, and tackling #610072: setUp() function accepting array as arguments instead. We should be able to make it accept either a string or an array, for backwards compatibility.

yched’s picture

re webchick: this is a problem we already faced before, and this exact same code is already in FieldTestCase::setUp(), so while I agree that #610072: setUp() function accepting array as arguments is the way forward, committing this meanwhile doesn't add uglyness that's not already in :-/.

Status: Reviewed & tested by the community » Needs review

Re-test of 644628-fieldattachtestcase-reuse.patch from comment #1 was requested by webchick.

chx’s picture

Status: Needs review » Reviewed & tested by the community

too late for the other issue. sorry.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Ok fair enough. But let's at least leave a one-liner or so explaining why we are doing it this way.

yched’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.42 KB

This gets even worse with PHP 5.3 in the mix - see chx's #709346: Field tests are broken in 5.3 and can not be extended

Moved chx's patch over here, and added the comment webchick asked for in #9. And back to RTBC.

That PHP 5.3 subtlety, and the code duplication involved for any test that wants to be subclassable, makes it really unfortunate that this is not being fixed by #610072: setUp() function accepting array as arguments, though...

yched’s picture

Would #610072: setUp() function accepting array as arguments be acceptable if setUp() could handle both a variable number of strings OR one single array of strings ?
I doubt the code would be so ugly as the one we're adding here...

[edit: actually, that's exactly webchick's proposal in comment #5, which chx crossed as 'too late' (the irony...) - I really think we should reconsider that]

webchick’s picture

Yes, I would really very much rather change the function signature of setUp() in a fully backwards-compatible way than commit complete cruft like this. No offense. ;)

But I don't understand the PHP 5.3.0 hunks and why the other issue is going to fix those. Help?

chx’s picture

The other issue helps because then you can call parent::setup($modules) without needing a dynamic call which is not easy.

yched’s picture

And PHP 5.3 needs specific code for dynamic calls to parent::setup($modules) :
http://www.php.net/manual/en/function.call-user-func-array.php#93744

dries’s picture

I agree with webchick in #12. :)

webchick’s picture

Status: Reviewed & tested by the community » Closed (won't fix)