class-wp-unittest-factory.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * A factory for making WordPress data with a cross-object type API.
  4. *
  5. * Tests should use this factory to generate test fixtures.
  6. */
  7. class WP_UnitTest_Factory {
  8. /**
  9. * Generates post fixtures for use in tests.
  10. *
  11. * @var WP_UnitTest_Factory_For_Post
  12. */
  13. public $post;
  14. /**
  15. * Generates attachment fixtures for use in tests.
  16. *
  17. * @var WP_UnitTest_Factory_For_Attachment
  18. */
  19. public $attachment;
  20. /**
  21. * Generates comment fixtures for use in tests.
  22. *
  23. * @var WP_UnitTest_Factory_For_Comment
  24. */
  25. public $comment;
  26. /**
  27. * Generates user fixtures for use in tests.
  28. *
  29. * @var WP_UnitTest_Factory_For_User
  30. */
  31. public $user;
  32. /**
  33. * Generates taxonomy term fixtures for use in tests.
  34. *
  35. * @var WP_UnitTest_Factory_For_Term
  36. */
  37. public $term;
  38. /**
  39. * Generates category fixtures for use in tests.
  40. *
  41. * @var WP_UnitTest_Factory_For_Term
  42. */
  43. public $category;
  44. /**
  45. * Generates tag fixtures for use in tests.
  46. *
  47. * @var WP_UnitTest_Factory_For_Term
  48. */
  49. public $tag;
  50. /**
  51. * Generates bookmark (link) fixtures for use in tests.
  52. *
  53. * @since 4.6.0
  54. * @var WP_UnitTest_Factory_For_Bookmark
  55. */
  56. public $bookmark;
  57. /**
  58. * Generates blog (site) fixtures for use in Multisite tests.
  59. *
  60. * @var WP_UnitTest_Factory_For_Blog
  61. */
  62. public $blog;
  63. /**
  64. * Generates network fixtures for use in Multisite tests.
  65. *
  66. * @var WP_UnitTest_Factory_For_Network
  67. */
  68. public $network;
  69. public function __construct() {
  70. $this->post = new WP_UnitTest_Factory_For_Post( $this );
  71. $this->attachment = new WP_UnitTest_Factory_For_Attachment( $this );
  72. $this->comment = new WP_UnitTest_Factory_For_Comment( $this );
  73. $this->user = new WP_UnitTest_Factory_For_User( $this );
  74. $this->term = new WP_UnitTest_Factory_For_Term( $this );
  75. $this->category = new WP_UnitTest_Factory_For_Term( $this, 'category' );
  76. $this->tag = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' );
  77. $this->bookmark = new WP_UnitTest_Factory_For_Bookmark( $this );
  78. if ( is_multisite() ) {
  79. $this->blog = new WP_UnitTest_Factory_For_Blog( $this );
  80. $this->network = new WP_UnitTest_Factory_For_Network( $this );
  81. }
  82. }
  83. }