diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebd17c1..c67cc16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4] + php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0] steps: - name: Checkout code @@ -24,10 +24,13 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate - - name: Install dependencies - run: | - composer require phpunit/phpunit "<=8.5.2" --no-update --ignore-platform-reqs - composer install --prefer-dist --no-progress --no-interaction --no-suggest + - name: Install dependencies on PHP 7 + if: matrix.php < 8 + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Install dependencies on PHP 8 + if: matrix.php == 8 + run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=php - name: Run test suite run: php vendor/bin/codecept run diff --git a/Robofile.php b/Robofile.php deleted file mode 100644 index ebe93e9..0000000 --- a/Robofile.php +++ /dev/null @@ -1,21 +0,0 @@ - 

Module reference is taken from the source code. Help us to improve documentation. Edit module reference
'; - $documentationFile = 'documentation.md'; - $this->generateDocumentationForClass($className, $documentationFile, $sourceMessage); - } -} \ No newline at end of file diff --git a/composer.json b/composer.json index c1e6e52..d7a6d21 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,10 @@ ], "minimum-stability": "RC", "require": { - "php": ">=5.6.0 <8.0", + "php": ">=5.6.0 <9.0", "codeception/codeception": "^4.0" }, "require-dev": { - "codeception/util-robohelpers": "dev-master", "doctrine/orm": "^2", "doctrine/annotations": "^1", "doctrine/data-fixtures": "^1", diff --git a/documentation.md b/documentation.md deleted file mode 100644 index cc7b5fe..0000000 --- a/documentation.md +++ /dev/null @@ -1,339 +0,0 @@ -# Doctrine2 - - -Access the database using [Doctrine2 ORM](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/). - -When used with Zend Framework 2 or Symfony2, Doctrine's Entity Manager is automatically retrieved from Service Locator. -Set up your `functional.suite.yml` like this: - -``` -modules: - enabled: - - Symfony # 'ZF2' or 'Symfony' - - Doctrine2: - depends: Symfony - cleanup: true # All doctrine queries will be wrapped in a transaction, which will be rolled back at the end of each test -``` - -If you don't use Symfony or Zend Framework, you need to specify a callback function to retrieve the Entity Manager: - -``` -modules: - enabled: - - Doctrine2: - connection_callback: ['MyDb', 'createEntityManager'] - cleanup: true # All doctrine queries will be wrapped in a transaction, which will be rolled back at the end of each test - -``` - -This will use static method of `MyDb::createEntityManager()` to establish the Entity Manager. - -By default, the module will wrap everything into a transaction for each test and roll it back afterwards -(this is controlled by the `cleanup` setting). -By doing this, tests will run much faster and will be isolated from each other. - -To use the Doctrine2 Module in acceptance tests, set up your `acceptance.suite.yml` like this: - -```yaml -modules: - enabled: - - Symfony: - part: SERVICES - - Doctrine2: - depends: Symfony -`` - -You cannot use `cleanup: true` in an acceptance test, since Codeception and your app (i.e. browser) are using two -different connections to the database, so Codeception can't wrap changes made by the app into a transaction. - -## Status - -* Maintainer: **davert** -* Stability: **stable** -* Contact: codecept@davert.mail.ua - -## Config - -## Public Properties - -* `em` - Entity Manager - -## Note on parameters - -Every method that expects some parameters to be checked against values in the database (`see...()`, -`dontSee...()`, `grab...()`) can accept instance of \Doctrine\Common\Collections\Criteria for more -flexibility, e.g.: - -``` php -$I->seeInRepository('User', [ - 'name' => 'John', - Criteria::create()->where( - Criteria::expr()->endsWith('email', '@domain.com') - ), -]); -``` - -If criteria is just a `->where(...)` construct, you can pass just expression without criteria wrapper: - -``` php -$I->seeInRepository('User', [ - 'name' => 'John', - Criteria::expr()->endsWith('email', '@domain.com'), -]); -``` - -Criteria can be used not only to filter data, but also to change order of results: - -``` php -$I->grabEntitiesFromRepository('User', [ - 'status' => 'active', - Criteria::create()->orderBy(['name' => 'asc']), -]); -``` - -Note that key is ignored, because actual field name is part of criteria and/or expression. - -## Actions - -### clearEntityManager - -Performs $em->clear(): - -``` php -$I->clearEntityManager(); -``` - - -### dontSeeInRepository - -Flushes changes to database and performs `findOneBy()` call for current repository. - - * `param` $entity - * `param array` $params - - -### flushToDatabase - -Performs $em->flush(); - - -### grabEntitiesFromRepository - -Selects entities from repository. -It builds query based on array of parameters. -You can use entity associations to build complex queries. - -Example: - -``` php -grabEntitiesFromRepository('AppBundle:User', array('name' => 'davert')); -?> -``` - - * `Available since` 1.1 - * `param` $entity - * `param array` $params. For `IS NULL`, use `array('field'=>null)` - * `return` array - - -### grabEntityFromRepository - -Selects a single entity from repository. -It builds query based on array of parameters. -You can use entity associations to build complex queries. - -Example: - -``` php -grabEntityFromRepository('User', array('id' => '1234')); -?> -``` - - * `Available since` 1.1 - * `param` $entity - * `param array` $params. For `IS NULL`, use `array('field'=>null)` - * `return` object - - -### grabFromRepository - -Selects field value from repository. -It builds query based on array of parameters. -You can use entity associations to build complex queries. - -Example: - -``` php -grabFromRepository('User', 'email', array('name' => 'davert')); -?> -``` - - * `Available since` 1.1 - * `param` $entity - * `param` $field - * `param array` $params - - -### haveFakeRepository - -Mocks the repository. - -With this action you can redefine any method of any repository. -Please, note: this fake repositories will be accessible through entity manager till the end of test. - -Example: - -``` php -haveFakeRepository('Entity\User', array('findByUsername' => function($username) { return null; })); - -``` - -This creates a stub class for Entity\User repository with redefined method findByUsername, -which will always return the NULL value. - - * `param` $classname - * `param array` $methods - - -### haveInRepository - -Persists record into repository. -This method creates an entity, and sets its properties directly (via reflection). -Setters of entity won't be executed, but you can create almost any entity and save it to database. -If the entity has a constructor, for optional parameters the default value will be used and for non-optional parameters the given fields (with a matching name) will be passed when calling the constructor before the properties get set directly (via reflection). - -Returns primary key of newly created entity. Primary key value is extracted using Reflection API. -If primary key is composite, array of values is returned. - -```php -$I->haveInRepository('Entity\User', array('name' => 'davert')); -``` - -This method also accepts instances as first argument, which is useful when entity constructor -has some arguments: - -```php -$I->haveInRepository(new User($arg), array('name' => 'davert')); -``` - -Alternatively, constructor arguments can be passed by name. Given User constructor signature is `__constructor($arg)`, the example above could be rewritten like this: - -```php -$I->haveInRepository('Entity\User', array('arg' => $arg, 'name' => 'davert')); -``` - -If entity has relations, they can be populated too. In case of OneToMany the following format -ie expected: - -```php -$I->haveInRepository('Entity\User', array( - 'name' => 'davert', - 'posts' => array( - array( - 'title' => 'Post 1', - ), - array( - 'title' => 'Post 2', - ), - ), -)); -``` - -For ManyToOne format is slightly different: - -```php -$I->haveInRepository('Entity\User', array( - 'name' => 'davert', - 'post' => array( - 'title' => 'Post 1', - ), -)); -``` - -This works recursively, so you can create deep structures in a single call. - -Note that both `$em->persist(...)`, $em->refresh(...), and `$em->flush()` are called every time. - - * `param string|object` $classNameOrInstance - * `param array` $data - - -### loadFixtures - -Loads fixtures. Fixture can be specified as a fully qualified class name, -an instance, or an array of class names/instances. - -```php -loadFixtures(AppFixtures::class); -$I->loadFixtures([AppFixtures1::class, AppFixtures2::class]); -$I->loadFixtures(new AppFixtures); -``` - -By default fixtures are loaded in 'append' mode. To replace all -data in database, use `false` as second parameter: - -```php -loadFixtures(AppFixtures::class, false); -``` - -Note: this method requires `doctrine/data-fixtures` package to be installed. - - * `param string|string[]|object[]` $fixtures - * `param bool` $append -@throws ModuleException -@throws ModuleRequireException - - -### onReconfigure - -HOOK to be executed when config changes with `_reconfigure`. - - -### persistEntity - -This method is deprecated in favor of `haveInRepository()`. It's functionality is exactly the same. - - -### refreshEntities - -Performs $em->refresh() on every passed entity: - -``` php -$I->refreshEntities($user); -$I->refreshEntities([$post1, $post2, $post3]]); -``` - -This can useful in acceptance tests where entity can become invalid due to -external (relative to entity manager used in tests) changes. - - * `param object|object[]` $entities - - -### seeInRepository - -Flushes changes to database, and executes a query with parameters defined in an array. -You can use entity associations to build complex queries. - -Example: - -``` php -seeInRepository('AppBundle:User', array('name' => 'davert')); -$I->seeInRepository('User', array('name' => 'davert', 'Company' => array('name' => 'Codegyre'))); -$I->seeInRepository('Client', array('User' => array('Company' => array('name' => 'Codegyre'))); -?> -``` - -Fails if record for given criteria can\'t be found, - - * `param` $entity - * `param array` $params - -

 

Module reference is taken from the source code. Help us to improve documentation. Edit module reference
diff --git a/readme.md b/readme.md index 936fa8d..cc0c300 100644 --- a/readme.md +++ b/readme.md @@ -10,4 +10,4 @@ composer require --dev "codeception/module-doctrine2" ## Documentation -Look at documentation.md file +Module documentation diff --git a/src/Codeception/Module/Doctrine2.php b/src/Codeception/Module/Doctrine2.php index 745b02f..a8c0cdf 100644 --- a/src/Codeception/Module/Doctrine2.php +++ b/src/Codeception/Module/Doctrine2.php @@ -74,7 +74,7 @@ * You cannot use `cleanup: true` in an acceptance test, since Codeception and your app (i.e. browser) are using two * different connections to the database, so Codeception can't wrap changes made by the app into a transaction. * - * Change purge mode doctrine fixtures: + * Change purge mode of doctrine fixtures: * ```yaml * modules: * enabled: