capacityMock = $this->createMock(CapacityInterface::class); $this->subject = new CapacityRestriction(); $this->subject->setServiceLocator($this->getServiceLocatorMock([ CapacityInterface::SERVICE_ID => $this->capacityMock, ])); parent::setUp(); } public function testDoesComply_WhenConfigValueIsZero_ThenRestrictionIsNotApplied() { $this->capacityMock->expects($this->never())->method('consume'); $this->assertTrue($this->subject->doesComply(0)); } public function testDoesComply_WhenConfigValueIsProvided_ThenCapacityIsConsumed() { $this->capacityMock->expects($this->once())->method('consume')->willReturn(true); $this->assertTrue($this->subject->doesComply(1)); } }