MDL-44070 Conditional availability enhancements (3): API/tests

Implements the new availability/plugin API. This represents a
Boolean tree structure that controls the availability of an
item.

In this commit, the new API is not yet connected to the rest of
Moodle, so it doesn't do anything yet.