Skip to content

Commit 626f787

Browse files
committed
Tests: Add @method notations to factor class DocBlocks as a way to indicate expected return types from factory methods for the benefit of IDEs.
Props jdgrimes. Fixes #37867. git-svn-id: https://develop.svn.wordpress.org/trunk@40968 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 63739c5 commit 626f787

7 files changed

Lines changed: 69 additions & 0 deletions

tests/phpunit/includes/factory/class-wp-unittest-factory-for-blog.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/**
4+
* Unit test factory for sites on a multisite network.
5+
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
9+
* @method int create( $args = array(), $generation_definitions = null )
10+
* @method WP_Site create_and_get( $args = array(), $generation_definitions = null )
11+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
12+
*/
313
class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing {
414

515
function __construct( $factory = null ) {

tests/phpunit/includes/factory/class-wp-unittest-factory-for-bookmark.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
/**
44
* Factory for creating fixtures for the deprecated Links/Bookmarks API.
55
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
69
* @since 4.6.0
10+
*
11+
* @method int create( $args = array(), $generation_definitions = null )
12+
* @method object create_and_get( $args = array(), $generation_definitions = null )
13+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
714
*/
815
class WP_UnitTest_Factory_For_Bookmark extends WP_UnitTest_Factory_For_Thing {
916

tests/phpunit/includes/factory/class-wp-unittest-factory-for-comment.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/**
4+
* Unit test factory for comments.
5+
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
9+
* @method int create( $args = array(), $generation_definitions = null )
10+
* @method WP_Comment create_and_get( $args = array(), $generation_definitions = null )
11+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
12+
*/
313
class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing {
414

515
function __construct( $factory = null ) {

tests/phpunit/includes/factory/class-wp-unittest-factory-for-network.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/**
4+
* Unit test factory for networks.
5+
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
9+
* @method int create( $args = array(), $generation_definitions = null )
10+
* @method WP_Network create_and_get( $args = array(), $generation_definitions = null )
11+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
12+
*/
313
class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing {
414

515
function __construct( $factory = null ) {

tests/phpunit/includes/factory/class-wp-unittest-factory-for-post.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/**
4+
* Unit test factory for posts.
5+
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
9+
* @method int create( $args = array(), $generation_definitions = null )
10+
* @method WP_Post create_and_get( $args = array(), $generation_definitions = null )
11+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
12+
*/
313
class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing {
414

515
function __construct( $factory = null ) {

tests/phpunit/includes/factory/class-wp-unittest-factory-for-term.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/**
4+
* Unit test factory for terms.
5+
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
9+
* @method int create( $args = array(), $generation_definitions = null )
10+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
11+
*/
312
class WP_UnitTest_Factory_For_Term extends WP_UnitTest_Factory_For_Thing {
413

514
private $taxonomy;
@@ -35,6 +44,9 @@ function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) {
3544
return wp_set_post_terms( $post_id, $terms, $taxonomy, $append );
3645
}
3746

47+
/**
48+
* @return array|null|WP_Error|WP_Term
49+
*/
3850
function create_and_get( $args = array(), $generation_definitions = null ) {
3951
$term_id = $this->create( $args, $generation_definitions );
4052
$taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;

tests/phpunit/includes/factory/class-wp-unittest-factory-for-user.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/**
4+
* Unit test factory for users.
5+
*
6+
* Note: The below @method notations are defined solely for the benefit of IDEs,
7+
* as a way to indicate expected return values from the given factory methods.
8+
*
9+
* @method int create( $args = array(), $generation_definitions = null )
10+
* @method WP_User create_and_get( $args = array(), $generation_definitions = null )
11+
* @method int[] create_many( $count, $args = array(), $generation_definitions = null )
12+
*/
313
class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing {
414

515
function __construct( $factory = null ) {

0 commit comments

Comments
 (0)