@@ -74,6 +74,71 @@ public function tear_down() {
7474 parent ::tear_down ();
7575 }
7676
77+ /**
78+ * Returns the form field with the given id from a view configuration.
79+ *
80+ * @param array $config The view configuration.
81+ * @param string $id The form field id.
82+ * @return array|null The form field, or null when absent.
83+ */
84+ private function get_form_field ( $ config , $ id ) {
85+ foreach ( $ config ['form ' ]['fields ' ] as $ field ) {
86+ if ( is_array ( $ field ) && isset ( $ field ['id ' ] ) && $ id === $ field ['id ' ] ) {
87+ return $ field ;
88+ }
89+ }
90+ return null ;
91+ }
92+
93+ /**
94+ * The `status` and `discussion` groups of the default post type form declare
95+ * their panel summary explicitly, for built-in and custom post types alike.
96+ *
97+ * @ticket 65981
98+ *
99+ * @dataProvider data_default_form_post_types
100+ *
101+ * @param string $post_type The post type.
102+ */
103+ public function test_default_form_groups_declare_summary ( $ post_type ) {
104+ if ( ! post_type_exists ( $ post_type ) ) {
105+ register_post_type ( $ post_type );
106+ }
107+
108+ $ config = wp_get_entity_view_config ( 'postType ' , $ post_type );
109+
110+ foreach ( array ( 'status ' , 'discussion ' ) as $ group ) {
111+ $ field = $ this ->get_form_field ( $ config , $ group );
112+ $ this ->assertNotNull ( $ field , "The ` {$ group }` group is present. " );
113+ $ this ->assertNotEmpty ( $ field ['children ' ], "The ` {$ group }` group keeps its children. " );
114+ $ this ->assertSame (
115+ array (
116+ 'type ' => 'panel ' ,
117+ 'summary ' => $ group ,
118+ ),
119+ $ field ['layout ' ],
120+ "The ` {$ group }` group summary is explicit. "
121+ );
122+ }
123+
124+ if ( 'page ' !== $ post_type && 'post ' !== $ post_type ) {
125+ unregister_post_type ( $ post_type );
126+ }
127+ }
128+
129+ /**
130+ * Data provider.
131+ *
132+ * @return array[]
133+ */
134+ public function data_default_form_post_types () {
135+ return array (
136+ 'page ' => array ( 'page ' ),
137+ 'post ' => array ( 'post ' ),
138+ 'custom post type ' => array ( 'summaries_cpt ' ),
139+ );
140+ }
141+
77142 /**
78143 * The default configuration exposes the documented shape for an unknown entity.
79144 */
0 commit comments