Skip to content

Commit

Permalink
NGSTACK-816 add tests for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
petarjakopec committed Aug 21, 2024
1 parent e7be506 commit 41ae780
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@
},
"require-dev": {
"netgen/ibexa-site-api": "^6.1",
"ibexa/graphql": "^4.5"
"ibexa/graphql": "^4.5",
"phpunit/phpunit": "^10",
"matthiasnoback/symfony-dependency-injection-test": "^4.1"
},
"autoload": {
"psr-4": {
"Netgen\\Bundle\\IbexaAdminUIExtraBundle\\": "bundle"
}
},
"autoload-dev": {
"psr-4": {
"Netgen\\IbexaAdminUIExtra\\Tests\\": "tests/bundle"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"config": {
"allow-plugins": false
},
"scripts": {
"test": "@php vendor/bin/phpunit --colors=always"
}
}
8 changes: 8 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Dependency injection unit tests">
<directory suffix="Test.php">./tests/bundle/DependencyInjection</directory>
</testsuite>
</testsuites>
</phpunit>
83 changes: 83 additions & 0 deletions tests/bundle/DependencyInjection/NetgenIbexaAdminUIExtraTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

declare(strict_types=1);

namespace Netgen\IbexaAdminUIExtra\Tests\DependencyInjection;

use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use Netgen\Bundle\IbexaAdminUIExtraBundle\DependencyInjection\NetgenIbexaAdminUIExtraExtension;

final class NetgenIbexaAdminUIExtraTest extends AbstractExtensionTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->setParameter('kernel.bundles', []);
}

public static function provideDefaultConfigurationCases(): iterable
{
return [
[
[],
],
[
[
'show_external_siteaccess_urls' => false,
],
],
];
}

public static function provideShowExternalSiteaccessUrlsConfigurationCases(): iterable
{
return [
[
[
'show_external_siteaccess_urls' => false,
],
false,
],
[
[
'show_external_siteaccess_urls' => true,
],
true,
],
];
}

/**
* @dataProvider provideDefaultConfigurationCases
*/
public function testDefaultConfiguration(array $configuration): void
{
$this->load($configuration);

$this->assertContainerBuilderHasParameter(
'netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls',
false,
);
}

/**
* @dataProvider provideShowExternalSiteaccessUrlsConfigurationCases
*/
public function testShowExternalSiteaccessUrlsConfiguration(array $configuration, bool $expectedParameterValue): void
{
$this->load($configuration);

$this->assertContainerBuilderHasParameter(
'netgen_ibexa_admin_ui_extra.show_external_siteaccess_urls',
$expectedParameterValue,
);
}

protected function getContainerExtensions(): array
{
return [
new NetgenIbexaAdminUIExtraExtension(),
];
}
}

0 comments on commit 41ae780

Please sign in to comment.