-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI][DX] Do not map id to class for global classes #21453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[DI][DX] Do not map id to class for global classes
- Loading branch information
commit bb870304f098a6b12ebe376e4cd71e2df5868747
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional
10000
Unicode characters
60 changes: 60 additions & 0 deletions
60
src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\DependencyInjection\Tests\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\ResolveClassPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass; | ||
|
||
class ResolveClassPassTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider provideValidClassId | ||
*/ | ||
public function testResolveClassFromId($serviceId) | ||
{ | ||
$pass = new ResolveClassPass(); | ||
$container = new ContainerBuilder(); | ||
$def = $container->register($serviceId); | ||
|
||
$pass->process($container); | ||
|
||
$this->assertSame($serviceId, $def->getClass()); | ||
} | ||
|
||
public function provideValidClassId() | ||
{ | ||
yield array('Acme\UnknownClass'); | ||
yield array(CaseSensitiveClass::class); | ||
} | ||
|
||
/** | ||
* @dataProvider provideInvalidClassId | ||
*/ | ||
public function testWontResolveClassFromId($serviceId) | ||
{ | ||
$pass = new ResolveClassPass(); | ||
$container = new ContainerBuilder(); | ||
$def = $container->register($serviceId); | ||
|
||
$pass->process($container); | ||
|
||
$this->assertNull($def->getClass()); | ||
} | ||
|
||
public function provideInvalidClassId() | ||
{ | ||
yield array(\stdClass::class); | ||
yield array('bar'); | ||
yield array('\DateTime'); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ services: | |
|
||
with_defaults_aliased_short: '@with_defaults' | ||
|
||
with_shortcut_args: [foo] | ||
Acme\WithShortCutArgs: [foo] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it a Symfony convention to put the providers before the test method? (I personally tend to put them all as the last ones)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the Symfyon "convention" is to put the provider just after the test using it.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a personal preference. I prefer showing the dataset before the testcase itself, as I find it more readable like this (the test case might be long, so having the dataset right before the method allows to quickly see the tested data, whereas having it after the method may not fit your screen). It's totally arguable.
Should I change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is Symfony code, there is personal preference, but consistency with the code base. So, I would indeed change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough :)
Done.