8000 [TwigBundle] do not mock the container builder or definitions by xabbuh · Pull Request #26078 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBundle] do not mock the container builder or definitions #26078

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 1 commit into from
Feb 8, 2018

Conversation

xabbuh
Copy link
Member
@xabbuh xabbuh commented Feb 7, 2018
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

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

more of this please :)

@fancyweb
Copy link
Contributor
fancyweb commented Feb 7, 2018

Hey, I am the person who wrote this test yesterday.
I unfortunately don't know much about testing so I did it by looking to this other test of the TwigBundle https://github.com/symfony/symfony/blob/39e88ed3128933d7540eadd847d5650c8b52f5ba/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php
For my personal knowledge, can someone explain me why this is better to not use mocking in this scenario please ? :-) Thank you.

@fabpot
Copy link
Member
fabpot commented Feb 8, 2018

Thank you @xabbuh.

@fabpot fabpot merged commit 8bba882 into symfony:3.4 Feb 8, 2018
fabpot added a commit that referenced this pull request Feb 8, 2018
…tions (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBundle] do not mock the container builder or definitions

| 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        |

Commits
-------

8bba882 do not mock the container builder or definitions
@greg0ire
Copy link
Contributor
greg0ire commented Feb 8, 2018

Several reasons:

  1. less code => easier to maintain
  2. the test should test the outcome, not how it is achieved, it should have no knowledge of the SUT's internals
  3. if what you are mocking comes from another package, you want to catch any deprecations, and you mock the internals as they are at one point in time, but they may change without it being considered a BC-break => "don't mock what you don't own"

@xabbuh xabbuh deleted the pr-25756 branch February 8, 2018 18:05
@xabbuh
Copy link
Member Author
xabbuh commented Feb 8, 2018

@fancyweb Sorry that I only created a PR after yours was merged, but I sadly didn't manage to review it before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0