Ok, I am brand new to TDD within the Drupal environment but we have been asked to try write tests where possible for our custom and/or utility/support modules.
I've managed to write some simple PHPUnit tests, but because the classes within my module have some methods that try to load entities (Content Types built via standard Drupal UI) and then do various thing with them, I am having trouble how to bridge this gap.
Currently when I run my tests most of the assertions pass as they are fairly simply but the one is giving me a warning:
1) Warning The data provider specified for Drupal\Tests\lrgContentTypes\Unit\AuctionEventTest::testGetNodeFields is invalid. \Drupal::$container is not initialised yet. \Drupal::setContainer() must be called with a real container.
This has only occurred recently because I have now fleshed out the code for the entity class that the parent is trying to pass in the provider.
I am unsure where to go from here, the Drupal 8 documentation seems to be spotty and gives no clear guidance from a basics point of view.
Is there anywhere that gives a definitive set of examples to show how to test methods that try to load a node via
Node::load and where
Entity Reference Revision objects are expected?
I will post my classes and test classes below in case its relevant.
1) AuctionEventTest class
2) AuctionLotTest class
3) AuctionEvent Class (Auction Event content type utility class)
4) AuctionLot Class (Auction Lot Entity Reference Revision util class)