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

[FrameworkBundle] Allow fetching private services from test clients#26499

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

Merged

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedMar 12, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#25814
LicenseMIT
Doc PR-

With this PR,$client->getContainer() returns a special container that gives access to private services as if they were public.

Tests derived fromWebTestCase andKernelTestCase can access this special container by using the newstatic::$container property.

nesl247, theofidry, dmaicher, bashkarev, michaelzangerle, linaori, jorge07, fracz, manuelkiessling, arnaudgoulpeau, and 7 more reacted with thumbs up emojijorge07, sstok, manuelkiessling, thePanz, and tcitworld reacted with hooray emojitheofidry, bashkarev, hhamon, sstok, manuelkiessling, thePanz, fracz, tcitworld, and ragboyjr reacted with heart emoji
*/
public function compile()
{
return $this->publicContainer->isCompiled();
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo?$this->publicContainer->compile();

@jakzal
Copy link
Contributor

jakzal commentedMar 12, 2018
edited
Loading

Looks promising! The only issue I see is that it currently requires theClient, while a common use case is to extend theKernelTestCase and fetch the container from kernel.

Edit: I guess in such scenario we can still do$container->get('test.service_container')->get('my_private_service')

@ogizanagi
Copy link
Contributor

In my experience, this would be useful for anyKernelTestCase, not onlyWebTestCase. So should the service be public and a getter provided inKernelTestCase?

@nicolas-grekas
Copy link
MemberAuthor

In my experience, this would be useful for any KernelTestCase

OK, what about the new patch?

sstok reacted with heart emoji

@ogizanagi
Copy link
Contributor

Better :)

@nicolas-grekasnicolas-grekasforce-pushed thetest-container branch 4 times, most recently from626b6ad tod5c7c60CompareMarch 13, 2018 11:03
@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedMar 13, 2018
edited
Loading

PR ready. Unused private services are still removed. This is a requirement because not all private services are valid. Since they are removed, this is not an issue but a feature. Keeping a reference to all private services would be a BC break (as experienced on the test suite before handling this.)

@nicolas-grekasnicolas-grekas merged commita840809 intosymfony:masterMar 16, 2018
nicolas-grekas added a commit that referenced this pull requestMar 16, 2018
… test clients (nicolas-grekas)This PR was merged into the 4.1-dev branch.Discussion----------[FrameworkBundle] Allow fetching private services from test clients| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#25814| License       | MIT| Doc PR        | -With this PR, `$client->getContainer()` returns a special container that gives access to private services as if they were public.Tests derived from `WebTestCase` and `KernelTestCase` can access this special container by using the new `static::$container` property.Commits-------a840809 [FrameworkBundle] Allow fetching private services from test clients
@nicolas-grekasnicolas-grekas deleted the test-container branchMarch 16, 2018 09:52
@kniziol
Copy link

@nicolas-grekas It will be available in 3.4 version?

@nicolas-grekas
Copy link
MemberAuthor

that's a new feature, so for 4.1

@umpirsky
Copy link
Contributor

So, actual code that's being tested will still use regular container that cannot access private services, right?

@nicolas-grekas
Copy link
MemberAuthor

@umpirski right.

umpirsky and aivus reacted with thumbs up emoji

curry684 added a commit to snc/SncRedisBundle that referenced this pull requestApr 10, 2018
Sincesymfony/symfony#26499 will not be partof Symfony 3.4 regrettably.
@fabpotfabpot mentioned this pull requestMay 7, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas approved these changes

+2 more reviewers

@jakzaljakzaljakzal left review comments

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

7 participants

@nicolas-grekas@jakzal@ogizanagi@kniziol@umpirsky@dunglas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp