|
|
@@ -69,24 +69,23 @@ class AbstractVoterTest extends TestCase
|
|
|
protected InternalRequestsService | MockObject $internalRequestsService;
|
|
|
protected SwitchUser | MockObject $switchUserService;
|
|
|
|
|
|
+ private bool $initialConditionSaved = false;
|
|
|
private ?string $initialEntityClass = null;
|
|
|
private ?array $initialAllowedOperations = null;
|
|
|
private ?int $initialSwitchHeader = null;
|
|
|
private ?string $initialRemoteAddr = null;
|
|
|
private ?string $initialInternalRequestToken = null;
|
|
|
|
|
|
- public function __construct(?string $name = null, array $data = [], $dataName = '')
|
|
|
- {
|
|
|
- parent::__construct($name, $data, $dataName);
|
|
|
-
|
|
|
+ private function saveInitialCondition() {
|
|
|
$this->initialEntityClass = TestableAbstractVoter::getEntityClass();
|
|
|
$this->initialAllowedOperations = TestableAbstractVoter::getAllowedOperations();
|
|
|
$this->initialSwitchHeader = $_SERVER['HTTP_X_SWITCH_USER'] ?? null;
|
|
|
$this->initialRemoteAddr = $_SERVER['REMOTE_ADDR'] ?? null;
|
|
|
$this->initialInternalRequestToken = $_SERVER['HTTP_INTERNAL_REQUESTS_TOKEN'] ?? null;
|
|
|
+ $this->initialConditionSaved = true;
|
|
|
}
|
|
|
|
|
|
- private function reinit() {
|
|
|
+ private function reinitialize() {
|
|
|
// Reinitialize the TestableAbstractVoter static properties
|
|
|
TestableAbstractVoter::setEntityClass($this->initialEntityClass);
|
|
|
TestableAbstractVoter::setAllowedOperations($this->initialAllowedOperations);
|
|
|
@@ -108,6 +107,10 @@ class AbstractVoterTest extends TestCase
|
|
|
}
|
|
|
|
|
|
public function setUp(): void {
|
|
|
+ if (!$this->initialConditionSaved) {
|
|
|
+ $this->saveInitialCondition();
|
|
|
+ }
|
|
|
+
|
|
|
$this->security = $this->getMockBuilder(Security::class)->disableOriginalConstructor()->getMock();
|
|
|
$this->accessUtils = $this->getMockBuilder(Utils::class)->disableOriginalConstructor()->getMock();
|
|
|
$this->internalRequestsService = $this->getMockBuilder(InternalRequestsService::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -117,7 +120,7 @@ class AbstractVoterTest extends TestCase
|
|
|
|
|
|
public function tearDown(): void
|
|
|
{
|
|
|
- $this->reinit();
|
|
|
+ $this->reinitialize();
|
|
|
}
|
|
|
|
|
|
private function makeAbstractVoterMockFor(string $methodName): MockObject | TestableAbstractVoter {
|