Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.2"

steps:
- name: "Checkout"
Expand Down
87 changes: 12 additions & 75 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
deps:
- "normal"
Expand All @@ -27,113 +24,53 @@ jobs:
symfony-deprecations-helper:
- ""
include:
# Test against latest Symfony 5.4 stable on 7.4
- symfony-require: "5.4.*"
php-version: "7.4"
deps: "dev"

# Test against latest Symfony 5.4 stable on 7.4 deps normal
- symfony-require: "5.4.*"
php-version: "7.4"
deps: "normal"

# Test against latest Symfony 5.4 stable on 8.0
- symfony-require: "5.4.*"
php-version: "8.0"
deps: "dev"

# Test against latest Symfony 5.4 stable on 8.0 deps normal
- symfony-require: "5.4.*"
php-version: "8.0"
deps: "normal"

# Test against latest Symfony 5.4 stable on 8.1
- symfony-require: "5.4.*"
php-version: "8.1"
deps: "dev"

# Test against latest Symfony 5.4 stable on 8.1 deps normal
- symfony-require: "5.4.*"
php-version: "8.1"
deps: "normal"

# Test against latest Symfony 5.4 stable on 8.2
- symfony-require: "5.4.*"
php-version: "8.2"
deps: "dev"

# Test against latest Symfony 5.4 stable on 8.2 deps normal
- symfony-require: "5.4.*"
php-version: "8.2"
deps: "normal"

# Test against latest Symfony 6.0 stable on 8.0
- symfony-require: "6.0.*"
php-version: "8.0"
deps: "dev"

# Test against latest Symfony 6.0 stable on 8.0 deps normal
- symfony-require: "6.0.*"
php-version: "8.0"
deps: "normal"

# Test against latest Symfony 6.0 stable on 8.1
- symfony-require: "6.0.*"
php-version: "8.1"
deps: "dev"

# Test against latest Symfony 6.0 stable on 8.1 deps normal
- symfony-require: "6.0.*"
php-version: "8.1"
deps: "normal"

# Test against latest Symfony 6.0 stable on 8.2
- symfony-require: "6.0.*"
- symfony-require: "7.0.*"
php-version: "8.2"
deps: "dev"

# Test against latest Symfony 6.0 stable on 8.2 deps normal
- symfony-require: "6.0.*"
- symfony-require: "7.0.*"
php-version: "8.2"
deps: "normal"

# Test against latest Symfony 6.1 stable on 8.1
- symfony-require: "6.1.*"
- symfony-require: "7.1.*"
php-version: "8.1"
deps: "dev"

# Test against latest Symfony 6.1 stable on 8.1 deps normal
- symfony-require: "6.1.*"
- symfony-require: "7.1.*"
php-version: "8.1"
deps: "normal"

# Test against latest Symfony 6.1 stable on 8.2
- symfony-require: "6.1.*"
- symfony-require: "7.1.*"
php-version: "8.2"
deps: "dev"

# Test against latest Symfony 6.1 stable on 8.2 deps normal
- symfony-require: "6.1.*"
- symfony-require: "7.1.*"
php-version: "8.2"
deps: "normal"

# Test against latest Symfony 6.2 stable on 8.1
- symfony-require: "6.2.*"
php-version: "8.1"
- symfony-require: "7.2.*"
php-version: "8.2"
deps: "dev"

# Test against latest Symfony 6.2 stable on 8.1 deps normal
- symfony-require: "6.2.*"
php-version: "8.1"
- symfony-require: "7.2.*"
php-version: "8.2"
deps: "normal"

# Test against latest Symfony 6.2 stable on 8.2
- symfony-require: "6.2.*"
- symfony-require: "7.2.*"
php-version: "8.2"
deps: "dev"

# Test against latest Symfony 6.2 stable on 8.2 deps normal
- symfony-require: "6.2.*"
- symfony-require: "7.2.*"
php-version: "8.2"
deps: "normal"
steps:
Expand Down
10 changes: 7 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Psr\Http\Message\UriFactoryInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Tmdb\Client;
Expand All @@ -20,7 +21,6 @@
use Tmdb\Formatter\Hydration\SimpleHydrationFormatter;
use Tmdb\Formatter\TmdbApiException\SimpleTmdbApiExceptionFormatter;


class Configuration implements ConfigurationInterface
{
/**
Expand All @@ -29,9 +29,13 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('tmdb_symfony');
/** @var ArrayNodeDefinition $rootNode */

$rootNode = $treeBuilder->getRootNode();

if (!$rootNode instanceof ArrayNodeDefinition) {
return $treeBuilder;
}

$this->addRootChildren($rootNode);
$this->addOptionsSection($rootNode);
$this->addLogSection($rootNode);
Expand All @@ -45,7 +49,7 @@ private function addRootChildren(ArrayNodeDefinition $rootNode): void
$rootNode
->beforeNormalization()
->ifTrue(function ($v) {
return isset($v['api_key']) && !empty($v['api_key']);
return !empty($v['api_key']);
})
->then(function ($v) {
$v['options']['api_token'] = $v['api_key'];
Expand Down
55 changes: 23 additions & 32 deletions Tests/DependencyInjection/CompilerPass/ConfigurationPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
use Tmdb\SymfonyBundle\TmdbSymfonyBundle;
use Tmdb\Token\Api\ApiToken;
use Tmdb\Token\Api\BearerToken;
use PHPUnit\Framework\Attributes as PHPUnit;

final class ConfigurationPassTest extends TestCase
{
/**
* @test
* @group DependencyInjection
*/
public function testProcessFullConfiguration()
private const DEPENDENCY_INJECTION_GROUP = 'DependencyInjection';

#[PHPUnit\Group(self::DEPENDENCY_INJECTION_GROUP)]
#[PHPUnit\Test]
public function testProcessFullConfiguration(): void
{
$container = $this->createFullConfiguration();
$this->registerBasicServices($container);
Expand All @@ -33,11 +34,9 @@ public function testProcessFullConfiguration()
$this->doBasicAssertionsBasedOnFullOrMinimalConfig($container);
}

/**
* @test
* @group DependencyInjection
*/
public function testProcessMinimalConfiguration()
#[PHPUnit\Group(self::DEPENDENCY_INJECTION_GROUP)]
#[PHPUnit\Test]
public function testProcessMinimalConfiguration(): void
{
$container = $this->createMinimalConfiguration();
$this->registerBasicServices($container);
Expand All @@ -48,11 +47,9 @@ public function testProcessMinimalConfiguration()
$this->doBasicAssertionsBasedOnFullOrMinimalConfig($container);
}

/**
* @test
* @group DependencyInjection
*/
public function testAutowiring()
#[PHPUnit\Group(self::DEPENDENCY_INJECTION_GROUP)]
#[PHPUnit\Test]
public function testAutowiring(): void
{
$container = new ContainerBuilder();

Expand Down Expand Up @@ -89,11 +86,9 @@ public function testAutowiring()
$this->assertTag($container, get_class($uriFactoryMock), TmdbSymfonyBundle::PSR17_URI_FACTORIES);
}

/**
* @test
* @group DependencyInjection
*/
public function testAutowiringFailsWithUndiscoveredServices()
#[PHPUnit\Group(self::DEPENDENCY_INJECTION_GROUP)]
#[PHPUnit\Test]
public function testAutowiringFailsWithUndiscoveredServices(): void
{
$this->expectException(\RuntimeException::class);
$container = new ContainerBuilder();
Expand All @@ -106,11 +101,9 @@ public function testAutowiringFailsWithUndiscoveredServices()
$pass->process($container);
}

/**
* @test
* @group DependencyInjection
*/
public function testAutowiringFailsWithSeveralDiscoveredServices()
#[PHPUnit\Group(self::DEPENDENCY_INJECTION_GROUP)]
#[PHPUnit\Test]
public function testAutowiringFailsWithSeveralDiscoveredServices(): void
{
$this->expectException(\RuntimeException::class);

Expand All @@ -131,11 +124,9 @@ public function testAutowiringFailsWithSeveralDiscoveredServices()
$pass->process($container);
}

/**
* @test
* @group DependencyInjection
*/
public function testProcessBearerToken()
#[PHPUnit\Group(self::DEPENDENCY_INJECTION_GROUP)]
#[PHPUnit\Test]
public function testProcessBearerToken(): void
{
$config = $this->getFullConfig();
$config['options']['bearer_token'] = 'bearer_token';
Expand All @@ -146,7 +137,7 @@ public function testProcessBearerToken()
$pass = new ConfigurationPass();
$pass->process($container);

$this->assertEquals(
$this->assertSame(
BearerToken::class,
$container->getDefinition('Tmdb\SymfonyBundle\ClientConfiguration')->getArgument(0)->__toString()
);
Expand Down Expand Up @@ -189,7 +180,7 @@ protected function assertClientConfigurationEquals(
string $expectedServiceId,
int $argument
) {
$this->assertEquals(
$this->assertSame(
$expectedServiceId,
$container->getDefinition('Tmdb\SymfonyBundle\ClientConfiguration')->getArgument($argument)->__toString()
);
Expand Down
Loading