Closed (fixed)
Project:
Rules
Version:
8.x-3.x-dev
Component:
User Interface
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Sep 2016 at 23:24 UTC
Updated:
30 Nov 2019 at 18:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sukanya.ramakrishnan commentedOk, i understand what the 'assignment restriction' means now. The validation is done only on saving the form. I would assume that the form could display the applicable 'input' method based on the restrictions. Will try and submit a patch soon!
Thanks
Sukanya
Comment #3
tr commentedConfirmed that 'assignment_restriction' doesn't seem to have any effect - direct input mode is *always* the default, regardless of 'assignment_restriction', and 'assignment_restriction' doesn't force a mode to be used like it did in D7.
I'm bumping the priority because this is causing recurring issues like #2998793: Node is of Type error.
Added 'Needs test' tag because we really should have a test to make sure 'assignment_restriction' works, as part of the fix.
Comment #4
tr commentedComment #5
tr commentedComment #6
tr commentedComment #7
jonathan1055 commentedWhilst investigating #3047684: List Contextdefinition must be multiple @TR suggested that it would be solved by getting the Assignment Restriction code working, because then the switch button should not be displayed in those cases. And this issue seems a good thing to do anyway, as this feature has not been implemented yet in the context form, but the background settings and functions are all done.
One test had to be altered because it was pressing the button to switch to data selection whereas now with the implementaion this conditon is restricted to data selection anyway. There was even a @todo by the button press saying "this should not be necessary once the data context is set to selector by default"
Because there is another test named
testMultipleContextActionI made a minor change to the test name fromtestMultipleContexttotestMultipleInputContextto make it easier to use-filter=when running phpunit.This patch does not make any changes to the current settings in the context definitions, it just implements the feature in the form. To assist in manual testing here are the places we need to check:
I know that this feature will need tests to prove the setting is working, but here are the code changes, and so far it seems to work.
Comment #8
tr commentedNice! Thanks for working on this. I think it will be a big usability improvement, especially with the "Node is of Type" condition where people keep tripping over this.
Yup, I put that @todo in there when I wrote the test (see #2855433: ContextFormTrait.php not processing multi-line conditions correctly when line break character is '\r\n') because it did not default to 'selector' like it should have.
Good idea, I hadn't noticed that.
It's very nice! The tests shouldn't be too hard - we just have to check that the button doesn't appear and the correct mode is chosen when the assignment_restriction is set, and that the button does appear when assignment_restriction is not set. And we will also have to go through all the conditions and actions to ensure that assignment_restriction is used in exactly the same places as 'restriction' was in D7. I've found that a number of the condition/action parameters did not get ported properly, they were just left off, so I've done several rounds already of comparing and correcting the D7 condition/action definitions against the D8 annotation. (I have one patch in the works for missing descriptions in the annotation - that should get committed within the next few days.)
Here's a modified patch where instead of using the hardwired strings
'selector'and'input'I used the constantsContextDefinitionInterface::ASSIGNMENT_RESTRICTION_SELECTORandContextDefinitionInterface::ASSIGNMENT_RESTRICTION_INPUT. This is something I've had fixed locally for a while, it just didn't seem important enough to open a separate issue just to do this. But as long as we're working on the assignment_restriction, we should do this now.Give me a few days to do some manual testing and convince myself this is working ...
Comment #9
jonathan1055 commentedYes, good idea to use this patch to change to the constants. It also showed that we were using the Core ContextDefinitionInterface not the Rules extension of it, so that's good to fix too.
I will work on the tests.
Comment #10
jonathan1055 commentedHere's a patch with a new test. The code in ContextFormTrait is not included so this will fail. I used actual conditions and actions provided in the Rules model for the examples. I did look at the ones provided in the rules_test module, but none had restrictions defined, and when I added restrictions it caused existing tests to fail (which of course could have been modified to cater for the change in default for 'selector' restrictions but I thought that was making more unnecessary work). Other existing tests use the actual conditions and actions provided by Rules. If we find that the restrictions for these four contexts have to be changed in future it will be easy enough to adjust the new test. I picked ones that are not likely to change.
Comment #11
jonathan1055 commentedAs expected the patch in #10 failed. Even though it stops at the first failed assertion I have tested this locally, commenting out assertions, and it fails for the other assertions too.
Here's the new test plus implementation as per patch #8
Comment #12
tr commentedI like this very much. I think the choices you made in #10 were correct. Just a few minor things and I think it's ready to commit. Thanks for all your work on this!
In the test, you use
$this->expressionManager,$this->storage, and$this->accountbut none of those are defined as class variables - this only works because PHP allows you to dynamically define class variables like this, but best practice would be to addprotected $accountfor instance to theConfigureAndExecuteTestclass definition, with appropriate documentation comments. While changing$accountto$this->accountis useful because it is used in more than one test method (and thus should be in the class definition and initialized in the constructor), I think$expression_managerand$storageshould probably be defined as local variables, rather than using$this>expressionManagerand$this->storagebecause those are not used in other test methods.Otherwise, I don't see any problems with the patch.
Comment #13
jonathan1055 commentedThank you.
Yes, you are right, I was being lazy.
Yes I agree. I do use those in the new Typed Data Widgets tests, but you are right that they should be local here. Then if I use them in a new subsequent test I can move them.
I guess in general for things like this, it depends on how many tests use it (and thus would benefit from it being a class property) vs how many tests do not use it (and thus it is an unnecessary overhead when running that test).
New patch and interdiff for review.
Comment #15
tr commentedOK, committed! Thanks - this is going to help a lot towards reducing the support requests, because it will now be a whole lot more difficult to enter an invalid value when configuring conditions and actions.
Comment #16
jonathan1055 commentedThanks for committing. Yes it should help a lot.
Unassigning.