Skip to content

Commit 05059ff

Browse files
committed
CS fixed
1 parent e073c2c commit 05059ff

20 files changed

+169
-96
lines changed

tests/Map/TestHrefLang.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class TestHrefLang extends MslsUnitTestCase {
1414

1515
protected function setUp(): void {
16-
parent::setUp();
16+
parent::setUp();
1717

1818
$map = [
1919
'de_DE' => 'de',
@@ -53,7 +53,7 @@ public function test_get(): void {
5353

5454
public function test_get_has_filter(): void {
5555
Functions\when( 'has_filter' )->justReturn( true );
56-
Filters\expectApplied('msls_head_hreflang')->once()->with( 'en_US')->andReturn( 'en-US' );
56+
Filters\expectApplied( 'msls_head_hreflang' )->once()->with( 'en_US' )->andReturn( 'en-US' );
5757

5858
$this->assertEquals( 'en-US', $this->test->get( 'en_US' ) );
5959
}

tests/TestMslsAdmin.php

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class TestMslsAdmin extends MslsUnitTestCase {
1313

14-
public function get_sut( array $users = [] ): MslsAdmin {
14+
public function get_sut( array $users = [] ): MslsAdmin {
1515
Functions\when( 'get_option' )->justReturn( [] );
1616
Functions\when( 'update_option' )->justReturn( true );
1717
Functions\when( 'get_current_blog_id' )->justReturn( 1 );
@@ -103,7 +103,10 @@ public function test_has_problems_is_empty(): void {
103103
public function test_subsubsub(): void {
104104
$obj = $this->get_sut();
105105

106-
$this->assertEquals( '<ul class="subsubsub"><li><a href="wp-admin" class="current">abc (DEF)</a> | </li><li><a href="wp-admin">uvw (XYZ)</a></li></ul>', $obj->subsubsub() );
106+
$this->assertEquals(
107+
'<ul class="subsubsub"><li><a href="wp-admin" class="current">abc (DEF)</a> | </li><li><a href="wp-admin">uvw (XYZ)</a></li></ul>',
108+
$obj->subsubsub()
109+
);
107110
}
108111

109112
public function test_blog_language(): void {
@@ -116,25 +119,29 @@ public function test_blog_language(): void {
116119
public function test_display(): void {
117120
$obj = $this->get_sut();
118121

119-
$this->expectOutputString( '<select id="display" name="msls[display]"><option value="0" >Flag and description</option><option value="1" >Description only</option><option value="2" >Flag only</option><option value="3" >Description and flag</option></select>' );
122+
$this->expectOutputString(
123+
'<select id="display" name="msls[display]"><option value="0" >Flag and description</option><option value="1" >Description only</option><option value="2" >Flag only</option><option value="3" >Description and flag</option></select>'
124+
);
120125
$obj->display();
121126
}
122127

123128
public function test_admin_display(): void {
124129
$obj = $this->get_sut();
125130

126-
$this->expectOutputString( '<select id="admin_display" name="msls[admin_display]"><option value="flag" >Flag</option><option value="label" >Label</option></select>' );
131+
$this->expectOutputString(
132+
'<select id="admin_display" name="msls[admin_display]"><option value="flag" >Flag</option><option value="label" >Label</option></select>'
133+
);
127134
$obj->admin_display();
128135
}
129136

130137
public function test_reference_user(): void {
131-
$users = [];
138+
$users = [];
132139
$too_much = MslsAdmin::MAX_REFERENCE_USERS + 1;
133-
for( $i = 1; $i <= $too_much; $i++ ) {
140+
for ( $i = 1; $i <= $too_much; $i ++ ) {
134141
$users[] = (object) [ 'ID' => $i, 'user_nicename' => 'realloc' ];
135142
}
136143

137-
$obj = $this->get_sut( $users );
144+
$obj = $this->get_sut( $users );
138145

139146
set_error_handler(
140147
static function ( $errno, $errstr ) {
@@ -145,7 +152,9 @@ static function ( $errno, $errstr ) {
145152
);
146153

147154
$this->expectException( \Exception::class );
148-
$this->expectExceptionMessage( 'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of 100 users. Please, use the hook "msls_reference_users" to filter the result before!' );
155+
$this->expectExceptionMessage(
156+
'Multisite Language Switcher: Collection for reference user has been truncated because it exceeded the maximum of 100 users. Please, use the hook "msls_reference_users" to filter the result before!'
157+
);
149158

150159
$obj->reference_user();
151160
}
@@ -160,71 +169,91 @@ public function test_reference_user_over_max(): void {
160169
public function test_activate_autocomplete(): void {
161170
$obj = $this->get_sut();
162171

163-
$this->expectOutputString( '<input type="checkbox" id="activate_autocomplete" name="msls[activate_autocomplete]" value="1" /> <label for="activate_autocomplete">Activate experimental autocomplete inputs</label>' );
172+
$this->expectOutputString(
173+
'<input type="checkbox" id="activate_autocomplete" name="msls[activate_autocomplete]" value="1" /> <label for="activate_autocomplete">Activate experimental autocomplete inputs</label>'
174+
);
164175
$obj->activate_autocomplete();
165176
}
166177

167178
public function test_sort_by_description(): void {
168179
$obj = $this->get_sut();
169180

170-
$this->expectOutputString( '<input type="checkbox" id="sort_by_description" name="msls[sort_by_description]" value="1" /> <label for="sort_by_description">Sort languages by description</label>' );
181+
$this->expectOutputString(
182+
'<input type="checkbox" id="sort_by_description" name="msls[sort_by_description]" value="1" /> <label for="sort_by_description">Sort languages by description</label>'
183+
);
171184
$obj->sort_by_description();
172185
}
173186

174187

175188
public function test_exclude_current_blog(): void {
176189
$obj = $this->get_sut();
177190

178-
$this->expectOutputString( '<input type="checkbox" id="exclude_current_blog" name="msls[exclude_current_blog]" value="1" /> <label for="exclude_current_blog">Exclude this blog from output</label>' );
191+
$this->expectOutputString(
192+
'<input type="checkbox" id="exclude_current_blog" name="msls[exclude_current_blog]" value="1" /> <label for="exclude_current_blog">Exclude this blog from output</label>'
193+
);
179194
$obj->exclude_current_blog();
180195
}
181196

182197
function test_only_with_translation(): void {
183198
$obj = $this->get_sut();
184199

185-
$this->expectOutputString( '<input type="checkbox" id="only_with_translation" name="msls[only_with_translation]" value="1" /> <label for="only_with_translation">Show only links with a translation</label>' );
200+
$this->expectOutputString(
201+
'<input type="checkbox" id="only_with_translation" name="msls[only_with_translation]" value="1" /> <label for="only_with_translation">Show only links with a translation</label>'
202+
);
186203
$obj->only_with_translation();
187204
}
188205

189206
function test_output_current_blog(): void {
190207
$obj = $this->get_sut();
191208

192-
$this->expectOutputString( '<input type="checkbox" id="output_current_blog" name="msls[output_current_blog]" value="1" /> <label for="output_current_blog">Display link to the current language</label>' );
209+
$this->expectOutputString(
210+
'<input type="checkbox" id="output_current_blog" name="msls[output_current_blog]" value="1" /> <label for="output_current_blog">Display link to the current language</label>'
211+
);
193212
$obj->output_current_blog();
194213
}
195214

196215
function test_description(): void {
197216
$obj = $this->get_sut();
198217

199-
$this->expectOutputString( '<input type="text" class="regular-text" id="description" name="msls[description]" value="" size="40"/>' );
218+
$this->expectOutputString(
219+
'<input type="text" class="regular-text" id="description" name="msls[description]" value="" size="40"/>'
220+
);
200221
$obj->description();
201222
}
202223

203224
function test_before_output(): void {
204225
$obj = $this->get_sut();
205226

206-
$this->expectOutputString( '<input type="text" class="regular-text" id="before_output" name="msls[before_output]" value="" size="30"/>' );
227+
$this->expectOutputString(
228+
'<input type="text" class="regular-text" id="before_output" name="msls[before_output]" value="" size="30"/>'
229+
);
207230
$obj->before_output();
208231
}
209232

210233
function test_after_output(): void {
211234
$obj = $this->get_sut();
212235

213-
$this->expectOutputString( '<input type="text" class="regular-text" id="after_output" name="msls[after_output]" value="" size="30"/>' );
236+
$this->expectOutputString(
237+
'<input type="text" class="regular-text" id="after_output" name="msls[after_output]" value="" size="30"/>'
238+
);
214239
$obj->after_output();
215240
}
216241

217242
function test_before_item(): void {
218243
$obj = $this->get_sut();
219244

220-
$this->expectOutputString( '<input type="text" class="regular-text" id="before_item" name="msls[before_item]" value="" size="30"/>' );
245+
$this->expectOutputString(
246+
'<input type="text" class="regular-text" id="before_item" name="msls[before_item]" value="" size="30"/>'
247+
);
221248
$obj->before_item();
222249
}
223250

224251
function test_after_item(): void {
225252
$obj = $this->get_sut();
226253

227-
$this->expectOutputString( '<input type="text" class="regular-text" id="after_item" name="msls[after_item]" value="" size="30"/>' );
254+
$this->expectOutputString(
255+
'<input type="text" class="regular-text" id="after_item" name="msls[after_item]" value="" size="30"/>'
256+
);
228257
$obj->after_item();
229258
}
230259

@@ -236,7 +265,9 @@ function test_rewrite_tizio(): void {
236265

237266
Functions\when( 'get_post_type_object' )->justReturn( $post_type );
238267

239-
$this->expectOutputString( '<input type="text" class="regular-text" id="rewrite_tizio" name="msls[rewrite_tizio]" value="" size="30" readonly="readonly"/>' );
268+
$this->expectOutputString(
269+
'<input type="text" class="regular-text" id="rewrite_tizio" name="msls[rewrite_tizio]" value="" size="30" readonly="readonly"/>'
270+
);
240271
$obj->rewrite_tizio( 'tizio' );
241272
}
242273

@@ -248,7 +279,9 @@ function test_rewrite_pinko(): void {
248279

249280
Functions\when( 'get_post_type_object' )->justReturn( $post_type );
250281

251-
$this->expectOutputString( '<input type="text" class="regular-text" id="rewrite_pinko" name="msls[rewrite_pinko]" value="pinko" size="30" readonly="readonly"/>' );
282+
$this->expectOutputString(
283+
'<input type="text" class="regular-text" id="rewrite_pinko" name="msls[rewrite_pinko]" value="pinko" size="30" readonly="readonly"/>'
284+
);
252285
$obj->rewrite_pinko( 'pinko' );
253286
}
254287

@@ -260,14 +293,18 @@ function test_rewrite_pallino(): void {
260293

261294
Functions\when( 'get_post_type_object' )->justReturn( $post_type );
262295

263-
$this->expectOutputString( '<input type="text" class="regular-text" id="rewrite_pallino" name="msls[rewrite_pallino]" value="pallino_slug" size="30" readonly="readonly"/>' );
296+
$this->expectOutputString(
297+
'<input type="text" class="regular-text" id="rewrite_pallino" name="msls[rewrite_pallino]" value="pallino_slug" size="30" readonly="readonly"/>'
298+
);
264299
$obj->rewrite_pallino( 'pallino' );
265300
}
266301

267302
function test_content_filter(): void {
268303
$obj = $this->get_sut();
269304

270-
$this->expectOutputString( '<input type="checkbox" id="content_filter" name="msls[content_filter]" value="1" /> <label for="content_filter">Add hint for available translations</label>' );
305+
$this->expectOutputString(
306+
'<input type="checkbox" id="content_filter" name="msls[content_filter]" value="1" /> <label for="content_filter">Add hint for available translations</label>'
307+
);
271308
$obj->content_filter();
272309
}
273310

@@ -300,7 +337,9 @@ function test_render(): void {
300337
Functions\when( 'settings_fields' )->returnArg();
301338
Functions\when( 'do_settings_sections' )->returnArg();
302339

303-
$this->expectOutputRegex( '/^<div class="wrap"><div class="icon32" id="icon-options-general"><br\/><\/div><h1>Multisite Language Switcher Options<\/h1>.*$/' );
340+
$this->expectOutputRegex(
341+
'/^<div class="wrap"><div class="icon32" id="icon-options-general"><br\/><\/div><h1>Multisite Language Switcher Options<\/h1>.*$/'
342+
);
304343
$obj->render();
305344
}
306345

tests/TestMslsAdminIcon.php

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ public function get_test( $post ): MslsAdminIcon {
2222
}
2323

2424
public function get_post( $post_type, $id = 0 ): \WP_Post {
25-
$post = \Mockery::mock( '\WP_Post' );
26-
$post->ID = $id;
27-
$post->post_type = $post_type;
25+
$post = \Mockery::mock( '\WP_Post' );
26+
$post->ID = $id;
27+
$post->post_type = $post_type;
2828
$post->post_author = $this->get_user();
2929

3030
return $post;
3131
}
3232

3333
public function get_user(): \WP_User {
34-
$user = \Mockery::mock( '\WP_User' );
34+
$user = \Mockery::mock( '\WP_User' );
3535
$user->ID = 1;
3636
$user->role = 'editor';
3737

@@ -40,8 +40,16 @@ public function get_user(): \WP_User {
4040

4141
public static function get_post_type(): array {
4242
return [
43-
[ 'post', 'http://example.org/wp-admin/post-new.php', 'http://example.org/wp-admin/post.php?post=2&amp;action=edit' ],
44-
[ 'page', 'http://example.org/wp-admin/post-new.php?post_type=page', 'http://example.org/wp-admin/post.php?post=2&amp;action=edit' ]
43+
[
44+
'post',
45+
'http://example.org/wp-admin/post-new.php',
46+
'http://example.org/wp-admin/post.php?post=2&amp;action=edit'
47+
],
48+
[
49+
'page',
50+
'http://example.org/wp-admin/post-new.php?post_type=page',
51+
'http://example.org/wp-admin/post.php?post=2&amp;action=edit'
52+
]
4553
];
4654
}
4755

@@ -84,7 +92,10 @@ public function test_get_a_empty_post(): void {
8492

8593
$this->assertInstanceOf( MslsAdminIcon::class, $obj->set_href( 0 ) );
8694

87-
$value = sprintf( '<a title="Create a new translation in the de_DE-blog" href="%s"><span class="dashicons dashicons-plus"></span></a>&nbsp;', $create_link );
95+
$value = sprintf(
96+
'<a title="Create a new translation in the de_DE-blog" href="%s"><span class="dashicons dashicons-plus"></span></a>&nbsp;',
97+
$create_link
98+
);
8899
$this->assertEquals( $value, $obj->get_a() );
89100
$this->assertEquals( $value, $obj->__toString() );
90101
}
@@ -102,7 +113,10 @@ public function test_get_a_empty_page(): void {
102113

103114
$this->assertInstanceOf( MslsAdminIcon::class, $obj->set_href( 0 ) );
104115

105-
$value = sprintf( '<a title="Create a new translation in the de_DE-blog" href="%s"><span class="dashicons dashicons-plus"></span></a>&nbsp;', $create_link );
116+
$value = sprintf(
117+
'<a title="Create a new translation in the de_DE-blog" href="%s"><span class="dashicons dashicons-plus"></span></a>&nbsp;',
118+
$create_link
119+
);
106120
$this->assertEquals( $value, $obj->get_a() );
107121
$this->assertEquals( $value, $obj->__toString() );
108122
}
@@ -140,33 +154,33 @@ public function test_get_img_post_page(): void {
140154
public function test_set_id_with_null_constructor(): void {
141155
Functions\expect( 'add_query_arg' )->once();
142156

143-
$obj = new MslsAdminIcon( null );
157+
$obj = new MslsAdminIcon( null );
144158

145159
$this->assertInstanceOf( MslsAdminIcon::class, $obj->set_id( 1 ) );
146160
}
147161

148162
public function test_set_id(): void {
149-
$obj = new MslsAdminIcon( 'post' );
163+
$obj = new MslsAdminIcon( 'post' );
150164

151165
$this->assertInstanceOf( MslsAdminIcon::class, $obj->set_id( 1 ) );
152166
}
153167

154168
public function test_set_origin_language(): void {
155-
$obj = new MslsAdminIcon( 'post' );
169+
$obj = new MslsAdminIcon( 'post' );
156170

157171
$this->assertInstanceOf( MslsAdminIcon::class, $obj->set_origin_language( 'it_IT' ) );
158172
}
159173

160174
public function test_set_icon_type(): void {
161-
$obj = new MslsAdminIcon( 'post' );
175+
$obj = new MslsAdminIcon( 'post' );
162176

163177
$this->assertInstanceOf( MslsAdminIcon::class, $obj->set_icon_type( 'flag' ) );
164178
}
165179

166180
public function icon_type_provider(): array {
167181
return [
168182
[ 'flag', 'de_DE', '<span class="flag-icon flag-icon-de">de_DE</span>' ],
169-
[ 'label', 'it_IT', '<span class="language-badge it_IT"><span>it</span><span>IT</span></span>'],
183+
[ 'label', 'it_IT', '<span class="language-badge it_IT"><span>it</span><span>IT</span></span>' ],
170184
[ null, 'fr_FR', '<span class="dashicons dashicons-plus"></span>' ],
171185
[ null, null, '' ],
172186
];
@@ -178,7 +192,7 @@ public function icon_type_provider(): array {
178192
public function test_get_icon_flag( ?string $icon_type, ?string $language, string $expected ): void {
179193
Functions\expect( 'plugin_dir_path' )->atLeast( 1 )->andReturn( dirname( __DIR__, 1 ) . '/' );
180194

181-
$obj = new MslsAdminIcon( 'post' );
195+
$obj = new MslsAdminIcon( 'post' );
182196
$obj->set_icon_type( $icon_type );
183197

184198
if ( ! is_null( $language ) ) {
@@ -191,7 +205,7 @@ public function test_get_icon_flag( ?string $icon_type, ?string $language, strin
191205
public function test_get_icon_label(): void {
192206
Functions\expect( 'plugin_dir_path' )->atLeast( 1 )->andReturn( dirname( __DIR__, 1 ) . '/' );
193207

194-
$obj = new MslsAdminIcon( 'post' );
208+
$obj = new MslsAdminIcon( 'post' );
195209
$obj->set_icon_type( 'flag' );
196210

197211
$this->assertEquals( '', $obj->get_icon() );
@@ -202,7 +216,7 @@ public function test_get_icon_label(): void {
202216
}
203217

204218
public function test_get_edit_new(): void {
205-
$obj = new MslsAdminIcon( 'post' );
219+
$obj = new MslsAdminIcon( 'post' );
206220
$obj->set_id( 123 );
207221
$obj->set_origin_language( 'de_DE' );
208222

0 commit comments

Comments
 (0)