1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* micrometa |
5
|
|
|
* |
6
|
|
|
* @category Jkphl |
7
|
|
|
* @package Jkphl\Micrometa |
8
|
|
|
* @subpackage Infrastructure |
9
|
|
|
* @author Joschi Kuphal <[email protected]> / @jkphl |
10
|
|
|
* @copyright Copyright © 2017 Joschi Kuphal <[email protected]> / @jkphl |
11
|
|
|
* @license http://opensource.org/licenses/MIT The MIT License (MIT) |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
/*********************************************************************************** |
15
|
|
|
* The MIT License (MIT) |
16
|
|
|
* |
17
|
|
|
* Copyright © 2017 Joschi Kuphal <[email protected]> / @jkphl |
18
|
|
|
* |
19
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
20
|
|
|
* this software and associated documentation files (the "Software"), to deal in |
21
|
|
|
* the Software without restriction, including without limitation the rights to |
22
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
23
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so, |
24
|
|
|
* subject to the following conditions: |
25
|
|
|
* |
26
|
|
|
* The above copyright notice and this permission notice shall be included in all |
27
|
|
|
* copies or substantial portions of the Software. |
28
|
|
|
* |
29
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
30
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
31
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
32
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
33
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
34
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
35
|
|
|
***********************************************************************************/ |
36
|
|
|
|
37
|
|
|
namespace Jkphl\Micrometa\Tests\Ports; |
38
|
|
|
|
39
|
|
|
use Jkphl\Micrometa\Application\Item\Item as ApplicationItem; |
40
|
|
|
use Jkphl\Micrometa\Application\Value\StringValue; |
41
|
|
|
use Jkphl\Micrometa\Infrastructure\Factory\MicroformatsFactory; |
42
|
|
|
use Jkphl\Micrometa\Infrastructure\Parser\Microformats; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Parser factory tests |
46
|
|
|
* |
47
|
|
|
* @package Jkphl\Micrometa |
48
|
|
|
* @subpackage Jkphl\Micrometa\Tests |
49
|
|
|
*/ |
50
|
|
|
class ItemTest extends \PHPUnit_Framework_TestCase |
51
|
|
|
{ |
52
|
|
|
/** |
53
|
|
|
* Test an item |
54
|
|
|
*/ |
55
|
|
|
public function testItem() |
56
|
|
|
{ |
57
|
|
|
$authorItem = new ApplicationItem( |
58
|
|
|
Microformats::FORMAT, |
59
|
|
|
(object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-card'], |
60
|
|
|
[ |
61
|
|
|
(object)[ |
62
|
|
|
'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
63
|
|
|
'name' => 'p-name', |
64
|
|
|
'values' => [ |
65
|
|
|
new StringValue('John Doe') |
66
|
|
|
] |
67
|
|
|
], |
68
|
|
|
(object)[ |
69
|
|
|
'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
70
|
|
|
'name' => 'u-email', |
71
|
|
|
'values' => [ |
72
|
|
|
new StringValue('[email protected]') |
73
|
|
|
] |
74
|
|
|
] |
75
|
|
|
] |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
$entryItem = new ApplicationItem( |
80
|
|
|
Microformats::FORMAT, |
81
|
|
|
(object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-entry'], |
82
|
|
|
[ |
83
|
|
|
(object)[ |
84
|
|
|
'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
85
|
|
|
'name' => 'p-name', |
86
|
|
|
'values' => [ |
87
|
|
|
new StringValue('Famous blog post') |
88
|
|
|
] |
89
|
|
|
], |
90
|
|
|
(object)[ |
91
|
|
|
'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
92
|
|
|
'name' => 'p-author', |
93
|
|
|
'values' => [ |
94
|
|
|
$authorItem |
95
|
|
|
] |
96
|
|
|
] |
97
|
|
|
] |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
$feedItem = new ApplicationItem( |
|
|
|
|
102
|
|
|
Microformats::FORMAT, |
103
|
|
|
(object)['profile' => MicroformatsFactory::MF2_PROFILE_URI, 'name' => 'h-feed'], |
104
|
|
|
[ |
105
|
|
|
(object)[ |
106
|
|
|
'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
107
|
|
|
'name' => 'p-name', |
108
|
|
|
'values' => [ |
109
|
|
|
new StringValue('John Doe\'s Blog') |
110
|
|
|
] |
111
|
|
|
], |
112
|
|
|
(object)[ |
113
|
|
|
'profile' => MicroformatsFactory::MF2_PROFILE_URI, |
114
|
|
|
'name' => 'p-author', |
115
|
|
|
'values' => [ |
116
|
|
|
$authorItem |
117
|
|
|
] |
118
|
|
|
] |
119
|
|
|
], |
120
|
|
|
[$entryItem, $entryItem] |
121
|
|
|
); |
122
|
|
|
|
123
|
|
|
// print_r($feedItem); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.