Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
38.10% |
8 / 21 |
|
18.75% |
3 / 16 |
CRAP | |
0.00% |
0 / 1 |
MockPageConfig | |
38.10% |
8 / 21 |
|
18.75% |
3 / 16 |
76.73 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
getContentModel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
hasLintableContentModel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getNs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageLanguage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageLanguageDir | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getParentRevisionId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionTimestamp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionUserId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionSha1 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionSize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionContent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Mocks; |
5 | |
6 | use Wikimedia\Parsoid\Config\PageConfig; |
7 | use Wikimedia\Parsoid\Config\PageContent; |
8 | |
9 | class MockPageConfig extends PageConfig { |
10 | |
11 | /** @var ?PageContent */ |
12 | private $content; |
13 | |
14 | /** @var int */ |
15 | private $pageid; |
16 | |
17 | /** @var int */ |
18 | private $pagens; |
19 | |
20 | /** @var string */ |
21 | private $title; |
22 | |
23 | /** @var ?string */ |
24 | private $pagelanguage; |
25 | |
26 | /** @var ?string */ |
27 | private $pagelanguageDir; |
28 | |
29 | /** |
30 | * Construct a mock environment object for use in tests |
31 | * @param array $opts |
32 | * @param ?PageContent $content |
33 | */ |
34 | public function __construct( array $opts, ?PageContent $content ) { |
35 | $this->content = $content; |
36 | $this->title = $opts['title'] ?? 'TestPage'; |
37 | $this->pageid = $opts['pageid'] ?? -1; |
38 | $this->pagens = $opts['pagens'] ?? 0; |
39 | $this->pagelanguage = $opts['pageLanguage'] ?? null; |
40 | $this->pagelanguageDir = $opts['pageLanguageDir'] ?? null; |
41 | } |
42 | |
43 | /** @inheritDoc */ |
44 | public function getContentModel(): string { |
45 | return 'wikitext'; |
46 | } |
47 | |
48 | public function hasLintableContentModel(): bool { |
49 | return true; |
50 | } |
51 | |
52 | /** @inheritDoc */ |
53 | public function getTitle(): string { |
54 | return $this->title; |
55 | } |
56 | |
57 | /** @inheritDoc */ |
58 | public function getNs(): int { |
59 | return $this->pagens; |
60 | } |
61 | |
62 | /** @inheritDoc */ |
63 | public function getPageId(): int { |
64 | return $this->pageid; |
65 | } |
66 | |
67 | /** @inheritDoc */ |
68 | public function getPageLanguage(): string { |
69 | return $this->pagelanguage ?? 'en'; |
70 | } |
71 | |
72 | /** @inheritDoc */ |
73 | public function getPageLanguageDir(): string { |
74 | return $this->pagelanguageDir ?? 'rtl'; |
75 | } |
76 | |
77 | /** @inheritDoc */ |
78 | public function getRevisionId(): ?int { |
79 | return 1; |
80 | } |
81 | |
82 | /** @inheritDoc */ |
83 | public function getParentRevisionId(): ?int { |
84 | return null; |
85 | } |
86 | |
87 | /** @inheritDoc */ |
88 | public function getRevisionTimestamp(): ?string { |
89 | return null; |
90 | } |
91 | |
92 | /** @inheritDoc */ |
93 | public function getRevisionUser(): ?string { |
94 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
95 | throw new \BadMethodCallException( 'Not implemented' ); |
96 | } |
97 | |
98 | /** @inheritDoc */ |
99 | public function getRevisionUserId(): ?int { |
100 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
101 | throw new \BadMethodCallException( 'Not implemented' ); |
102 | } |
103 | |
104 | /** @inheritDoc */ |
105 | public function getRevisionSha1(): ?string { |
106 | return null; |
107 | } |
108 | |
109 | /** @inheritDoc */ |
110 | public function getRevisionSize(): ?int { |
111 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
112 | throw new \BadMethodCallException( 'Not implemented' ); |
113 | } |
114 | |
115 | /** @inheritDoc */ |
116 | public function getRevisionContent(): ?PageContent { |
117 | return $this->content; |
118 | } |
119 | |
120 | } |