GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — codeception.github.com/docs/modules/Doctrine2.markdown at master · captbaritone/codeception.github.com

Expand file tree

/

Doctrine2.markdown

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
163 lines (90 loc) · 3.28 KB
/

Doctrine2.markdown

Copy path

File metadata and controls

163 lines (90 loc) · 3.28 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions
layout doc
title Doctrine2 Module - Codeception - Documentation

Doctrine2 Module

For additional reference, please review the source

Allows integration and testing for projects with Doctrine2 ORM.

Doctrine2 uses EntityManager to perform all database operations. As the module uses active connection and active entity manager, instance of this object should be passed to this module.

It can be done in bootstrap file, by setting static $em property:

{% highlight php %}

findOneBy() call for current repository. * param $entity * param array $params #### flushToDatabase Performs $em->flush(); #### getName __not documented__ #### grabFromRepository Selects field value from repository. It builds query based on array of parameters. You can use entity associations to build complex queries. Example: {% highlight php %} grabFromRepository('User', 'email', array('name' => 'davert')); ?>

{% endhighlight %}

  • version 1.1
  • param $entity
  • param $field
  • param array $params
  • return array

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:

{% highlight php %}

haveFakeRepository('Entity\User', array('findByUsername' => function($username) { return null; })); {% endhighlight %} 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 Saves data in repository #### persistEntity Adds entity to repository and flushes. You can redefine it's properties with the second parameter. Example: {% highlight php %} persistEntity(new \Entity\User, array('name' => 'Miles')); $I->persistEntity($user, array('name' => 'Miles')); {% endhighlight %} * param $obj * param array $values #### seeInRepository Flushes changes to database executes a query defined by array. It builds query based on array of parameters. You can use entity associations to build complex queries. Example: {% highlight php %} seeInRepository('User', array('name' => 'davert')); $I->seeInRepository('User', array('name' => 'davert', 'Company' => array('name' => 'Codegyre'))); $I->seeInRepository('Client', array('User' => array('Company' => array('name' => 'Codegyre'))); ?>

{% endhighlight %}

Fails if record for given criteria can't be found,

  • param $entity
  • param array $params
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.