Fix duplicate errors when config data is not different.

Perform a more careful inspection of config data when checking
duplicates. Simply check the json_encode() value has issues when default
config is involved. array_diff* have similar issues with nested data.

Since the empty config data will be the most common case the previous
optimization is still valid and very useful.

Refs #5286
Add additional test coverage.

Refs #5286
Merge pull request #5289 from cakephp/issue-5286

Fix duplicate errors when config data is not different.