felixkiss/uniquewith-validator — pull request #23 by jdunk (2014-12-21 09:55:39+00:00)
Title: Bug fix: error messages don't work.

Hi Felix. Great work on this much-needed super-useful validator.

I noticed the wrong validator instance property was getting set for the source error message templates: $this->messages is for a MessageBag object representing the result of validation, i.e. it's returned by $this->messages(). The "$messages" parameter that is passed into Illuminate/Validation/Validator.php::__construct() gets assigned to $this->customMessages, not $this->messages. So accessing $this->messages directly was a mistake.

Also, since the constructor accepts this (custom error messages) as a parameter, there was no need to modify the instance member directly, so I changed it to pass this array into the constructor instead.

Also, I noticed the Illuminate/Validation/Validator::__construct method signature had an extra param that ValidatorExtension did not support. So I added support for that as well.

The tests illustrate the problems I fixed. They will fail without the patch to ValidatorExtension. They succeed with it. I also removed unnecessary calls to trans->shouldReceive since this is done already in setUp(). I also unbroke the returning of data for certain mocked translator calls, so the error messages can be seen in the tests now also.

Let me know if any questions.