Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
plugin system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2014 at 18:32 UTC
Updated:
20 Jan 2015 at 19:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mile23This patch covers Context::getContextValue(), which is the most complex method in this class (CRAP score: 12).
As noted in the issue summary, this patch avoids
getConstraints(), which is buggy.Comment #2
dawehnerCan't we split this up into two test methods and use two times the same provider?
Comment #3
mile23The logic follows the logic of getContextValue().
I thought about refactoring it the way you mention, but it doesn't make much sense, since there are only three data sets from the data provider.
Nevertheless: Judge for yourself. :-)
I prefer the patch in #1.
Comment #4
mile23Anyone? :-)
Comment #5
mile23Comment #6
duaelfr6/6 tests PASS
29% coverage but most of the uncovered code is made of getters and setters.
Don't we want the ::getConstraints() and ::validate() methods tested ?
Usual comments:
Unused ;)
I don't like that kind of condition but that's just my point of view...
Comment #7
mile23See the summary about
getConstraints(). It's buggy, so I didn't test it :-) #2378297: Inconsistent use of ContextDefinitionInterface in Drupal\Component\Plugin\Context\Context::getConstraints()validate()depends on a static factory. It should really allow you to inject a validator, but it doesn't.Point 2: That's what I mean about the patch in #1 being better.
Comment #8
daffie commented@Mile23: If you think that the validate() should use injection instead of a static factory, why don't you create an issue for that.
I prefer the patch from comment #1. I have added to #2378297: Inconsistent use of ContextDefinitionInterface in Drupal\Component\Plugin\Context\Context::getConstraints() that there is the need for a PHPUnit test for the ::getConstraints() method.
Fix the first comment from DuaelFr: remove the unused:
use Drupal\Component\Plugin\Context\Context;.If there is an issue created for the ::validate() method and in that issue an mention for creating a PHPUnit test for the ::validate() method, then I shall give this issue an RTBC.
Comment #9
mile23Here's the patch from comment #1, minus the
usestatement. :-)Issue about
validate()to come.Comment #10
mile23Comment #11
mile23Hello, testbot?
Comment #12
mile23Filed #2382805: Modify Drupal\Component\Plugin\Context\ContextInterface to allow for unit testing..
One or the other of these two issues will need a re-roll when the other drops.
Comment #13
daffie commentedIn this patch is the file ContextText class added with a PHPUnit test. The only function that is been tested is getContextValue(). There are also a few getters and setters functions that are not tested. The two remaining functions are getConstraints() and validate(). For the first function is #2378297: Inconsistent use of ContextDefinitionInterface in Drupal\Component\Plugin\Context\Context::getConstraints() created and for the second function #2382805: Modify Drupal\Component\Plugin\Context\ContextInterface to allow for unit testing.. The patch lloks good to me and I give it a RTBC.
Comment #15
mile23Patch applies and everything passes locally so I assume it's the testbot.
Comment #17
mile23Comment #18
daffie commentedBefore the retest failed it was RTBC. Nothing has changed and the testbot is happy again. So back to RTBC.
Comment #19
webchickNot really the most qualified to give these sign-off, but they've been sitting here long enough for someone to raise objections, and moar test coverage is never a bad thing.
Committed and pushed to 8.0.x. Thanks!