Merge "registration: Only allow one extension to set a specific config setting"
[lhc/web/wiklou.git] / tests / phpunit / mocks / content / DummyContentForTesting.php
1 <?php
2
3 class DummyContentForTesting extends AbstractContent {
4
5 const MODEL_ID = "testing";
6
7 public function __construct( $data ) {
8 parent::__construct( self::MODEL_ID );
9
10 $this->data = $data;
11 }
12
13 public function serialize( $format = null ) {
14 return serialize( $this->data );
15 }
16
17 /**
18 * @return string A string representing the content in a way useful for
19 * building a full text search index. If no useful representation exists,
20 * this method returns an empty string.
21 */
22 public function getTextForSearchIndex() {
23 return '';
24 }
25
26 /**
27 * @return string|bool The wikitext to include when another page includes this content,
28 * or false if the content is not includable in a wikitext page.
29 */
30 public function getWikitextForTransclusion() {
31 return false;
32 }
33
34 /**
35 * Returns a textual representation of the content suitable for use in edit
36 * summaries and log messages.
37 *
38 * @param int $maxlength Maximum length of the summary text.
39 * @return string The summary text.
40 */
41 public function getTextForSummary( $maxlength = 250 ) {
42 return '';
43 }
44
45 /**
46 * Returns native represenation of the data. Interpretation depends on the data model used,
47 * as given by getDataModel().
48 *
49 * @return mixed The native representation of the content. Could be a string, a nested array
50 * structure, an object, a binary blob... anything, really.
51 */
52 public function getNativeData() {
53 return $this->data;
54 }
55
56 /**
57 * returns the content's nominal size in bogo-bytes.
58 *
59 * @return int
60 */
61 public function getSize() {
62 return strlen( $this->data );
63 }
64
65 /**
66 * Return a copy of this Content object. The following must be true for the object returned
67 * if $copy = $original->copy()
68 *
69 * * get_class($original) === get_class($copy)
70 * * $original->getModel() === $copy->getModel()
71 * * $original->equals( $copy )
72 *
73 * If and only if the Content object is imutable, the copy() method can and should
74 * return $this. That is, $copy === $original may be true, but only for imutable content
75 * objects.
76 *
77 * @return Content A copy of this object
78 */
79 public function copy() {
80 return $this;
81 }
82
83 /**
84 * Returns true if this content is countable as a "real" wiki page, provided
85 * that it's also in a countable location (e.g. a current revision in the main namespace).
86 *
87 * @param bool|null $hasLinks If it is known whether this content contains links,
88 * provide this information here, to avoid redundant parsing to find out.
89 * @return bool
90 */
91 public function isCountable( $hasLinks = null ) {
92 return false;
93 }
94
95 /**
96 * @param Title $title
97 * @param int $revId Unused.
98 * @param null|ParserOptions $options
99 * @param bool $generateHtml Whether to generate Html (default: true). If false, the result
100 * of calling getText() on the ParserOutput object returned by this method is undefined.
101 *
102 * @return ParserOutput
103 */
104 public function getParserOutput( Title $title, $revId = null,
105 ParserOptions $options = null, $generateHtml = true
106 ) {
107 return new ParserOutput( $this->getNativeData() );
108 }
109
110 /**
111 * @see AbstractContent::fillParserOutput()
112 *
113 * @param Title $title Context title for parsing
114 * @param int|null $revId Revision ID (for {{REVISIONID}})
115 * @param ParserOptions $options Parser options
116 * @param bool $generateHtml Whether or not to generate HTML
117 * @param ParserOutput &$output The output object to fill (reference).
118 */
119 protected function fillParserOutput( Title $title, $revId,
120 ParserOptions $options, $generateHtml, ParserOutput &$output ) {
121 $output = new ParserOutput( $this->getNativeData() );
122 }
123 }