Looking at the Yii 3 session package, the class is made final, which makes it impossible to mock by phpunit. The alternative is type-hint the interface instead and make a dummy session class implementing the interface (anonymous, for example), but then you have to implement all methods in the interface. This is by design, or? Just the price to pay by using the final keyword? Kinda makes the mock functionality of phpunit useless.