Skip to content

Commit

Permalink
Reduce SessionStrategyManager memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Mar 13, 2024
1 parent 24c344c commit efd9e1d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions library/aik099/PHPUnit/Session/SessionStrategyManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class SessionStrategyManager
protected $lastUsedSessionStrategyHash;

/**
* Session strategy, that was requested in browser configuration.
* Session strategy, that was last requested in the browser configuration.
*
* @var ISessionStrategy[]
* @var ISessionStrategy
*/
protected $sessionStrategiesInUse = array();
protected $lastUsedSessionStrategy;

/**
* Session strategy, that will be used by default.
Expand Down Expand Up @@ -94,15 +94,14 @@ public function getSessionStrategy(BrowserConfiguration $browser, BrowserTestCas
$strategy_type = $browser->getSessionStrategy();
$strategy_hash = $browser->getSessionStrategyHash($test_case);

if ( $strategy_hash !== $this->lastUsedSessionStrategyHash ) {
$this->sessionStrategiesInUse[$strategy_hash] = $this->_sessionStrategyFactory->createStrategy(
$strategy_type
);
if ( $strategy_hash === $this->lastUsedSessionStrategyHash ) {
return $this->lastUsedSessionStrategy;
}

$this->lastUsedSessionStrategy = $this->_sessionStrategyFactory->createStrategy($strategy_type);
$this->lastUsedSessionStrategyHash = $strategy_hash;

return $this->sessionStrategiesInUse[$strategy_hash];
return $this->lastUsedSessionStrategy;
}

}

0 comments on commit efd9e1d

Please sign in to comment.