|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP version 7.1 |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the license that is bundled with this package in the file LICENSE. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class PhUmlStatisticsOptionTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** @test */ |
|
13
|
|
View Code Duplication |
function it_shows_the_statistics_of_a_directory() |
|
|
|
|
|
|
14
|
|
|
{ |
|
15
|
|
|
$statistics = <<<STATS |
|
16
|
|
|
Phuml generated statistics |
|
17
|
|
|
========================== |
|
18
|
|
|
|
|
19
|
|
|
General statistics |
|
20
|
|
|
------------------ |
|
21
|
|
|
|
|
22
|
|
|
Classes: 2 |
|
23
|
|
|
Interfaces: 0 |
|
24
|
|
|
|
|
25
|
|
|
Attributes: 3 (0 are typed) |
|
26
|
|
|
* private: 3 |
|
27
|
|
|
* protected: 0 |
|
28
|
|
|
* public: 0 |
|
29
|
|
|
|
|
30
|
|
|
Functions: 11 |
|
31
|
|
|
* private: 1 |
|
32
|
|
|
* protected: 0 |
|
33
|
|
|
* public: 10 |
|
34
|
|
|
|
|
35
|
|
|
Average statistics |
|
36
|
|
|
------------------ |
|
37
|
|
|
|
|
38
|
|
|
Attributes per class: 1.5 |
|
39
|
|
|
Functions per class: 5.5 |
|
40
|
|
|
|
|
41
|
|
|
STATS; |
|
42
|
|
|
$output = <<<OUTPUT |
|
43
|
|
|
phUML Version 0.2 (Jakob Westhoff <[email protected]>) |
|
44
|
|
|
[|] Running... (This may take some time) |
|
45
|
|
|
[|] Parsing class structure |
|
46
|
|
|
[|] Running 'Statistics' processor |
|
47
|
|
|
[|] Writing generated data to disk |
|
48
|
|
|
|
|
49
|
|
|
OUTPUT; |
|
50
|
|
|
$file = __DIR__ . '/../../tests/.output/statistics.txt'; |
|
51
|
|
|
|
|
52
|
|
|
passthru(sprintf( |
|
53
|
|
|
'php %s %s -statistics %s', |
|
54
|
|
|
__DIR__ . '/../../src/app/phuml', |
|
55
|
|
|
__DIR__ . '/../.code/classes', |
|
56
|
|
|
$file |
|
57
|
|
|
)); |
|
58
|
|
|
|
|
59
|
|
|
$this->expectOutputString($output); |
|
60
|
|
|
$this->assertStringEqualsFile($file, $statistics); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** @test */ |
|
64
|
|
View Code Duplication |
function it_accepts_the_recursive_options_for_the_statistics_processor() |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
$statistics = <<<STATS |
|
67
|
|
|
Phuml generated statistics |
|
68
|
|
|
========================== |
|
69
|
|
|
|
|
70
|
|
|
General statistics |
|
71
|
|
|
------------------ |
|
72
|
|
|
|
|
73
|
|
|
Classes: 19 |
|
74
|
|
|
Interfaces: 0 |
|
75
|
|
|
|
|
76
|
|
|
Attributes: 21 (0 are typed) |
|
77
|
|
|
* private: 16 |
|
78
|
|
|
* protected: 1 |
|
79
|
|
|
* public: 4 |
|
80
|
|
|
|
|
81
|
|
|
Functions: 86 |
|
82
|
|
|
* private: 36 |
|
83
|
|
|
* protected: 0 |
|
84
|
|
|
* public: 50 |
|
85
|
|
|
|
|
86
|
|
|
Average statistics |
|
87
|
|
|
------------------ |
|
88
|
|
|
|
|
89
|
|
|
Attributes per class: 1.11 |
|
90
|
|
|
Functions per class: 4.53 |
|
91
|
|
|
|
|
92
|
|
|
STATS; |
|
93
|
|
|
$output = <<<OUTPUT |
|
94
|
|
|
phUML Version 0.2 (Jakob Westhoff <[email protected]>) |
|
95
|
|
|
[|] Running... (This may take some time) |
|
96
|
|
|
[|] Parsing class structure |
|
97
|
|
|
[|] Running 'Statistics' processor |
|
98
|
|
|
[|] Writing generated data to disk |
|
99
|
|
|
|
|
100
|
|
|
OUTPUT; |
|
101
|
|
|
$file = __DIR__ . '/../../tests/.output/statistics.txt'; |
|
102
|
|
|
|
|
103
|
|
|
passthru(sprintf( |
|
104
|
|
|
'php %s -r %s -statistics %s', |
|
105
|
|
|
__DIR__ . '/../../src/app/phuml', |
|
106
|
|
|
__DIR__ . '/../.code/classes', |
|
107
|
|
|
$file |
|
108
|
|
|
)); |
|
109
|
|
|
|
|
110
|
|
|
$this->expectOutputString($output); |
|
111
|
|
|
$this->assertStringEqualsFile($file, $statistics); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.