MediaWiki REL1_32
StaticArrayWriterTest.php
Go to the documentation of this file.
1<?php
22
26class StaticArrayWriterTest extends PHPUnit\Framework\TestCase {
27 public function testCreate() {
28 $data = [
29 'foo' => 'bar',
30 'baz' => 'rawr',
31 "they're" => '"quoted properly"',
32 'nested' => [ 'elements', 'work' ],
33 'and' => [ 'these' => 'do too' ],
34 ];
35 $writer = new StaticArrayWriter();
36 $actual = $writer->create( $data, "Header\nWith\nNewlines" );
37 $expected = <<<PHP
38<?php
39// Header
40// With
41// Newlines
42return [
43 'foo' => 'bar',
44 'baz' => 'rawr',
45 'they\'re' => '"quoted properly"',
46 'nested' => [
47 0 => 'elements',
48 1 => 'work',
49 ],
50 'and' => [
51 'these' => 'do too',
52 ],
53];
54
55PHP;
56 $this->assertSame( $expected, $actual );
57 }
58}
\Wikimedia\StaticArrayWriter
Format a static PHP array to be written to a file.
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *json simple implementation for use by etc *css user provided css code *text plain text In PHP