File tree Expand file tree Collapse file tree
tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Doctrine \ODM \MongoDB \Tests ;
4+
5+ use Doctrine \Common \Collections \ArrayCollection ;
6+ use Doctrine \ODM \MongoDB \Mapping \Annotations as ODM ;
7+
8+ class GH301Test extends BaseTest
9+ {
10+ public function testPersistIsCascadedInSingleDocumentFlush ()
11+ {
12+ $ ref = new GH301Document ();
13+ $ ref ->name = 'referenced ' ;
14+
15+ $ doc = new GH301Document ();
16+ $ doc ->name = 'parent ' ;
17+ $ doc ->refOnePersist = $ ref ;
18+
19+ $ this ->dm ->persist ($ doc );
20+ $ this ->dm ->flush ($ doc );
21+ $ this ->dm ->clear ();
22+
23+ $ docId = $ doc ->id ; unset($ doc );
24+ $ refId = $ ref ->id ; unset($ ref );
25+
26+ $ doc = $ this ->dm ->find (__NAMESPACE__ . '\GH301Document ' , $ docId );
27+ $ this ->assertNotNull ($ doc );
28+ $ this ->assertEquals ($ refId , $ doc ->refOnePersist ->id );
29+ }
30+ }
31+
32+ /** @ODM\Document */
33+ class GH301Document
34+ {
35+ /** @ODM\Id */
36+ public $ id ;
37+
38+ /** @ODM\String */
39+ public $ name ;
40+
41+ /**
42+ * @ODM\ReferenceOne(targetDocument="GH301Document", cascade="persist")
43+ */
44+ public $ refOnePersist ;
45+ }
You can’t perform that action at this time.
0 commit comments