Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
47.06% |
8 / 17 |
|
25.00% |
3 / 12 |
CRAP | |
0.00% |
0 / 1 |
| MockPageConfig | |
47.06% |
8 / 17 |
|
25.00% |
3 / 12 |
33.37 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 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\Parsoid\Config\PageConfig; |
| 8 | use Wikimedia\Parsoid\Config\PageContent; |
| 9 | use Wikimedia\Parsoid\Config\SiteConfig; |
| 10 | use Wikimedia\Parsoid\Core\LinkTarget; |
| 11 | use Wikimedia\Parsoid\Utils\Title; |
| 12 | use Wikimedia\Parsoid\Utils\Utils; |
| 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 Title $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 = Title::newFromText( $opts['title'] ?? 'TestPage', $siteConfig, $opts['pagens'] ?? null ); |
| 40 | $this->pageid = $opts['pageid'] ?? -1; |
| 41 | $this->pagelanguage = Utils::mwCodeToBcp47( $opts['pageLanguage'] ?? 'en' ); |
| 42 | $this->pagelanguageDir = $opts['pageLanguageDir'] ?? null; |
| 43 | } |
| 44 | |
| 45 | /** @inheritDoc */ |
| 46 | public function getContentModel(): string { |
| 47 | return 'wikitext'; |
| 48 | } |
| 49 | |
| 50 | /** @inheritDoc */ |
| 51 | public function getLinkTarget(): LinkTarget { |
| 52 | return $this->title; |
| 53 | } |
| 54 | |
| 55 | /** @inheritDoc */ |
| 56 | public function getPageId(): int { |
| 57 | return $this->pageid; |
| 58 | } |
| 59 | |
| 60 | /** @inheritDoc */ |
| 61 | public function getPageLanguageBcp47(): Bcp47Code { |
| 62 | return $this->pagelanguage; |
| 63 | } |
| 64 | |
| 65 | /** @inheritDoc */ |
| 66 | public function getPageLanguageDir(): string { |
| 67 | return $this->pagelanguageDir ?? 'rtl'; |
| 68 | } |
| 69 | |
| 70 | /** @inheritDoc */ |
| 71 | public function getRevisionId(): ?int { |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | /** @inheritDoc */ |
| 76 | public function getParentRevisionId(): ?int { |
| 77 | return null; |
| 78 | } |
| 79 | |
| 80 | /** @inheritDoc */ |
| 81 | public function getRevisionTimestamp(): ?string { |
| 82 | return null; |
| 83 | } |
| 84 | |
| 85 | /** @inheritDoc */ |
| 86 | public function getRevisionSha1(): ?string { |
| 87 | return null; |
| 88 | } |
| 89 | |
| 90 | /** @inheritDoc */ |
| 91 | public function getRevisionSize(): ?int { |
| 92 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
| 93 | throw new \BadMethodCallException( 'Not implemented' ); |
| 94 | } |
| 95 | |
| 96 | /** @inheritDoc */ |
| 97 | public function getRevisionContent(): ?PageContent { |
| 98 | return $this->content; |
| 99 | } |
| 100 | |
| 101 | } |