@@ 52-75 (lines=24) @@ | ||
49 | $line->save(); |
|
50 | } |
|
51 | ||
52 | public function testSave() |
|
53 | { |
|
54 | $po = new PurchaseOrder(); |
|
55 | $po->id = 1; |
|
56 | $po->name = 'PO1'; |
|
57 | ||
58 | $line = new PurchaseOrderLine(); |
|
59 | $line->id = 1; |
|
60 | $line->name = 'Line1'; |
|
61 | ||
62 | $po->save(); |
|
63 | $po->lines()->save($line); |
|
64 | ||
65 | $poPath = $po->getPath()->toArray(); |
|
66 | $linePath = $line->getPath()->toArray(); |
|
67 | ||
68 | $res = $this->es->get($poPath); |
|
69 | $this->assertEquals(1, $res['_id']); |
|
70 | $this->assertEquals('PO1', $res['_source']['name']); |
|
71 | ||
72 | $res = $this->es->get($linePath); |
|
73 | $this->assertEquals(1, $res['_id']); |
|
74 | $this->assertEquals('Line1', $res['_source']['name']); |
|
75 | } |
|
76 | ||
77 | public function testAssociate() |
|
78 | { |
|
@@ 77-101 (lines=25) @@ | ||
74 | $this->assertEquals('Line1', $res['_source']['name']); |
|
75 | } |
|
76 | ||
77 | public function testAssociate() |
|
78 | { |
|
79 | $po = new PurchaseOrder(); |
|
80 | $po->id = 1; |
|
81 | $po->name = 'PO1'; |
|
82 | ||
83 | $line = new PurchaseOrderLine(); |
|
84 | $line->id = 1; |
|
85 | $line->name = 'Line1'; |
|
86 | ||
87 | $po->save(); |
|
88 | $line->po()->associate($po); |
|
89 | $line->save(); |
|
90 | ||
91 | $poPath = $po->getPath()->toArray(); |
|
92 | $linePath = $line->getPath()->toArray(); |
|
93 | ||
94 | $res = $this->es->get($poPath); |
|
95 | $this->assertEquals(1, $res['_id']); |
|
96 | $this->assertEquals('PO1', $res['_source']['name']); |
|
97 | ||
98 | $res = $this->es->get($linePath); |
|
99 | $this->assertEquals(1, $res['_id']); |
|
100 | $this->assertEquals('Line1', $res['_source']['name']); |
|
101 | } |
|
102 | ||
103 | public function testGetParent() |
|
104 | { |