summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit/includes/factory/class-wp-unittest-factory.php
blob: 4d0934bb9a0593cd8a36739448cdfedf2a1568e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php

/**
 * A factory for making WordPress data with a cross-object type API.
 *
 * Tests should use this factory to generate test fixtures.
 */
class WP_UnitTest_Factory {

	/**
	 * Generates post fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_Post
	 */
	public $post;

	/**
	 * Generates attachment fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_Attachment
	 */
	public $attachment;

	/**
	 * Generates comment fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_Comment
	 */
	public $comment;

	/**
	 * Generates user fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_User
	 */
	public $user;

	/**
	 * Generates taxonomy term fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_Term
	 */
	public $term;

	/**
	 * Generates category fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_Term
	 */
	public $category;

	/**
	 * Generates tag fixtures for use in tests.
	 *
	 * @var WP_UnitTest_Factory_For_Term
	 */
	public $tag;

	/**
	 * Generates bookmark (link) fixtures for use in tests.
	 *
	 * @since 4.6.0
	 * @var WP_UnitTest_Factory_For_Bookmark
	 */
	public $bookmark;

	/**
	 * Generates blog (site) fixtures for use in Multisite tests.
	 *
	 * @var WP_UnitTest_Factory_For_Blog
	 */
	public $blog;

	/**
	 * Generates network fixtures for use in Multisite tests.
	 *
	 * @var WP_UnitTest_Factory_For_Network
	 */
	public $network;

	public function __construct() {
		$this->post       = new WP_UnitTest_Factory_For_Post( $this );
		$this->attachment = new WP_UnitTest_Factory_For_Attachment( $this );
		$this->comment    = new WP_UnitTest_Factory_For_Comment( $this );
		$this->user       = new WP_UnitTest_Factory_For_User( $this );
		$this->term       = new WP_UnitTest_Factory_For_Term( $this );
		$this->category   = new WP_UnitTest_Factory_For_Term( $this, 'category' );
		$this->tag        = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' );
		$this->bookmark   = new WP_UnitTest_Factory_For_Bookmark( $this );
		if ( is_multisite() ) {
			$this->blog    = new WP_UnitTest_Factory_For_Blog( $this );
			$this->network = new WP_UnitTest_Factory_For_Network( $this );
		}
	}
}