ConfigReader example

Feature::resetRegisteredFeatures();
        Feature::registerFeatures($this->featureConfigBackup);
    }

    public function testInvalidDomain(): void
    {
        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessage('Expected domain');

        $configService = new ConfigurationService(
            [],
            new ConfigReader(),
            $this->createMock(AppLoader::class),
            new StaticEntityRepository([]),
            new StaticSystemConfigService([])
        );

        static::assertFalse($configService->checkConfiguration('invalid!', Context::createDefaultContext()));

        $configService->getConfiguration('invalid!', Context::createDefaultContext());
    }

    public function testMissingConfig(): void
    {
parent::tearDown();

        // @phpstan-ignore-next-line         InstalledVersions::reload($this->packages);
    }

    public function testGetConfigWhenNotExists(): void
    {
        $appLoader = new AppLoader(
            __DIR__,
            __DIR__,
            new ConfigReader()
        );

        $appEntity = new AppEntity();
        $appEntity->setPath('non-existing');

        static::assertNull($appLoader->getConfiguration($appEntity));
    }

    public function testGetConfig(): void
    {
        $appLoader = new AppLoader(
            
static::assertSame(trim($expectedCssOutput)trim((string) $actual));
    }

    /** * @param array<int, Plugin> $plugins */
    private function getConfigurationService(array $plugins): ConfigurationService
    {
        return new ConfigurationService(
            $plugins,
            new ConfigReader(),
            $this->getContainer()->get(AppLoader::class),
            $this->getContainer()->get('app.repository'),
            $this->getContainer()->get(SystemConfigService::class)
        );
    }

    /** * @param array<int, Plugin> $plugins */
    private function getConfigurationServiceDbException(array $plugins): ConfigurationService
    {
        

#[Package('system-settings')] class ConfigReaderTest extends TestCase
{
    private ConfigReader $configReader;

    protected function setUp(): void
    {
        $this->configReader = new ConfigReader();
    }

    public function testConfigReaderWithValidConfig(): void
    {
        $actualConfig = $this->configReader->read(__DIR__ . '/_fixtures/valid_config.xml');

        static::assertSame($this->getExpectedConfig()$actualConfig);
    }

    public function testConfigReaderWithInvalidPath(): void
    {
        
            // phpunit.xml.dist sets app.baseURL in $_SERVER             // So if you set app.baseURL in .env, it takes precedence             $config = new App();
            $this->assertTrue(
                $validation->check($config->baseURL, 'valid_url'),
                'baseURL "' . $config->baseURL . '" in .env is not valid URL'
            );
        }

        // Get the baseURL in app/Config/App.php         // You can't use Config\App, because phpunit.xml.dist sets app.baseURL         $reader = new ConfigReader();

        // BaseURL in app/Config/App.php is a valid URL?         $this->assertTrue(
            $validation->check($reader->baseURL, 'valid_url'),
            'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL'
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.