|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2018 Michael Giesler |
|
3
|
|
|
* |
|
4
|
|
|
* This file is part of Dembelo. |
|
5
|
|
|
* |
|
6
|
|
|
* Dembelo is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
|
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* Dembelo is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU Affero General Public License 3 for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU Affero General Public License 3 |
|
17
|
|
|
* along with Dembelo. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace DembeloMain\IntegrationTests\Document; |
|
21
|
|
|
|
|
22
|
|
|
use DembeloMain\Document\Textnode; |
|
23
|
|
|
use DembeloMain\Document\TextnodeHitch; |
|
24
|
|
|
use DembeloMain\IntegrationTests\WebTestCase; |
|
25
|
|
|
use Doctrine\ODM\MongoDB\PersistentCollection; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @group integration |
|
29
|
|
|
*/ |
|
30
|
|
|
class TextnodeTest extends WebTestCase |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @return void |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testChildHitchesIsEmptyForNewTextnode(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$textnode = new Textnode(); |
|
38
|
|
|
$textnode->setText('firstTextnode'); |
|
39
|
|
|
$this->getMongo()->persist($textnode); |
|
40
|
|
|
$this->getMongo()->flush(); |
|
41
|
|
|
$this->getMongo()->clear(); |
|
42
|
|
|
$textnodes = $this->getMongo()->getRepository(Textnode::class)->findAll(); |
|
43
|
|
|
|
|
44
|
|
|
self::assertEquals('firstTextnode', $textnodes[0]->getText()); |
|
45
|
|
|
self::assertInstanceOf(PersistentCollection::class, $textnodes[0]->getChildHitches()); |
|
46
|
|
|
self::assertEquals(0, $textnodes[0]->getChildHitches()->count()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testChildHitchesReference(): void |
|
53
|
|
|
{ |
|
54
|
|
|
$textnode = new Textnode(); |
|
55
|
|
|
$this->getMongo()->persist($textnode); |
|
56
|
|
|
$hitch = new TextnodeHitch(); |
|
57
|
|
|
$this->getMongo()->persist($hitch); |
|
58
|
|
|
$hitch->setSourceTextnode($textnode); |
|
59
|
|
|
|
|
60
|
|
|
$this->getMongo()->flush(); |
|
61
|
|
|
$this->getMongo()->clear(); |
|
62
|
|
|
|
|
63
|
|
|
$textnodes = $this->getMongo()->getRepository(Textnode::class)->findAll(); |
|
64
|
|
|
$hitches = $this->getMongo()->getRepository(TextnodeHitch::class)->findAll(); |
|
65
|
|
|
|
|
66
|
|
|
self::assertInstanceOf(Textnode::class, $textnodes[0]); |
|
67
|
|
|
self::assertInstanceOf(TextnodeHitch::class, $hitches[0]); |
|
68
|
|
|
self::assertSame($textnodes[0], $hitches[0]->getSourceTextnode()); |
|
69
|
|
|
self::assertEquals(1, $textnodes[0]->getChildHitches()->count()); |
|
70
|
|
|
self::assertSame($hitches[0], $textnodes[0]->getChildHitches()->first()); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|