Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / mocks / content / DummyContentForTesting.php
blob323c6273781f258b1ab8f7284704aff4f9e2e422
1 <?php
3 use MediaWiki\Content\AbstractContent;
4 use MediaWiki\Content\Content;
6 class DummyContentForTesting extends AbstractContent {
8 public const MODEL_ID = "testing";
10 /** @var mixed */
11 private $data;
13 public function __construct( $data ) {
14 parent::__construct( self::MODEL_ID );
16 $this->data = $data;
19 public function serialize( $format = null ) {
20 return $this->data;
23 /**
24 * @return string A string representing the content in a way useful for
25 * building a full text search index. If no useful representation exists,
26 * this method returns an empty string.
28 public function getTextForSearchIndex() {
29 return '';
32 /**
33 * @return string|bool The wikitext to include when another page includes this content,
34 * or false if the content is not includable in a wikitext page.
36 public function getWikitextForTransclusion() {
37 return false;
40 /**
41 * Returns a textual representation of the content suitable for use in edit
42 * summaries and log messages.
44 * @param int $maxlength Maximum length of the summary text.
45 * @return string The summary text.
47 public function getTextForSummary( $maxlength = 250 ) {
48 return '';
51 /**
52 * Returns native representation of the data. Interpretation depends on the data model used,
53 * as given by getDataModel().
55 * @return mixed The native representation of the content. Could be a string, a nested array
56 * structure, an object, a binary blob... anything, really.
58 public function getNativeData() {
59 return $this->data;
62 /**
63 * returns the content's nominal size in bogo-bytes.
65 * @return int
67 public function getSize() {
68 return strlen( $this->data );
71 /**
72 * Return a copy of this Content object. The following must be true for the object returned
73 * if $copy = $original->copy()
75 * * get_class($original) === get_class($copy)
76 * * $original->getModel() === $copy->getModel()
77 * * $original->equals( $copy )
79 * If and only if the Content object is immutable, the copy() method can and should
80 * return $this. That is, $copy === $original may be true, but only for imutable content
81 * objects.
83 * @return Content A copy of this object
85 public function copy() {
86 return $this;
89 /**
90 * Returns true if this content is countable as a "real" wiki page, provided
91 * that it's also in a countable location (e.g. a current revision in the main namespace).
93 * @param bool|null $hasLinks If it is known whether this content contains links,
94 * provide this information here, to avoid redundant parsing to find out.
95 * @return bool
97 public function isCountable( $hasLinks = null ) {
98 return false;