Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8596b19

Browse filesBrowse files
minor #22398 Enhancing integration test to show that "override" tags show up first (weaverryan)
This PR was merged into the 3.3-dev branch. Discussion ---------- Enhancing integration test to show that "override" tags show up first | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | not needed Relates a bit to #22396, in that I'm clarifying and emphasizing the following types of situations: ```yml services: _instanceof: Symfony\Component\Security\Core\Authorization\Voter\VoterInterface: tags: # you probably shouldn't set priority here, but let's pretend we did - { name: security.voter, priority: 100 } AppBundle\Security\CoolPersonVoter: tags: - { name: security.voter, priority: 50 } ``` In the final `Definition`, the tags will appear in this order: * security.voter, priority 50 * security.voter, priority 100 It works the same for parent-child definitions. tl;dr; If a service has the same tag multiple times, the one that should be used should appear *earlier* in the Definition. The code already works that way - this test emphasizes it. Commits ------- e9b96e5 Enhancing integration test to show that "override" tags always show up first
2 parents 8e4e741 + e9b96e5 commit 8596b19
Copy full SHA for 8596b19

File tree

Expand file treeCollapse file tree

2 files changed

+11
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-6
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function testInstanceofDefaultsAndParentDefinitionResolution()
135135
// all tags are kept
136136
$this->assertEquals(
137137
array(
138-
'foo_tag' => array(array('priority' => 100), array()),
138+
'foo_tag' => array(array('tag_option' => 'from_service'), array('tag_option' => 'from_instanceof')),
139139
'bar_tag' => array(array()),
140140
),
141141
$simpleService->getTags()
@@ -169,10 +169,10 @@ public function testInstanceofDefaultsAndParentDefinitionResolution()
169169
// tags inherit like normal
170170
$this->assertEquals(
171171
array(
172-
'foo_tag' => array(array('priority' => 100), array()),
172+
'foo_tag' => array(array('tag_option' => 'from_child_def'), array('tag_option' => 'from_parent_def'), array('tag_option' => 'from_instanceof')),
173173
'bar_tag' => array(array()),
174174
),
175-
$simpleService->getTags()
175+
$childDef2->getTags()
176176
);
177177
}
178178
}

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_defaults_instanceof_parent.yml

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_defaults_instanceof_parent.yml
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
autowire: false
99
shared: false
1010
tags:
11-
- { name: foo_tag }
11+
- { name: foo_tag, tag_option: from_instanceof }
1212
calls:
1313
- [setSunshine, [bright]]
1414

@@ -20,8 +20,8 @@ services:
2020
service_simple:
2121
class: Symfony\Component\DependencyInjection\Tests\Compiler\IntegrationTestStub
2222
tags:
23-
- { name: foo_tag, priority: 100 }
24-
# calls from instanceof are kept, but this comes later
23+
- { name: foo_tag, tag_option: from_service }
24+
# calls from instanceof are kept, but this comes later
2525
calls:
2626
- [enableSummer, [true]]
2727
- [setSunshine, [warm]]
@@ -43,7 +43,12 @@ services:
4343
parent_service_with_class:
4444
abstract: true
4545
class: Symfony\Component\DependencyInjection\Tests\Compiler\IntegrationTestStub
46+
tags:
47+
- { name: foo_tag, tag_option: from_parent_def }
4648

4749
child_service_with_parent_instanceof:
4850
parent: parent_service_with_class
4951
shared: true
52+
inherit_tags: true
53+
tags:
54+
- { name: foo_tag, tag_option: from_child_def }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.