-
- Notifications
You must be signed in to change notification settings - Fork 5.3k
[WIP] Added Test documentation for third party bundles #5232
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
Conversation
cookbook/bundles/tests.md Outdated
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.
og
-> of
You will have to add a reference to the new document in |
cookbook/bundles/tests.md Outdated
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.
an console
=> a console
Took @javiereguiluz, @xabbuh and @pyrech feedback into account: * Fixed RST (use of double back quote) * Fixed typos * Removed use of first person * Indexed article in cookbook/map.rst.inc
Thanks @javiereguiluz, @xabbuh and @pyrech for all your feedbacks. I've taken them into account in a separate commit to make it easier to spot the diff. |
As you're writing reStructured text and not markdown, the extension has to be |
cookbook/bundles/tests.md Outdated
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.
"Writing Tests for Third Party Bundles" (we follow the "capitialize all words, except from closed-class words" title case standard)
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.
this relies on the next section to create the console, so it look weird
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.
I'm not sure how to improve this part: should I remove it, or move it around? I could use some advice here :)
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.
I propose to convert this to a simple sidebar and adding it after the Running Commands section. Like:
.. sidebar:: Visiting Pages in the Browser As you can run commands now, it is possible to run the internal webserver to visit the pages in a browser. In order to do this, you have to add a minimal front controller (just like the one that can be found in the Symfony Standard Edition:: // Tests/Functional/app/web.php use Symfony\Component\HttpFoundation\Request; require_once __DIR__.'/autoload.php'; $kernel = new AppKernel('prod', false); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); Now, you can execute the ``server:run`` comand: .. code-block:: bash $ php Tests/Functional/app/console.php server:run -d Tests/app
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, I propose to rename web.php
to app_test.php
and then use php Tests/Functional/app/console.php server:run --env=test -d Tests/Functional/app
. This way, everything works as expected
Might be also good to show how to test some elements of the dependency injection like compilers, extension and configuration: Exemple in DunglasApiBundle:
Another one with HautelookAliceBundle
|
@theofidry I'll add those links to the section discussed here: #5232 (comment) |
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.
We usually have a little introduction paragraph at the start of the article, instead of starting with the text directly. What about adding such a paragraph here as well? For instance:
When creating a shared bundle, you need to verify if the bundle works as it should. The best practice is to write automatic functional tests. This article will guide you through setting up and running such tests.
@gnugat I've decorated this article with comments again, sorry for that... I don't think they are very hard to fix, but if you don't want to fix them, feel free to just say it and we'll take it from here. The article looks like a really nice getting started guide. Some sections are duplicate with |
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.
I'd remove this block - it's a bit of a maintenance problem. Instead, just describe how you could create a kernel and a "fake" request in order to test your bundle.
At this point, I don't think this should be included in the docs. We have too much to maintain, so we need to focus our efforts on core things needed by users. This doesn't make this a bad article at all (though the PR has stalled) - I'd rather existing bundles serve as the best resource for learning how to test your reusable bundle. Cheers! |
As discussed in #4503, I've started to rewrite an article I've published about writing tests in third party bundles.
At this stage this PR should be considered as a Work In Progress as I'm not sure if it contains too much information (tests for third party bundles could be the subject of a whole section), not enough examples, or if it's simply irrelevant.
I'd be more than happy to take any feedback :) .