Depending on the tests executed it was possible to arrive
to favourites tests with 2 "concepts" (say userid and contextid,
or userid and itemid) having the same ID.
Then, the array_diff() operations used by some mock stuff in the
tests wrongly was returning matches by value, ultimately causing
the test to fail.
Now, the matching is performed using array_diff_assoc() that takes
keys into considation when performing the match.
Added a new type of service which can be used to interact with the
all favourites for a given component, not just those owned by a a
specific user. As such, objects of this type are scoped to a component.
This gets rid of specific repo functions which were unused, and makes
sure the following methods are defined on the interface, implemented
and tested:
- exists_by($criteria)
- find_by($criteria)
- delete_by($crtieria)
Also, added missing tests for find_favourite() repo method.
Let's worry about reuse of the crud code later, when that requirement
arises, so moved that into the ifavourite_repository interface, and then
renamed it favourite_repository_interface.
This patch adds several things:
- favourite entity class under local/entity
- refactoring of repository and service to use the new class instead
of stdClass.
- update repository unit tests to use the object instead of stdClass.
- update service_test so that the mock repo requires the object for
the add operation.
- remove unnecessary constructor from favourites_repository class.