Don't find this solution, as more people try testing abstract classes. This is not what i want.
I have patter strategy, and all classes should implements interface. Wanted to add base spec, that rest should extends and add own things.
I should repeat my code in all specs?
Now, I have 2 in to strategies specs:
function it_should_implements_LoadStrategyInterface()
{
$this->shouldBeAnInstanceOf(LoadStrategyInterface::class);
}
How to not repeat myself?
I try to do AbstractStrategy
, but got
Class 'spec\LoadStrategy\Strategies\AbstractStrategy' not found
I'm missing something? Or code like this, is not autoloaded? Or maybe, this is bad practice?
Yes, you should repeat it in every spec. A workaround is to make your Spec file extending another Spec file (where you have this common example) that itself extends the base phpspec class. I would go with explicit describe (testing) this constraint in every concrete class by the way.