forked from f1nder/SolutionMongoAggregationBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseCase.php
More file actions
81 lines (67 loc) · 2.26 KB
/
BaseCase.php
File metadata and controls
81 lines (67 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace Solution\MongoAggregationBundle\Tests;
use Doctrine\MongoDB\ArrayIterator;
use Symfony\Bundle\SecurityBundle\Tests\Functional\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Solution\MongoAggregationBundle\Tests\App\AppKernel;
class BaseCase extends WebTestCase
{
/** @var ContainerInterface */
protected $container;
public function setUp()
{
self::$kernel = new AppKernel('test', true);
static::$kernel->boot();
$this->container = static::$kernel->getContainer();
}
protected function getMockConnection()
{
return $this->getMockBuilder('Doctrine\MongoDB\Connection')
->disableOriginalConstructor()
->getMock();
}
protected function getMockEventManager()
{
return $this->getMockBuilder('Doctrine\Common\EventManager')
->disableOriginalConstructor()
->getMock();
}
protected function getMockMongo()
{
return $this->getMockBuilder('Mongo')
->disableOriginalConstructor()
->getMock();
}
protected function getMockDatabase()
{
$db = $this->getMock('Doctrine\MongoDB\Database', array(), array(), '', false, false);
$db->expects($this->any())
->method('command')
->with($this->anything())
->will($this->returnValue(['ok' => true, 'result' => []]));
return $db;
}
/**
* @return Doctrine\Common\Collections\Collection
*/
private function getMockCollection()
{
$collection = $this->getMock('Doctrine\MongoDB\Collection', array(), array(), '', false, false);
$collection->expects($this->any())
->method('getDatabase')
->will($this->returnValue($this->getMockDatabase()));
return $collection;
}
/**
* @return Doctrine\ODM\MongoDB\DocumentManager
*/
protected function getMockDocumentManager()
{
$dm = $this->getMock('Doctrine\ODM\MongoDB\DocumentManager', array(), array(), '', false, false);
$dm->expects($this->any())
->method('getDocumentCollection')
->with($this->anything())
->will($this->returnValue($this->getMockCollection()));
return $dm;
}
}