Skip to content

Commit db38e5b

Browse files
alongoszadamwojs
authored andcommitted
[Tests] Fixed ConfigurationFactory test cases
* Added missing type hints to: - \Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactoryTestCase - \Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\BinarydataHandler\FlysystemTest - \Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler\FlysystemTest - \Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\BaseFlysystemTestCase * Fixed broken \Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler\FlysystemTest * Improved \Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\BaseFlysystemTestCase
1 parent 80f7170 commit db38e5b

File tree

4 files changed

+27
-35
lines changed

4 files changed

+27
-35
lines changed

tests/bundle/IO/DependencyInjection/ConfigurationFactory/BaseFlysystemTestCase.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory;
910

@@ -13,11 +14,11 @@
1314

1415
abstract class BaseFlysystemTestCase extends ConfigurationFactoryTestCase
1516
{
16-
private $flysystemAdapterServiceId = 'oneup_flysystem.test_adapter';
17+
private string $flysystemAdapterServiceId = 'oneup_flysystem.test_adapter';
1718

1819
private string $filesystemServiceId = 'ibexa.core.io.flysystem.my_test_handler_filesystem';
1920

20-
public function provideHandlerConfiguration()
21+
public function provideHandlerConfiguration(): array
2122
{
2223
$this->setDefinition($this->flysystemAdapterServiceId, new Definition());
2324

@@ -26,15 +27,15 @@ public function provideHandlerConfiguration()
2627
];
2728
}
2829

29-
public function provideParentServiceDefinition()
30+
public function provideParentServiceDefinition(): Definition
3031
{
3132
return new Definition(null, [null]);
3233
}
3334

34-
public function validateConfiguredHandler($handlerDefinitionId)
35+
public function validateConfiguredHandler(string $handlerServiceId): void
3536
{
36-
self::assertContainerBuilderHasServiceDefinitionWithArgument(
37-
$handlerDefinitionId,
37+
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
38+
$handlerServiceId,
3839
0,
3940
new Reference($this->filesystemServiceId)
4041
);

tests/bundle/IO/DependencyInjection/ConfigurationFactory/BinarydataHandler/FlysystemTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\BinarydataHandler;
910

@@ -17,9 +18,6 @@ public function provideTestedFactory(): Flysystem
1718
return new Flysystem();
1819
}
1920

20-
/**
21-
* Returns the expected parent service id.
22-
*/
2321
public function provideExpectedParentServiceId(): string
2422
{
2523
return 'ibexa.core.io.binarydata_handler.flysystem';

tests/bundle/IO/DependencyInjection/ConfigurationFactory/MetadataHandler/FlysystemTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,21 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler;
910

11+
use Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory;
1012
use Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler\Flysystem;
13+
use Ibexa\Tests\Bundle\IO\DependencyInjection\ConfigurationFactory\BaseFlysystemTestCase;
1114

12-
class FlysystemTest
15+
class FlysystemTest extends BaseFlysystemTestCase
1316
{
14-
/**
15-
* Returns an instance of the tested factory.
16-
*
17-
* @return \Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory\MetadataHandler\Flysystem
18-
*/
19-
public function provideTestedFactory()
17+
public function provideTestedFactory(): ConfigurationFactory
2018
{
2119
return new Flysystem();
2220
}
2321

24-
/**
25-
* Returns the expected parent service id.
26-
*/
2722
public function provideExpectedParentServiceId(): string
2823
{
2924
return 'ibexa.core.io.metadata_handler.flysystem';

tests/bundle/IO/DependencyInjection/ConfigurationFactoryTestCase.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Tests\Bundle\IO\DependencyInjection;
910

11+
use Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory;
1012
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractContainerBuilderTestCase;
1113
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
14+
use Symfony\Component\DependencyInjection\Definition;
1215

1316
/**
1417
* Abstract class for testing ConfigurationFactory implementations.
@@ -17,8 +20,7 @@
1720
*/
1821
abstract class ConfigurationFactoryTestCase extends AbstractContainerBuilderTestCase
1922
{
20-
/** @var \Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory */
21-
protected $factory;
23+
protected ConfigurationFactory $factory;
2224

2325
protected function setUp(): void
2426
{
@@ -27,24 +29,24 @@ protected function setUp(): void
2729
$this->factory = $this->provideTestedFactory();
2830
}
2931

30-
public function testGetParentServiceId()
32+
public function testGetParentServiceId(): void
3133
{
3234
self::assertEquals(
3335
$this->provideExpectedParentServiceId(),
3436
$this->factory->getParentServiceId()
3537
);
3638
}
3739

38-
public function testAddConfiguration()
40+
public function testAddConfiguration(): void
3941
{
4042
$node = new ArrayNodeDefinition('handler');
4143
$this->factory->addConfiguration($node);
42-
self::assertInstanceOf(ArrayNodeDefinition::class, $node);
44+
self::assertNotEmpty($node->getChildNodeDefinitions());
4345

4446
// @todo customized testing of configuration node ?
4547
}
4648

47-
public function testConfigureHandler()
49+
public function testConfigureHandler(): void
4850
{
4951
$handlerConfiguration =
5052
$this->provideHandlerConfiguration() +
@@ -60,7 +62,7 @@ public function testConfigureHandler()
6062
/**
6163
* Registers the handler in the container, like the pass would have done.
6264
*/
63-
private function registerHandler($name): string
65+
private function registerHandler(string $name): string
6466
{
6567
$this->setDefinition($this->provideExpectedParentServiceId(), $this->provideParentServiceDefinition());
6668
$handlerServiceId = sprintf('%s.%s', $this->provideExpectedParentServiceId(), $name);
@@ -71,10 +73,8 @@ private function registerHandler($name): string
7173

7274
/**
7375
* Returns an instance of the tested factory.
74-
*
75-
* @return \Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory
7676
*/
77-
abstract public function provideTestedFactory();
77+
abstract public function provideTestedFactory(): ConfigurationFactory;
7878

7979
/**
8080
* Returns the expected parent service id.
@@ -84,20 +84,18 @@ abstract public function provideExpectedParentServiceId();
8484
/**
8585
* Provides the parent service definition, as defined in the bundle's services definition.
8686
* Required so that getArguments / replaceCalls work correctly.
87-
*
88-
* @return \Symfony\Component\DependencyInjection\Definition
8987
*/
90-
abstract public function provideParentServiceDefinition();
88+
abstract public function provideParentServiceDefinition(): Definition;
9189

9290
/**
9391
* Provides the configuration array given to the handler, and initializes the container.
9492
* The name and type index are automatically set to respectively 'my_handler' and 'my_handler_test'.
9593
*
9694
* The method can also configure the container via $this->container.
9795
*
98-
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
96+
* @return array<string, string>
9997
*/
100-
abstract public function provideHandlerConfiguration();
98+
abstract public function provideHandlerConfiguration(): array;
10199

102100
/**
103101
* Lets you test the handler definition after it was configured.
@@ -106,5 +104,5 @@ abstract public function provideHandlerConfiguration();
106104
*
107105
* @param string $handlerServiceId id of the service that was registered by the compiler pass
108106
*/
109-
abstract public function validateConfiguredHandler($handlerServiceId);
107+
abstract public function validateConfiguredHandler(string $handlerServiceId): void;
110108
}

0 commit comments

Comments
 (0)