Completed
Push — master ( 74c3c7...591b88 )
by Eric
08:09
created

testTranslatableRepository()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 28

Duplication

Lines 38
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 38
loc 38
rs 8.8571
cc 1
eloc 28
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Component\Translation\Tests\Repository\Doctrine\MongoDB;
13
14
use Doctrine\ODM\MongoDB\Configuration;
15
use Doctrine\ODM\MongoDB\DocumentManager;
16
use Doctrine\ODM\MongoDB\DocumentRepository;
17
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
18
use Doctrine\ODM\MongoDB\UnitOfWork;
19
use Lug\Component\Registry\Model\RegistryInterface;
20
use Lug\Component\Resource\Model\ResourceInterface;
21
use Lug\Component\Resource\Repository\Doctrine\MongoDB\Repository;
22
use Lug\Component\Resource\Repository\Doctrine\MongoDB\RepositoryFactory;
23
use Lug\Component\Translation\Context\LocaleContextInterface;
24
use Lug\Component\Translation\Repository\Doctrine\MongoDB\TranslatableRepository;
25
use Lug\Component\Translation\Repository\Doctrine\MongoDB\TranslatableRepositoryFactory;
26
use Symfony\Component\DependencyInjection\ContainerInterface;
27
28
/**
29
 * @author GeLo <[email protected]>
30
 */
31
class TranslatableRepositoryFactoryTest extends \PHPUnit_Framework_TestCase
32
{
33
    /**
34
     * @var TranslatableRepositoryFactory
35
     */
36
    private $repositoryFactory;
37
38
    /**
39
     * @var \PHPUnit_Framework_MockObject_MockObject|ContainerInterface
40
     */
41
    private $container;
42
43
    /**
44
     * @var \PHPUnit_Framework_MockObject_MockObject|RegistryInterface
45
     */
46
    private $resourceRegistry;
47
48
    /**
49
     * @var \PHPUnit_Framework_MockObject_MockObject|LocaleContextInterface
50
     */
51
    private $localeContext;
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function setUp()
57
    {
58
        if (!class_exists(DocumentManager::class)) {
59
            $this->markTestSkipped();
60
        }
61
62
        $this->resourceRegistry = $this->createServiceRegistryMock();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createServiceRegistryMock() can also be of type object<Lug\Component\Reg...odel\RegistryInterface>. However, the property $resourceRegistry is declared as type object<PHPUnit_Framework_MockObject_MockObject>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
63
        $this->localeContext = $this->createLocaleContextMock();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createLocaleContextMock() can also be of type object<Lug\Component\Tra...LocaleContextInterface>. However, the property $localeContext is declared as type object<PHPUnit_Framework_MockObject_MockObject>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
64
65
        $this->container = $this->createContainerMock();
66
        $this->container
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Depend...tion\ContainerInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
67
            ->expects($this->atLeast(1))
68
            ->method('get')
69
            ->will($this->returnValueMap([
70
                [
71
                    'lug.resource.registry',
72
                    ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
73
                    $this->resourceRegistry,
74
                ],
75
                [
76
                    'lug.translation.context.locale',
77
                    ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
78
                    $this->localeContext,
79
                ],
80
            ]));
81
82
        $this->repositoryFactory = new TranslatableRepositoryFactory($this->container);
83
    }
84
85
    public function testInheritance()
86
    {
87
        $this->assertInstanceOf(RepositoryFactory::class, $this->repositoryFactory);
88
    }
89
90 View Code Duplication
    public function testRepository()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
    {
92
        $documentManager = $this->createDocumentManagerMock();
93
        $documentManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\DocumentManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
94
            ->expects($this->exactly(2))
95
            ->method('getClassMetadata')
96
            ->with($this->identicalTo($documentName = 'document'))
97
            ->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
98
99
        $documentManager
100
            ->expects($this->exactly(2))
101
            ->method('getConfiguration')
102
            ->will($this->returnValue($configuration = $this->createConfigurationMock()));
103
104
        $configuration
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\Configuration.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
105
            ->expects($this->exactly(2))
106
            ->method('getDefaultRepositoryClassName')
107
            ->will($this->returnValue($repositoryClass = DocumentRepository::class));
108
109
        $classMetadata
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\Mapping\ClassMetadata.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
110
            ->expects($this->exactly(2))
111
            ->method('getName')
112
            ->will($this->returnValue($documentName));
113
114
        $this->resourceRegistry
115
            ->expects($this->once())
116
            ->method('getIterator')
117
            ->will($this->returnValue(new \ArrayIterator([])));
118
119
        $documentManager
120
            ->expects($this->once())
121
            ->method('getUnitOfWork')
122
            ->will($this->returnValue($this->createUnitOfWorkMock()));
123
124
        $this->assertInstanceOf(
125
            $repositoryClass,
126
            $repository = $this->repositoryFactory->getRepository($documentManager, $documentName)
0 ignored issues
show
Bug introduced by
It seems like $documentManager defined by $this->createDocumentManagerMock() on line 92 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Doctrine\ODM\MongoDB\Rep...actory::getRepository() does only seem to accept object<Doctrine\ODM\MongoDB\DocumentManager>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
127
        );
128
129
        $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName));
0 ignored issues
show
Bug introduced by
It seems like $documentManager defined by $this->createDocumentManagerMock() on line 92 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Doctrine\ODM\MongoDB\Rep...actory::getRepository() does only seem to accept object<Doctrine\ODM\MongoDB\DocumentManager>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
130
    }
131
132 View Code Duplication
    public function testResourceRepository()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
133
    {
134
        $documentManager = $this->createDocumentManagerMock();
135
        $documentManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\DocumentManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
136
            ->expects($this->once())
137
            ->method('getClassMetadata')
138
            ->with($this->identicalTo($documentName = 'document'))
139
            ->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
140
141
        $classMetadata
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\Mapping\ClassMetadata.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
142
            ->expects($this->once())
143
            ->method('getName')
144
            ->will($this->returnValue($documentName));
145
146
        $this->resourceRegistry
147
            ->expects($this->once())
148
            ->method('getIterator')
149
            ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()])));
150
151
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
152
            ->expects($this->once())
153
            ->method('getModel')
154
            ->will($this->returnValue($documentName));
155
156
        $documentManager
157
            ->expects($this->once())
158
            ->method('getUnitOfWork')
159
            ->will($this->returnValue($this->createUnitOfWorkMock()));
160
161
        $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class;
162
163
        $this->assertInstanceOf(
164
            $repositoryClass,
165
            $repository = $this->repositoryFactory->getRepository($documentManager, $documentName)
0 ignored issues
show
Bug introduced by
It seems like $documentManager defined by $this->createDocumentManagerMock() on line 134 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Doctrine\ODM\MongoDB\Rep...actory::getRepository() does only seem to accept object<Doctrine\ODM\MongoDB\DocumentManager>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
166
        );
167
168
        $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName));
0 ignored issues
show
Bug introduced by
It seems like $documentManager defined by $this->createDocumentManagerMock() on line 134 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Doctrine\ODM\MongoDB\Rep...actory::getRepository() does only seem to accept object<Doctrine\ODM\MongoDB\DocumentManager>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
169
    }
170
171 View Code Duplication
    public function testTranslatableRepository()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
172
    {
173
        $documentManager = $this->createDocumentManagerMock();
174
        $documentManager
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\DocumentManager.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
175
            ->expects($this->once())
176
            ->method('getClassMetadata')
177
            ->with($this->identicalTo($documentName = 'document'))
178
            ->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
179
180
        $classMetadata
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Doctrine\ODM\MongoDB\Mapping\ClassMetadata.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
181
            ->expects($this->once())
182
            ->method('getName')
183
            ->will($this->returnValue($documentName));
184
185
        $this->resourceRegistry
186
            ->expects($this->once())
187
            ->method('getIterator')
188
            ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()])));
189
190
        $resource
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Lug\Component\Resource\Model\ResourceInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
191
            ->expects($this->once())
192
            ->method('getModel')
193
            ->will($this->returnValue($documentName));
194
195
        $documentManager
196
            ->expects($this->once())
197
            ->method('getUnitOfWork')
198
            ->will($this->returnValue($this->createUnitOfWorkMock()));
199
200
        $classMetadata->customRepositoryClassName = $repositoryClass = TranslatableRepository::class;
201
202
        $this->assertInstanceOf(
203
            $repositoryClass,
204
            $repository = $this->repositoryFactory->getRepository($documentManager, $documentName)
0 ignored issues
show
Bug introduced by
It seems like $documentManager defined by $this->createDocumentManagerMock() on line 173 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Doctrine\ODM\MongoDB\Rep...actory::getRepository() does only seem to accept object<Doctrine\ODM\MongoDB\DocumentManager>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
205
        );
206
207
        $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName));
0 ignored issues
show
Bug introduced by
It seems like $documentManager defined by $this->createDocumentManagerMock() on line 173 can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, Doctrine\ODM\MongoDB\Rep...actory::getRepository() does only seem to accept object<Doctrine\ODM\MongoDB\DocumentManager>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
208
    }
209
210
    /**
211
     * @return \PHPUnit_Framework_MockObject_MockObject|RegistryInterface
212
     */
213
    private function createServiceRegistryMock()
214
    {
215
        return $this->getMock(RegistryInterface::class);
216
    }
217
218
    /**
219
     * @return \PHPUnit_Framework_MockObject_MockObject|ContainerInterface
220
     */
221
    private function createContainerMock()
222
    {
223
        return $this->getMock(ContainerInterface::class);
224
    }
225
226
    /**
227
     * @return \PHPUnit_Framework_MockObject_MockObject|LocaleContextInterface
228
     */
229
    private function createLocaleContextMock()
230
    {
231
        return $this->getMock(LocaleContextInterface::class);
232
    }
233
234
    /**
235
     * @return \PHPUnit_Framework_MockObject_MockObject|DocumentManager
236
     */
237
    private function createDocumentManagerMock()
238
    {
239
        return $this->getMockBuilder(DocumentManager::class)
240
            ->disableOriginalConstructor()
241
            ->getMock();
242
    }
243
244
    /**
245
     * @return \PHPUnit_Framework_MockObject_MockObject|UnitOfWork
246
     */
247
    public function createUnitOfWorkMock()
248
    {
249
        return $this->getMockBuilder(UnitOfWork::class)
250
            ->disableOriginalConstructor()
251
            ->getMock();
252
    }
253
254
    /**
255
     * @return \PHPUnit_Framework_MockObject_MockObject|ClassMetadata
256
     */
257
    private function createClassMetadataMock()
258
    {
259
        return $this->getMockBuilder(ClassMetadata::class)
260
            ->disableOriginalConstructor()
261
            ->getMock();
262
    }
263
264
    /**
265
     * @return \PHPUnit_Framework_MockObject_MockObject|Configuration
266
     */
267
    private function createConfigurationMock()
268
    {
269
        return $this->getMock(Configuration::class);
270
    }
271
272
    /**
273
     * @return \PHPUnit_Framework_MockObject_MockObject|ResourceInterface
274
     */
275
    private function createResourceMock()
276
    {
277
        return $this->getMock(ResourceInterface::class);
278
    }
279
}
280