Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
44.44% |
8 / 18 |
|
16.67% |
2 / 12 |
CRAP | |
0.00% |
0 / 1 |
| MockPageConfig | |
44.44% |
8 / 18 |
|
16.67% |
2 / 12 |
36.69 | |
0.00% |
0 / 1 |
| __construct | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
1.00 | |||
| getContentModel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLinkTarget | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPageId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPageLanguageBcp47 | |
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 | |||
| 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\Bcp47Code\Bcp47Code; |
| 7 | use Wikimedia\Bcp47Code\Bcp47CodeValue; |
| 8 | use Wikimedia\Parsoid\Config\PageConfig; |
| 9 | use Wikimedia\Parsoid\Config\PageContent; |
| 10 | use Wikimedia\Parsoid\Config\SiteConfig; |
| 11 | use Wikimedia\Parsoid\Core\LinkTarget; |
| 12 | use Wikimedia\Parsoid\Utils\Title; |
| 13 | |
| 14 | class MockPageConfig extends PageConfig { |
| 15 | private SiteConfig $siteConfig; |
| 16 | |
| 17 | /** @var ?PageContent */ |
| 18 | private $content; |
| 19 | |
| 20 | /** @var int */ |
| 21 | private $pageid; |
| 22 | |
| 23 | private LinkTarget $title; |
| 24 | |
| 25 | private Bcp47Code $pagelanguage; |
| 26 | |
| 27 | /** @var ?string */ |
| 28 | private $pagelanguageDir; |
| 29 | |
| 30 | /** |
| 31 | * Construct a mock environment object for use in tests |
| 32 | * @param SiteConfig $siteConfig |
| 33 | * @param array $opts |
| 34 | * @param ?PageContent $content |
| 35 | */ |
| 36 | public function __construct( SiteConfig $siteConfig, array $opts, ?PageContent $content ) { |
| 37 | $this->siteConfig = $siteConfig; |
| 38 | $this->content = $content; |
| 39 | $this->title = $content?->getLinkTarget() ?? |
| 40 | Title::newFromText( $opts['title'] ?? 'TestPage', $siteConfig, $opts['pagens'] ?? null ); |
| 41 | $this->pageid = $opts['pageid'] ?? -1; |
| 42 | $this->pagelanguage = $opts['pageLanguage'] ?? new Bcp47CodeValue( 'en' ); |
| 43 | $this->pagelanguageDir = $opts['pageLanguageDir'] ?? null; |
| 44 | } |
| 45 | |
| 46 | /** @inheritDoc */ |
| 47 | public function getContentModel(): string { |
| 48 | return 'wikitext'; |
| 49 | } |
| 50 | |
| 51 | /** @inheritDoc */ |
| 52 | public function getLinkTarget(): LinkTarget { |
| 53 | return $this->title; |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | public function getPageId(): int { |
| 58 | return $this->pageid; |
| 59 | } |
| 60 | |
| 61 | /** @inheritDoc */ |
| 62 | public function getPageLanguageBcp47(): Bcp47Code { |
| 63 | return $this->pagelanguage; |
| 64 | } |
| 65 | |
| 66 | /** @inheritDoc */ |
| 67 | public function getPageLanguageDir(): string { |
| 68 | return $this->pagelanguageDir ?? 'rtl'; |
| 69 | } |
| 70 | |
| 71 | /** @inheritDoc */ |
| 72 | public function getRevisionId(): ?int { |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | /** @inheritDoc */ |
| 77 | public function getParentRevisionId(): ?int { |
| 78 | return null; |
| 79 | } |
| 80 | |
| 81 | /** @inheritDoc */ |
| 82 | public function getRevisionTimestamp(): ?string { |
| 83 | return null; |
| 84 | } |
| 85 | |
| 86 | /** @inheritDoc */ |
| 87 | public function getRevisionSha1(): ?string { |
| 88 | return null; |
| 89 | } |
| 90 | |
| 91 | /** @inheritDoc */ |
| 92 | public function getRevisionSize(): ?int { |
| 93 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
| 94 | throw new \BadMethodCallException( 'Not implemented' ); |
| 95 | } |
| 96 | |
| 97 | /** @inheritDoc */ |
| 98 | public function getRevisionContent(): ?PageContent { |
| 99 | return $this->content; |
| 100 | } |
| 101 | |
| 102 | } |