7
7
8
8
class DoctrineWriterTest extends \PHPUnit_Framework_TestCase
9
9
{
10
+ const TEST_ENTITY = 'Port\Doctrine\Tests\Fixtures\Entity\TestEntity ' ;
11
+
10
12
public function testWriteItem ()
11
13
{
12
14
$ em = $ this ->getEntityManager ();
13
15
14
16
$ em ->expects ($ this ->once ())
15
17
->method ('persist ' );
16
18
17
- $ writer = new DoctrineWriter ($ em , 'DdeboerPort :TestEntity ' );
19
+ $ writer = new DoctrineWriter ($ em , 'Port :TestEntity ' );
18
20
19
21
$ association = new TestEntity ();
20
22
$ item = array (
@@ -24,15 +26,15 @@ public function testWriteItem()
24
26
);
25
27
$ writer ->writeItem ($ item );
26
28
}
27
-
29
+
28
30
public function testWriteItemMongodb ()
29
31
{
30
32
$ em = $ this ->getMongoDocumentManager ();
31
33
32
34
$ em ->expects ($ this ->once ())
33
35
->method ('persist ' );
34
36
35
- $ writer = new DoctrineWriter ($ em , 'DdeboerPort :TestEntity ' );
37
+ $ writer = new DoctrineWriter ($ em , 'Port :TestEntity ' );
36
38
37
39
$ association = new TestEntity ();
38
40
$ item = array (
@@ -43,12 +45,13 @@ public function testWriteItemMongodb()
43
45
$ writer ->prepare ();
44
46
$ writer ->writeItem ($ item );
45
47
}
46
-
48
+
47
49
public function testUnsupportedDatabaseTypeException ()
48
50
{
49
- $ this ->setExpectedException ('Port\Doctrine\Exception\UnsupportedDatabaseTypeException ' );
50
- $ em = $ this ->getMock ('Doctrine\Common\Persistence\ObjectManager ' );
51
- new DoctrineWriter ($ em , 'DdeboerPort:TestEntity ' );
51
+ $ this ->expectException ('Port\Doctrine\Exception\UnsupportedDatabaseTypeException ' );
52
+ $ em = $ this ->getMockBuilder ('Doctrine\Common\Persistence\ObjectManager ' )
53
+ ->getMock ();
54
+ new DoctrineWriter ($ em , 'Port:TestEntity ' );
52
55
}
53
56
54
57
protected function getEntityManager ()
@@ -69,7 +72,7 @@ protected function getEntityManager()
69
72
70
73
$ metadata ->expects ($ this ->any ())
71
74
->method ('getName ' )
72
- ->will ($ this ->returnValue (' Port\Tests\Fixtures\Entity\TestEntity ' ));
75
+ ->will ($ this ->returnValue (self :: TEST_ENTITY ));
73
76
74
77
$ metadata ->expects ($ this ->any ())
75
78
->method ('getFieldNames ' )
@@ -81,7 +84,7 @@ protected function getEntityManager()
81
84
82
85
$ metadata ->expects ($ this ->any ())
83
86
->method ('getAssociationMappings ' )
84
- ->will ($ this ->returnValue (array (array ('fieldName ' => 'firstAssociation ' ,'targetEntity ' => ' Port\Tests\Fixtures\Entity\TestEntity ' ))));
87
+ ->will ($ this ->returnValue (array (array ('fieldName ' => 'firstAssociation ' ,'targetEntity ' => self :: TEST_ENTITY ))));
85
88
86
89
$ configuration = $ this ->getMockBuilder ('Doctrine\DBAL\Configuration ' )
87
90
->setMethods (array ('getConnection ' ))
@@ -108,10 +111,7 @@ protected function getEntityManager()
108
111
$ connection ->expects ($ this ->any ())
109
112
->method ('executeQuery ' )
110
113
->with ('TRUNCATE SQL ' );
111
-
112
- $ em ->expects ($ this ->never ())
113
- ->method ('getDocumentCollection ' );
114
-
114
+
115
115
$ em ->expects ($ this ->once ())
116
116
->method ('getRepository ' )
117
117
->will ($ this ->returnValue ($ repo ));
@@ -134,7 +134,7 @@ protected function getEntityManager()
134
134
135
135
return $ em ;
136
136
}
137
-
137
+
138
138
139
139
protected function getMongoDocumentManager ()
140
140
{
@@ -154,7 +154,7 @@ protected function getMongoDocumentManager()
154
154
155
155
$ metadata ->expects ($ this ->any ())
156
156
->method ('getName ' )
157
- ->will ($ this ->returnValue (' Port\Tests\Fixtures\Entity\TestEntity ' ));
157
+ ->will ($ this ->returnValue (self :: TEST_ENTITY ));
158
158
159
159
$ metadata ->expects ($ this ->any ())
160
160
->method ('getFieldNames ' )
@@ -163,10 +163,10 @@ protected function getMongoDocumentManager()
163
163
$ metadata ->expects ($ this ->any ())
164
164
->method ('getAssociationNames ' )
165
165
->will ($ this ->returnValue (array ('firstAssociation ' )));
166
-
166
+
167
167
$ metadata ->expects ($ this ->any ())
168
168
->method ('getAssociationMappings ' )
169
- ->will ($ this ->returnValue (array (array ('fieldName ' => 'firstAssociation ' ,'targetEntity ' => ' Port\Tests\Fixtures\Entity\TestEntity ' ))));
169
+ ->will ($ this ->returnValue (array (array ('fieldName ' => 'firstAssociation ' ,'targetEntity ' => self :: TEST_ENTITY ))));
170
170
171
171
$ configuration = $ this ->getMockBuilder ('Doctrine\DBAL\Configuration ' )
172
172
->setMethods (array ('getConnection ' ))
@@ -237,7 +237,7 @@ public function testLoadAssociationWithoutObject()
237
237
$ em ->expects ($ this ->once ())
238
238
->method ('getReference ' );
239
239
240
- $ writer = new DoctrineWriter ($ em , 'DdeboerPort :TestEntity ' );
240
+ $ writer = new DoctrineWriter ($ em , 'Port :TestEntity ' );
241
241
242
242
$ item = array (
243
243
'firstProperty ' => 'some value ' ,
@@ -258,7 +258,7 @@ public function testLoadAssociationWithPresetObject()
258
258
$ em ->expects ($ this ->never ())
259
259
->method ('getReference ' );
260
260
261
- $ writer = new DoctrineWriter ($ em , 'DdeboerPort :TestEntity ' );
261
+ $ writer = new DoctrineWriter ($ em , 'Port :TestEntity ' );
262
262
263
263
$ association = new TestEntity ();
264
264
$ item = array (
@@ -279,9 +279,9 @@ public function testFlushAndClear()
279
279
280
280
$ em ->expects ($ this ->once ())
281
281
->method ('clear ' )
282
- ->with ($ this ->equalTo (' Port\Tests\Fixtures\Entity\TestEntity ' ));
282
+ ->with ($ this ->equalTo (self :: TEST_ENTITY ));
283
283
284
- $ writer = new DoctrineWriter ($ em , 'DdeboerPort :TestEntity ' );
284
+ $ writer = new DoctrineWriter ($ em , 'Port :TestEntity ' );
285
285
$ writer ->finish ();
286
286
}
287
287
}
0 commit comments