actionService = $this->createMock(ActionDependenciesDAOServiceInterface::class); $this->action = new class($this->actionService) extends AbstractAction { public $isSecure; public $validByForm; protected function isSecure(): bool { return $this->isSecure; } protected function isValid(): bool { return $this->validByForm; } protected function proccess() { } }; } public function testNotValidByFormException(): void { $this->action->isSecure = true; $this->action->validByForm = false; $this->expectException(FormInvalidException::class); $this->action->execute(); } }