Skip to content
Merged
Prev Previous commit
Next Next commit
fix test cache factory
  • Loading branch information
rodriquelca committed Dec 6, 2024
commit 5d76ff0939c0648a7310f6bd1f90119e7cdecd59
18 changes: 10 additions & 8 deletions tests/unit/ProcessMaker/Cache/Screens/ScreenCacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use ProcessMaker\Cache\Monitoring\RedisMetricsManager;
use ProcessMaker\Cache\Screens\LegacyScreenCacheAdapter;
use ProcessMaker\Cache\Screens\ScreenCacheFactory;
use ProcessMaker\Cache\Screens\ScreenCacheInterface;
use ProcessMaker\Cache\Screens\ScreenCacheManager;
use ProcessMaker\Managers\ScreenCompiledManager;
use Tests\TestCase;
Expand Down Expand Up @@ -184,16 +185,17 @@ public function testGetScreenCacheReturnsSameInstanceAsCreate()
*/
public function testFactoryRespectsTestInstance()
{
// Create and set a test instance
$testInstance = $this->createMock(ScreenCacheInterface::class);
ScreenCacheFactory::setTestInstance($testInstance);
// Create a mock for ScreenCacheInterface
$mockInterface = $this->createMock(ScreenCacheInterface::class);

// Both create and getScreenCache should return test instance
$this->assertSame($testInstance, ScreenCacheFactory::create());
$this->assertSame($testInstance, ScreenCacheFactory::getScreenCache());
// Set the test instance in the factory
ScreenCacheFactory::setTestInstance($mockInterface);

// Clear test instance
ScreenCacheFactory::setTestInstance(null);
// Retrieve the instance from the factory
$instance = ScreenCacheFactory::create();

// Assert that the instance is the mock we set
$this->assertSame($mockInterface, $instance);
}

/**
Expand Down