tflori/orm

just another orm...

View the Project on GitHub tflori/orm

Build Status Test Coverage Maintainability Latest Stable Version Total Downloads

» API Reference » ORM\Testing\EntityFetcherMock\ResultRepository

ORM\Testing\EntityFetcherMock\ResultRepository

Table of Contents

Abstract

Constants

Name Value
RANDOM_KEY_MIN 1000000000
RANDOM_KEY_MAX 1000999999

Methods

ORM\Testing\EntityFetcherMock\ResultRepository::__construct

public function __construct(\ORM\EntityManager $em)
ResultRepository constructor.
Parameters
Parameter Type Description
$em ORM\EntityManager  

ORM\Testing\EntityFetcherMock\ResultRepository::__construct

↑ top


ORM\Testing\EntityFetcherMock\ResultRepository::addEntity

public function addEntity(\ORM\Entity $entity): mixed
Add an entity to be fetched by primary key

The entity needs to have a primary key if not it will be filled with random values between RANDOM_KEY_MIN and RANDOM_KEY_MAX (at the time writing this it is 1000000000 and 1000999999).

You can pass mocks from Entity too but we need to call Entity::getPrimaryKey().

Returns mixed  
Parameters
Parameter Type Description
$entity ORM\Entity  

ORM\Testing\EntityFetcherMock\ResultRepository::addEntity

↑ top


ORM\Testing\EntityFetcherMock\ResultRepository::addResult

public function addResult(
    mixed $class, 
    \ORM\Entity $entities, 
): \ORM\Testing\EntityFetcherMock\Result|\Mockery\MockInterface
Create and add a EntityFetcherMock\Result for $class

As the results are mocked to come from the database they will also get a primary key if they don’t have already.

Returns ORM\Testing\EntityFetcherMock\Result|Mockery\MockInterface  
Parameters
Parameter Type Description
$class mixed  
$entities ORM\Entity  

ORM\Testing\EntityFetcherMock\ResultRepository::addResult

↑ top


ORM\Testing\EntityFetcherMock\ResultRepository::completePrimaryKeys

public static function completePrimaryKeys(\ORM\Entity $entities): \ORM\Entity[]
Fill the primary keys of $entities

If the primary key is incomplete the missing attributes will be filled with a random integer between RANDOM_KEY_MIN and RANDOM_KEY_MAX (at the time writing this it is 1000000000 and 1000999999).

Static   This method is static.
Returns ORM\Entity[]  
Parameters
Parameter Type Description
$entities ORM\Entity  

ORM\Testing\EntityFetcherMock\ResultRepository::completePrimaryKeys

↑ top


ORM\Testing\EntityFetcherMock\ResultRepository::getResults

public function getResults(string $class, \ORM\EntityFetcher $fetcher): array
Get the results for $class and $query

The EntityFetcherMock\Result gets a quality for matching this query. Only the highest quality will be used.

Returns array  
Parameters
Parameter Type Description
$class string  
$fetcher ORM\EntityFetcher  

ORM\Testing\EntityFetcherMock\ResultRepository::getResults

↑ top


ORM\Testing\EntityFetcherMock\ResultRepository::retrieve

public function retrieve(string $class, array $primaryKey): \ORM\Entity|null
Retrieve an entity by $primaryKey
Returns ORM\Entity|null  
Parameters
Parameter Type Description
$class string  
$primaryKey array  

ORM\Testing\EntityFetcherMock\ResultRepository::retrieve

↑ top