From a3cd189fb8631f59660c0c01a6b82ea92cfa1ff9 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 18 Feb 2024 11:37:42 +0100 Subject: [PATCH] Update UnitTests.md: Renaming Doctrine2 -> Doctrine --- docs/UnitTests.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/UnitTests.md b/docs/UnitTests.md index 0efc3f305..d4d088212 100644 --- a/docs/UnitTests.md +++ b/docs/UnitTests.md @@ -299,19 +299,19 @@ A very similar approach can be used for all frameworks that have an ORM implemen In Yii2 and Phalcon, the methods `haveRecord`, `seeRecord`, `dontSeeRecord` work in the same way. They also should be included by specifying `part: ORM` in order to not use the functional testing actions. -If you are using Symfony with Doctrine, you don't need to enable Symfony itself but just Doctrine2: +If you are using Symfony with Doctrine, you don't need to enable Symfony itself but just Doctrine: ```yaml actor: UnitTester modules: enabled: - Asserts - - Doctrine2: + - Doctrine: depends: Symfony - \Helper\Unit ``` -In this case you can use the methods from the Doctrine2 module, while Doctrine itself uses the Symfony module +In this case you can use the methods from the Doctrine module, while Doctrine itself uses the Symfony module to establish connections to the database. In this case a test might look like: ```php @@ -321,7 +321,7 @@ function testUserNameCanBeChanged() // create a user from framework, user will be deleted after the test $id = $this->tester->haveInRepository(User::class, ['name' => 'miles']); // get entity manager by accessing module - $em = $this->getModule('Doctrine2')->em; + $em = $this->getModule('Doctrine')->em; // get real user $user = $em->find(User::class, $id); $user->setName('bill'); @@ -335,7 +335,7 @@ function testUserNameCanBeChanged() ``` In both examples you should not be worried about the data persistence between tests. -The Doctrine2 and Laravel modules will clean up the created data at the end of a test. +The Doctrine and Laravel modules will clean up the created data at the end of a test. This is done by wrapping each test in a transaction and rolling it back afterwards. ### Accessing Module @@ -344,12 +344,12 @@ Codeception allows you to access the properties and methods of all modules defin Unlike using the UnitTester class for this purpose, using a module directly grants you access to all public properties of that module. -We have already demonstrated this in a previous example where we accessed the Entity Manager from a Doctrine2 module: +We have already demonstrated this in a previous example where we accessed the Entity Manager from a Doctrine module: ```php getModule('Doctrine2')->em; +$em = $this->getModule('Doctrine')->em; ``` If you use the `Symfony` module, here is how you can access the Symfony container: