We use Drupal 7 as our base CMS tool.
For one specific product, something like an ERP, we've created sort of a non-drupal layer, to keep our specific business code in.
It would be something like this:
------------- | Business | -> This would be our business specific code layer ------------- | Glue | -> This is where we connect with the basic Drupal API as we need ------------- | Drupal | -> This is Drupal API -------------
We have the concept of
Repository, which is a basic class that retrieves something from the database in the form of an
Entity or a
This layer is connected to Drupal, since it needs access to the
db_query() method, from the Drupal 7 API.
Business layer is tested using
PHPUnit, with 100% coverage.
Now we are trying to test the
Glue layer as well, the unit of the
Repositories, their return values and parameters.
In order to do that, we came to the conclusion that we would need to mock the
Drupal database access API.
But to do that, what would be the correct or best approach?
- Wrap the
Drupalinto a class that could be mocked in the tests?
- Not test the