-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Updated testing/* articles to Symfony 4 #8705
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,22 +158,26 @@ As an example, a test could look like this:: | |
|
||
.. tip:: | ||
|
||
To run your functional tests, the ``WebTestCase`` class bootstraps the | ||
kernel of your application. In most cases, this happens automatically. | ||
However, if your kernel is in a non-standard directory, you'll need | ||
to modify your ``phpunit.xml.dist`` file to set the ``KERNEL_DIR`` | ||
environment variable to the directory of your kernel: | ||
To run your functional tests, the ``WebTestCase`` class needs to know which | ||
is the application kernel to bootstrap it. The kernel class is usually | ||
defined in the ``KERNEL_CLASS`` environment variable (included in the | ||
default ``phpunit .xml-dist`` file provided by Symfony): | ||
|
||
.. code-block:: xml | ||
|
||
<?xml version="1.0" charset="utf-8" ?> | ||
<phpunit> | ||
<php> | ||
<server name="KERNEL_DIR" value="/path/to/your/app/" /> | ||
<!-- the value is the FQCN of the application kernel --> | ||
<server name="KERNEL_CLASS" value="App\Kernel" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now should be |
||
</php> | ||
<!-- ... --> | ||
</phpunit> | ||
|
||
If your use case is more complex, you can also override the | ||
``createKernel()`` or ``getKernelClass()`` methods of your functional test, | ||
which take precedence over the ``KERNEL_CLASS`` env var. | ||
|
||
The ``createClient()`` method returns a client, which is like a browser that | ||
you'll use to crawl your site:: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,44 +113,32 @@ not to overwrite data you entered when developing the application and also | |
to be able to clear the database before every test. | ||
|
||
To do this, you can specify a database configuration which overwrites the default | ||
configuration: | ||
configuration just in the ``test`` environment: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config/config_test.yml | ||
# config/packages/test/doctrine.yaml | ||
doctrine: | ||
# ... | ||
dbal: | ||
host: localhost | ||
dbname: testdb | ||
user: testdb | ||
password: testdb | ||
url: 'mysql://USERNAME:PASSWORD@127.0.0.1/DB_NAME?charset=utf8mb4&serverVersion=5.7' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As Doctrine configuration has defined an environment variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much better. Thanks! |
||
|
||
.. code-block:: xml | ||
|
||
<!-- app/config/config_test.xml --> | ||
<!-- config/packages/test/doctrine.xml --> | ||
<doctrine:config> | ||
<doctrine:dbal | ||
host="localhost" | ||
dbname="testdb" | ||
user="testdb" | ||
password="testdb" | ||
url="mysql://USERNAME:PASSWORD@127.0.0.1/DB_NAME?charset=utf8mb4&serverVersion=5.7" | ||
/> | ||
</doctrine:config> | ||
|
||
.. code-block:: php | ||
|
||
// app/config/config_test.php | ||
// config/packages/test/doctrine.php | ||
$container->loadFromExtension('doctrine', array( | ||
'dbal' => array( | ||
'host' => 'localhost', | ||
'dbname' => 'testdb', | ||
'user' => 'testdb', | ||
'password' => 'testdb', | ||
'url' => 'mysql://USERNAME:PASSWORD@127.0.0.1/DB_NAME?charset=utf8mb4&serverVersion=5.7', | ||
), | ||
)); | ||
|
||
Make sure that your database runs on localhost and has the defined database and | ||
user credentials set up. |
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.
phpunit.xml.dist