Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[DI] Add tests for EnvVarProcessor#26542

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mcfedr wants to merge2 commits intosymfony:3.4frommcfedr:env_var_processor_tests

Conversation

@mcfedr
Copy link
Contributor

QA
Branch?3.4
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PRn/a

Add tests for theEnvVarProcessor as it doesn't have any at the moment.

Originally from this PR against master,#26498

$processor = new EnvVarProcessor($container);

$result = $processor->getEnv('string', 'foo', function () {
throw new LogicException('Shouldnt be called');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Minor typo:Shouldnt ->Shouldn\'t orShould not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't we use$this->fail() instead?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yep, I couldn't remember what the function was called, I knew it existed

return '1';
});

$this->assertTrue($result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just asking:assertTrue() accepts as true anything that PHP considers true ... or does it a stricttrue === ... comparison? We're getting a bool value here, so we need to be sure that a boolean is returned.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

use Symfony\Component\DependencyInjection\EnvVarProcessor;
use Symfony\Component\DependencyInjection\Exception\LogicException;

class EnvVarProcessorTest extends TestCase

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just asking: should we add a data provider with some edge cases to better test this feature? Empty strings, null values, zeros, etc. Thanks!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agree completely, updated with far more examples for each case

Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Forbase64 andjson, I'd suggest to add test cases with badly encoded strings.

$processor = new EnvVarProcessor($container);

$result = $processor->getEnv('string', 'foo', function () {
throw new LogicException('Shouldnt be called');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't we use$this->fail() instead?

$processor->getEnv('const', 'foo', function ($name) {
$this->assertSame('foo', $name);

return 'Symfony\Component\DependencyInjection\Tests\EnvVarProcessorTest::TEST_CONST_OTHER';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd suggest to use a name here that tells the reader that you've been using an undefined constant by design here, e.g.TEST_CONST_INVALID orTEST_CONST_UNDEFINED.

@mcfedrmcfedrforce-pushed theenv_var_processor_tests branch froma907f07 to90bc19fCompareMarch 16, 2018 13:13
@mcfedr
Copy link
ContributorAuthor

@derrabus Checking for badly encoded base64 is an option, but actually the currentEnvVarProcessor just ignores bad base64, and this would be a breaking change, I have pushed a commit (90bc19f) that checks this, but as it would be break backwards compatibility, its probably not a good idea.

@mcfedrmcfedrforce-pushed theenv_var_processor_tests branch from90bc19f to532c579CompareMarch 16, 2018 13:16
array(1),
array(1.1),
array(true),
array(false),
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I left outnull as it would conflict with my other PR,#26498

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Or should I better include it here and update in second PR assuming this gets merged first?

@derrabus
Copy link
Member

@mcfedr I wasn't aware of the current behavior of the base64 decoder. I agree that this PR should not change the behavior. We could tackle this with a later PR, maybe.

@mcfedr
Copy link
ContributorAuthor

@derrabus I guess its one of PHPs fun features, where its just trying to be helpful...

derrabus reacted with laugh emoji

@mcfedrmcfedrforce-pushed theenv_var_processor_tests branch from532c579 to8e735b7CompareMarch 19, 2018 10:41
@nicolas-grekasnicolas-grekas changed the titleAdd tests for EnvVarProcessor[DI] Add tests for EnvVarProcessorMar 19, 2018
@nicolas-grekas
Copy link
Member

Thank you@mcfedr.

nicolas-grekas added a commit that referenced this pull requestMar 19, 2018
This PR was squashed before being merged into the 3.4 branch (closes#26542).Discussion----------[DI] Add tests for EnvVarProcessor| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        | n/aAdd tests for the `EnvVarProcessor` as it doesn't have any at the moment.Originally from this PR against master,#26498Commits-------2992bb3 [DI] Add tests for EnvVarProcessor
@mcfedrmcfedr deleted the env_var_processor_tests branchMarch 19, 2018 15:05
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@derrabusderrabusderrabus approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

5 participants

@mcfedr@derrabus@nicolas-grekas@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp