AssetManagerTest\Service\AssetCacheManagerTest::testGetProviderWithCacheOptions PHP Method

testGetProviderWithCacheOptions() public method

    public function testGetProviderWithCacheOptions()
    {
        $serviceManager = new ServiceManager();
        $config = array('my_provided_class.tmp' => array('cache' => FilePathCache::class, 'options' => array('dir' => 'somewhere')));
        $serviceManager->setFactory('myZf2Service', function () {
            return new FilePathCache('somewhere', 'somfile');
        });
        $assetManager = new AssetCacheManager($serviceManager, $config);
        $reflectionMethod = new \ReflectionMethod(AssetCacheManager::class, 'getProvider');
        $reflectionMethod->setAccessible(true);
        /** @var FilePathCache $provider */
        $provider = $reflectionMethod->invoke($assetManager, 'my_provided_class.tmp');
        $this->assertTrue($provider instanceof FilePathCache);
        $reflectionProperty = new \ReflectionProperty(FilePathCache::class, 'dir');
        $reflectionProperty->setAccessible(true);
        $this->assertTrue($reflectionProperty->getValue($provider) == 'somewhere');
    }