3 use Wikimedia\TestingAccessWrapper;
11 $this->assertSame( $msg->getKey(), $msg2->getKey(),
'getKey' );
12 $this->assertSame( $msg->getKeysToTry(), $msg2->getKeysToTry(),
'getKeysToTry' );
13 $this->assertSame( $msg->getParams(), $msg2->getParams(),
'getParams' );
14 $this->assertSame( $msg->getLanguage(), $msg2->getLanguage(),
'getLanguage' );
16 $msg = TestingAccessWrapper::newFromObject( $msg );
17 $msg2 = TestingAccessWrapper::newFromObject( $msg2 );
18 $this->assertSame( $msg->interface, $msg2->interface,
'interface' );
19 $this->assertSame( $msg->useDatabase, $msg2->useDatabase,
'useDatabase' );
20 $this->assertSame( $msg->format, $msg2->format,
'format' );
22 $msg->title ? $msg->title->getFullText() :
null,
23 $msg2->title ? $msg2->title->getFullText() :
null,
33 $this->assertSame(
'foo', $msg->getApiCode() );
36 $this->assertSame(
'bar', $msg->getApiCode() );
39 $this->assertSame(
'baz', $msg->getApiCode() );
42 $msg =
new ApiMessage(
'actionthrottledtext' );
43 $this->assertSame(
'ratelimited', $msg->getApiCode() );
45 $msg =
new ApiMessage( [
'apierror-missingparam',
'param' ] );
46 $this->assertSame(
'noparam', $msg->getApiCode() );
57 $msg->setApiCode(
$code );
58 $this->fail(
'Expected exception not thrown' );
59 }
catch ( InvalidArgumentException $ex ) {
60 $this->assertTrue(
true );
65 $this->fail(
'Expected exception not thrown' );
66 }
catch ( InvalidArgumentException $ex ) {
67 $this->assertTrue(
true );
83 $msg =
new Message( [
'foo',
'bar' ], [
'baz' ] );
85 $msg2 =
new ApiMessage( $msg,
'code', [
'data' ] );
87 $this->assertEquals(
'code', $msg2->getApiCode() );
88 $this->assertEquals( [
'data' ], $msg2->getApiData() );
92 $this->assertEquals(
'code', $msg2->getApiCode() );
93 $this->assertEquals( [
'data' ], $msg2->getApiData() );
95 $msg =
new Message( [
'foo',
'bar' ], [
'baz' ] );
96 $msg2 =
new ApiMessage( [ [
'foo',
'bar' ],
'baz' ],
'code', [
'data' ] );
98 $this->assertEquals(
'code', $msg2->getApiCode() );
99 $this->assertEquals( [
'data' ], $msg2->getApiData() );
101 $msg =
new Message(
'foo' );
104 $this->assertEquals(
'foo', $msg2->getApiCode() );
105 $this->assertEquals( [], $msg2->getApiData() );
107 $msg2->setApiCode(
'code', [
'data' ] );
108 $this->assertEquals(
'code', $msg2->getApiCode() );
109 $this->assertEquals( [
'data' ], $msg2->getApiData() );
110 $msg2->setApiCode(
null );
111 $this->assertEquals(
'foo', $msg2->getApiCode() );
112 $this->assertEquals( [
'data' ], $msg2->getApiData() );
113 $msg2->setApiData( [
'data2' ] );
114 $this->assertEquals( [
'data2' ], $msg2->getApiData() );
126 $this->assertEquals(
'code', $msg2->getApiCode() );
127 $this->assertEquals( [
'data' ], $msg2->getApiData() );
131 $this->assertEquals(
'code', $msg2->getApiCode() );
132 $this->assertEquals( [
'data' ], $msg2->getApiData() );
135 $msg2 =
new ApiRawMessage( [
'foo',
'baz' ],
'code', [
'data' ] );
137 $this->assertEquals(
'code', $msg2->getApiCode() );
138 $this->assertEquals( [
'data' ], $msg2->getApiData() );
143 $this->assertEquals(
'code', $msg2->getApiCode() );
144 $this->assertEquals( [
'data' ], $msg2->getApiData() );
146 $msg2->setApiCode(
'code', [
'data' ] );
147 $this->assertEquals(
'code', $msg2->getApiCode() );
148 $this->assertEquals( [
'data' ], $msg2->getApiData() );
149 $msg2->setApiCode(
null );
150 $this->assertEquals(
'foo', $msg2->getApiCode() );
151 $this->assertEquals( [
'data' ], $msg2->getApiData() );
152 $msg2->setApiData( [
'data2' ] );
153 $this->assertEquals( [
'data2' ], $msg2->getApiData() );
161 $this->assertInstanceOf(
166 $msg =
new ApiMessage( [
'parentheses',
'foobar' ] );
167 $msg2 =
new Message(
'parentheses', [
'foobar' ] );
172 $this->assertEquals( $msg,
175 $this->assertSame( $msg,
178 $this->assertEquals( $msg,
181 $this->assertSame( $msg,