1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (C) 2014 Michael Herold <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This program is free software; you can redistribute it and/or |
6
|
|
|
* modify it under the terms of the GNU General Public License |
7
|
|
|
* as published by the Free Software Foundation; either version 2 |
8
|
|
|
* of the License, or (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU General Public License |
16
|
|
|
* along with this program; if not, write to the Free Software |
17
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Description of AppendagesTest |
22
|
|
|
* |
23
|
|
|
* @author Michael Herold <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class AppendagesTest extends Helpers |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
View Code Duplication |
public function testBasic() |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$doc = new hemio\html\Document(new hemio\html\Str('')); |
31
|
|
|
$doc->addInheritableAppendage('axkdw_sda2', '-lsk3jfl#1-'); |
32
|
|
|
$div = new \hemio\html\Div; |
33
|
|
|
$doc->getHtml()->getBody()->addChild($div); |
34
|
|
|
|
35
|
|
|
$this->assertEquals('-lsk3jfl#1-', |
36
|
|
|
$div->getInheritableAppendage('axkdw_sda2')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
View Code Duplication |
public function testLateAdded() |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
$doc = new hemio\html\Document(new hemio\html\Str('')); |
42
|
|
|
$div = new \hemio\html\Div; |
43
|
|
|
$doc->getHtml()->getBody()->addChild($div); |
44
|
|
|
$doc->addInheritableAppendage('axkdw_sda2', '-lsk3jfl#1-'); |
45
|
|
|
|
46
|
|
|
$this->assertEquals('-lsk3jfl#1-', |
47
|
|
|
$div->getInheritableAppendage('axkdw_sda2')); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
View Code Duplication |
public function testBasicExisting() |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$doc = new hemio\html\Document(new hemio\html\Str('')); |
53
|
|
|
$doc->addInheritableAppendage('key', 'overwritten-value'); |
54
|
|
|
$div = new \hemio\html\Div; |
55
|
|
|
$div->addInheritableAppendage('key', 'existing-value'); |
56
|
|
|
$doc->getHtml()->getBody()->addChild($div); |
57
|
|
|
|
58
|
|
|
$this->assertEquals('existing-value', |
59
|
|
|
$div->getInheritableAppendage('key')); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
View Code Duplication |
public function testLateAddedExisting() |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
$doc = new hemio\html\Document(new hemio\html\Str('')); |
65
|
|
|
$div = new \hemio\html\Div; |
66
|
|
|
$div->addInheritableAppendage('key', 'existing-value'); |
67
|
|
|
$doc->getHtml()->getBody()->addChild($div); |
68
|
|
|
$doc->addInheritableAppendage('key', 'overwritten-value'); |
69
|
|
|
|
70
|
|
|
$this->assertEquals('existing-value', |
71
|
|
|
$div->getInheritableAppendage('key')); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.