Skip to content

Commit 3074381

Browse files
authored
Merge pull request #358 from lloc/refactoring-2-9
Tests added
2 parents 5e356c1 + 4b14517 commit 3074381

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

includes/MslsMetaBox.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static function get_suggested_fields( $json, $args ) {
9090
*
9191
* @return MslsMetaBox
9292
*/
93-
public static function init() {
93+
public static function init(): MslsMetaBox {
9494
$options = msls_options();
9595
$obj = new static( $options, msls_blog_collection() );
9696

@@ -104,9 +104,9 @@ public static function init() {
104104
}
105105

106106
/**
107-
* Add
107+
* Adds the meta box to the post types
108108
*/
109-
public function add() {
109+
public function add(): void {
110110
foreach ( MslsPostType::instance()->get() as $post_type ) {
111111

112112
add_meta_box(
@@ -153,7 +153,7 @@ public function add() {
153153
*
154154
* @uses selected
155155
*/
156-
public function render_select() {
156+
public function render_select(): void {
157157
$blogs = $this->collection->get();
158158
if ( $blogs ) {
159159
global $post;
@@ -269,7 +269,7 @@ public function render_options( $type, $msls_id ): string {
269269
*
270270
* @return string
271271
*/
272-
public function render_option( $post_id, $msls_id ) {
272+
public function render_option( $post_id, $msls_id ): string {
273273
return sprintf(
274274
'<option value="%s" %s>%s</option>',
275275
$post_id,
@@ -283,7 +283,7 @@ public function render_option( $post_id, $msls_id ) {
283283
*
284284
* @param bool $echo Whether the metabox markup should be echoed to the page or not.
285285
*/
286-
public function render_input() {
286+
public function render_input(): void {
287287
$blogs = $this->collection->get();
288288

289289
if ( $blogs ) {
@@ -356,7 +356,7 @@ public function render_input() {
356356
*
357357
* @param int $post_id
358358
*/
359-
public function set( $post_id ) {
359+
public function set( $post_id ): void {
360360
if ( $this->is_autosave( $post_id ) || ! $this->verify_nonce() ) {
361361
return;
362362
}

tests/phpunit/TestMslsMetaBox.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function add_data_provider() {
9595

9696
/**
9797
* @dataProvider add_data_provider
98+
* @doesNotPerformAssertions
9899
*/
99100
public function test_add( $post_type, $fcount, $ocount, $content_import, $autocomplete ) {
100101
$options = \Mockery::mock( MslsOptions::class );
@@ -106,8 +107,6 @@ public function test_add( $post_type, $fcount, $ocount, $content_import, $autoco
106107
Functions\expect( '__' )->times( $fcount )->andReturnFirstArg();
107108
Functions\expect( 'msls_options' )->times( $ocount )->andReturn( $options );
108109

109-
$this->expectOutputString( '' );
110-
111110
$this->test->add();
112111
}
113112

@@ -233,4 +232,13 @@ public function test_render_input_only_one_blog() {
233232

234233
$this->test->render_input();
235234
}
235+
236+
/**
237+
* @doesNotPerformAssertions
238+
*/
239+
public function test_set() {
240+
Functions\expect( 'wp_is_post_revision' )->once()->andReturn( false );
241+
242+
$this->test->set( 13 );
243+
}
236244
}

0 commit comments

Comments
 (0)