|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2015 Michael Giesler, Stephan Kreutzer |
|
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
|
|
|
/** |
|
21
|
|
|
* @package DembeloMain |
|
22
|
|
|
*/ |
|
23
|
|
|
namespace DembeloMain\Tests\Document; |
|
24
|
|
|
|
|
25
|
|
|
use DembeloMain\Document\TextnodeHitch; |
|
26
|
|
|
use DembeloMain\Model\Repository\Doctrine\ODM\TextNodeRepository; |
|
27
|
|
|
use PHP_CodeSniffer\Generators\Text; |
|
28
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; |
|
29
|
|
|
use DembeloMain\Document\Textnode; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Class DocumentTextnodeTest |
|
33
|
|
|
*/ |
|
34
|
|
|
class TextnodeTest extends KernelTestCase |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var \DembeloMain\Document\Textnode |
|
38
|
|
|
*/ |
|
39
|
|
|
private $textnode; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* setUp method |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function setUp(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->textnode = new Textnode(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* tests getId() |
|
52
|
|
|
*/ |
|
53
|
|
|
public function testGetIdShouldBeEqualSetId() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->textnode->setId('testid'); |
|
56
|
|
|
$this->assertEquals('testid', $this->textnode->getId()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* tests getId() |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testGetIdShouldBeNullWhenNotSet() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->assertNull($this->textnode->getId()); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* tests the created |
|
69
|
|
|
*/ |
|
70
|
|
|
public function testCreated() |
|
71
|
|
|
{ |
|
72
|
|
|
$this->textnode->setCreated('2015-01-01 01:02:03'); |
|
73
|
|
|
$this->assertEquals('2015-01-01 01:02:03', $this->textnode->getCreated()); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* tests the licensee ID |
|
78
|
|
|
*/ |
|
79
|
|
|
public function testLicenseeId() |
|
80
|
|
|
{ |
|
81
|
|
|
$licenseeId = 'asd23fasdf'; |
|
82
|
|
|
$this->textnode->setLicenseeId($licenseeId); |
|
83
|
|
|
$this->assertEquals($licenseeId, $this->textnode->getLicenseeId()); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* tests the metadata |
|
88
|
|
|
*/ |
|
89
|
|
|
public function testMetadata() |
|
90
|
|
|
{ |
|
91
|
|
|
$metadata = array('story' => 'xyz'); |
|
92
|
|
|
$this->textnode->setMetadata($metadata); |
|
93
|
|
|
$this->assertEquals($metadata, $this->textnode->getMetadata()); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* tests the status |
|
98
|
|
|
*/ |
|
99
|
|
|
public function testStatus() |
|
100
|
|
|
{ |
|
101
|
|
|
$status = 1; |
|
102
|
|
|
$this->textnode->setStatus($status); |
|
103
|
|
|
$this->assertEquals($status, $this->textnode->getStatus()); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* tests the text |
|
108
|
|
|
*/ |
|
109
|
|
|
public function testText() |
|
110
|
|
|
{ |
|
111
|
|
|
$text = 'Lorem Ipsum'; |
|
112
|
|
|
$this->textnode->setText($text); |
|
113
|
|
|
$this->assertEquals($text, $this->textnode->getText()); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* tests the topicId |
|
118
|
|
|
*/ |
|
119
|
|
|
public function testTopicId() |
|
120
|
|
|
{ |
|
121
|
|
|
$topicId = 'asd23123'; |
|
122
|
|
|
$this->textnode->setTopicId($topicId); |
|
123
|
|
|
$this->assertEquals($topicId, $this->textnode->getTopicId()); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* tests the access |
|
128
|
|
|
*/ |
|
129
|
|
|
public function testAccess() |
|
130
|
|
|
{ |
|
131
|
|
|
$this->textnode->setAccess(false); |
|
132
|
|
|
$this->assertFalse($this->textnode->getAccess()); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* tests the access |
|
137
|
|
|
*/ |
|
138
|
|
|
public function testTwineId() |
|
139
|
|
|
{ |
|
140
|
|
|
$this->textnode->setTwineId('foobarTwineId'); |
|
141
|
|
|
$this->assertEquals('foobarTwineId', $this->textnode->getTwineId()); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Tests that no hitches are present after the Textnode was constructed. |
|
146
|
|
|
*/ |
|
147
|
|
|
public function testGetChildHitchesCountAfterTextnodeConstruction() |
|
148
|
|
|
{ |
|
149
|
|
|
$this->assertCount(0, $this->textnode->getChildHitches()); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* tests the access |
|
154
|
|
|
*/ |
|
155
|
|
|
public function testGetArbitraryId() |
|
156
|
|
|
{ |
|
157
|
|
|
$this->textnode->setArbitraryId('foobarArbitraryId'); |
|
158
|
|
|
$this->assertEquals('foobarArbitraryId', $this->textnode->getArbitraryId()); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* tests the text |
|
163
|
|
|
* @return void |
|
164
|
|
|
*/ |
|
165
|
|
|
public function testTextHyphenated(): void |
|
166
|
|
|
{ |
|
167
|
|
|
$text = 'Lorem Ipsum'; |
|
168
|
|
|
$this->textnode->setTextHyphenated($text); |
|
169
|
|
|
$this->assertEquals($text, $this->textnode->getTextHyphenated()); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @return void |
|
174
|
|
|
*/ |
|
175
|
|
|
public function testIsFinanceNode(): void |
|
176
|
|
|
{ |
|
177
|
|
|
self::assertTrue($this->textnode->isFinanceNode()); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|