forked from doctrine/mongodb-odm
/
GH245Test.php
50 lines (38 loc) · 1.04 KB
/
GH245Test.php
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
<?php
declare(strict_types=1);
namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTest;
use function get_class;
class GH245Test extends BaseTest
{
public function testTest()
{
$order = new GH245Order();
$order->id = 1;
$orderLog = new GH245OrderLog();
$orderLog->order = $order;
$this->dm->persist($orderLog);
$this->dm->persist($order);
$this->dm->flush();
$this->dm->clear();
$user = $this->dm->find(get_class($order), $order->id);
$this->assertIsInt($order->id);
$check = $this->dm->getDocumentCollection(get_class($orderLog))->findOne();
$this->assertIsInt($check['order']['$id']);
}
}
/** @ODM\Document */
class GH245Order
{
/** @ODM\Id(strategy="NONE") */
public $id;
}
/** @ODM\Document */
class GH245OrderLog
{
/** @ODM\Id */
public $id;
/** @ODM\ReferenceOne(targetDocument=GH245Order::class) */
public $order;
}