Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b11cb5b

Browse files
committed
Move tests to IntegrationTest
1 parent 27e40b8 commit b11cb5b

File tree

5 files changed

+61
-36
lines changed

5 files changed

+61
-36
lines changed

src/Symfony/Component/DependencyInjection/Tests/Compiler/AttributeAutoconfigurationPassTest.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,39 +45,4 @@ public function testAttributeConfiguratorCallableMissingType()
4545
$this->expectExceptionMessage('Argument "$reflector" of attribute autoconfigurator should have a type, use one or more of "\ReflectionClass|\ReflectionMethod|\ReflectionProperty|\ReflectionParameter|\Reflector" in ');
4646
(new AttributeAutoconfigurationPass())->process($container);
4747
}
48-
49-
public function testCallNearestParentConfigurator()
50-
{
51-
$calls = [];
52-
$container = new ContainerBuilder();
53-
$container->registerAttributeForAutoconfiguration(AsTaggedItem::class, function (ChildDefinition $definition, AsTaggedItem $attribute, \ReflectionClass $reflector) use (&$calls) {
54-
$calls[] = $attribute;
55-
});
56-
$container->register('foo', ServiceTaggedWithFooIndex::class)
57-
->setAutoconfigured(true)
58-
;
59-
60-
(new AttributeAutoconfigurationPass())->process($container);
61-
62-
$this->assertSame([], $container->getDefinition('foo')->getInstanceofConditionals());
63-
$this->assertCount(1, $calls);
64-
}
65-
}
66-
67-
#[\Attribute(\Attribute::TARGET_CLASS)]
68-
class AsTaggedItemWithFooIndex extends AsTaggedItem
69-
{
70-
public function __construct(
71-
?int $priority = null,
72-
) {
73-
parent::__construct(
74-
index: 'foo',
75-
priority: $priority
76-
);
77-
}
78-
}
79-
80-
#[AsTaggedItemWithFooIndex]
81-
class ServiceTaggedWithFooIndex
82-
{
8348
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
use Symfony\Component\DependencyInjection\Tests\Fixtures\TaggedService3;
5858
use Symfony\Component\DependencyInjection\Tests\Fixtures\TaggedService3Configurator;
5959
use Symfony\Component\DependencyInjection\Tests\Fixtures\TaggedService4;
60+
use Symfony\Component\DependencyInjection\Tests\Fixtures\TaggedService5;
6061
use Symfony\Contracts\Service\Attribute\SubscribedService;
6162
use Symfony\Contracts\Service\ServiceProviderInterface;
6263
use Symfony\Contracts\Service\ServiceSubscriberInterface;
@@ -993,6 +994,10 @@ static function (ChildDefinition $definition, CustomAnyAttribute $attribute, \Re
993994
->setPublic(true)
994995
->setAutoconfigured(true);
995996

997+
$container->register(TaggedService5::class)
998+
->setPublic(true)
999+
->setAutoconfigured(true);
1000+
9961001
$container->register('failing_factory', \stdClass::class);
9971002
$container->register('ccc', TaggedService4::class)
9981003
->setFactory([new Reference('failing_factory'), 'create'])
@@ -1018,6 +1023,12 @@ static function (ChildDefinition $definition, CustomAnyAttribute $attribute, \Re
10181023
['property' => 'name'],
10191024
['someAttribute' => 'on name', 'priority' => 0, 'property' => 'name'],
10201025
],
1026+
TaggedService5::class => [
1027+
['class' => TaggedService5::class],
1028+
['parameter' => 'param1'],
1029+
['method' => 'fooAction'],
1030+
['property' => 'name'],
1031+
],
10211032
'ccc' => [
10221033
['class' => TaggedService4::class],
10231034
['method' => 'fooAction'],

src/Symfony/Component/DependencyInjection/Tests/Fixtures/Attribute/CustomAnyAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Attribute;
1313

1414
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_PARAMETER)]
15-
final class CustomAnyAttribute
15+
class CustomAnyAttribute
1616
{
1717
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Attribute;
13+
14+
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_PARAMETER)]
15+
class CustomChildAttribute extends CustomAnyAttribute
16+
{
17+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
13+
14+
use Symfony\Component\DependencyInjection\Tests\Fixtures\Attribute\CustomChildAttribute;
15+
16+
#[CustomChildAttribute]
17+
final class TaggedService5
18+
{
19+
#[CustomChildAttribute]
20+
public string $name;
21+
22+
public function __construct(
23+
#[CustomChildAttribute]
24+
private string $param1,
25+
) {}
26+
27+
#[CustomChildAttribute]
28+
public function fooAction(
29+
#[CustomChildAttribute]
30+
string $param1
31+
) {}
32+
}

0 commit comments

Comments
 (0)