78d5dc7b28808fbab2cd3442336c5b961401ab41
[lhc/web/wiklou.git] / tests / phpunit / mocks / content / DummyContentHandlerForTesting.php
1 <?php
2
3 class DummyContentHandlerForTesting extends ContentHandler {
4
5 public function __construct( $dataModel ) {
6 parent::__construct( $dataModel, [ DummyContentForTesting::MODEL_ID ] );
7 }
8
9 /**
10 * @see ContentHandler::serializeContent
11 *
12 * @param Content $content
13 * @param string $format
14 *
15 * @return string
16 */
17 public function serializeContent( Content $content, $format = null ) {
18 return $content->serialize();
19 }
20
21 /**
22 * @see ContentHandler::unserializeContent
23 *
24 * @param string $blob
25 * @param string $format Unused.
26 *
27 * @return Content
28 */
29 public function unserializeContent( $blob, $format = null ) {
30 $d = unserialize( $blob );
31
32 return new DummyContentForTesting( $d );
33 }
34
35 /**
36 * Creates an empty Content object of the type supported by this ContentHandler.
37 * @return DummyContentForTesting
38 */
39 public function makeEmptyContent() {
40 return new DummyContentForTesting( '' );
41 }
42 }