We can replace this with an assertion from PHPUnit, which will fail the test it element is empty:
Assertion::assertNotNull( $this->mainAttributes[strtolower( $block )] ); 
I've placed this in the makeXpathForBlock function