@@ -126,6 +126,31 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
126
126
$ this ->assertSame ($ this ->contentDocument , $ res ->getContent ());
127
127
}
128
128
129
+ /**
130
+ * @expectedException \RuntimeException
131
+ * @expectedExceptionMessageRegExp /Failed to migrate existing.*? at "\/test\/generic" .*? It is an instance of ".*?stdClass.*?"\./
132
+ */
133
+ public function testCreateAutoRouteThrowsExceptionIfItCannotMigrateExistingGenericDocumentToAutoRoute ()
134
+ {
135
+ $ uri = '/generic ' ;
136
+ $ genericDocument = $ this ->prophesize ('Doctrine\ODM\PHPCR\Document\Generic ' );
137
+ $ genericDocument ->getNode ()->willReturn ($ this ->prophesize ('PHPCR\NodeInterface ' )->reveal ());
138
+ $ genericDocument ->getId ()->willReturn ($ this ->baseRoutePath . $ uri );
139
+ $ documentClassMapper = $ this ->prophesize ('Doctrine\ODM\PHPCR\DocumentClassMapperInterface ' );
140
+ $ configuration = $ this ->prophesize ('Doctrine\ODM\PHPCR\Configuration ' );
141
+ $ configuration ->getDocumentClassMapper ()->willReturn ($ documentClassMapper ->reveal ());
142
+ $ this ->dm ->getConfiguration ()->willReturn ($ configuration ->reveal ());
143
+ $ this ->dm ->getPhpcrSession ()->willReturn ($ this ->phpcrSession );
144
+ $ this ->dm ->detach ($ genericDocument )->willReturn (null );
145
+ $ this ->dm ->find (null , $ this ->baseRoutePath )->willReturn ($ this ->baseNode );
146
+ $ this ->dm ->find (null , $ this ->baseRoutePath . $ uri )->willReturn (
147
+ $ genericDocument ->reveal (),
148
+ $ this ->prophesize ('stdClass ' )->reveal ()
149
+ );
150
+ $ this ->uriContext ->getUri ()->willReturn ($ uri );
151
+ $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), $ this ->contentDocument , 'it ' );
152
+ }
153
+
129
154
/**
130
155
* @expectedException \RuntimeException
131
156
* @expectedExceptionMessage configuration points to a non-existant path
0 commit comments