@@ -5927,7 +5927,7 @@ public function test_return_block_node_paths() {
5927
5927
),
5928
5928
),
5929
5929
'core/group ' => array (
5930
- 'elements ' => array (
5930
+ 'elements ' => array (
5931
5931
'link ' => array (
5932
5932
'color ' => array (
5933
5933
'background ' => 'blue ' ,
@@ -5955,4 +5955,81 @@ public function test_return_block_node_paths() {
5955
5955
5956
5956
$ this ->assertEquals ( $ expected , $ block_nodes );
5957
5957
}
5958
+
5959
+ /**
5960
+ * This test covers `get_block_nodes` with the `$include_node_paths_only`
5961
+ * and `include_block_style_variations` options.
5962
+ */
5963
+ public function test_return_block_node_paths_with_variations () {
5964
+ $ theme_json = new ReflectionClass ( 'WP_Theme_JSON_Gutenberg ' );
5965
+
5966
+ $ func = $ theme_json ->getMethod ( 'get_block_nodes ' );
5967
+ $ func ->setAccessible ( true );
5968
+
5969
+ $ theme_json = array (
5970
+ 'version ' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA ,
5971
+ 'styles ' => array (
5972
+ 'typography ' => array (
5973
+ 'fontSize ' => '16px ' ,
5974
+ ),
5975
+ 'blocks ' => array (
5976
+ 'core/button ' => array (
5977
+ 'color ' => array (
5978
+ 'background ' => 'red ' ,
5979
+ ),
5980
+ 'variations ' => array (
5981
+ 'cheese ' => array (
5982
+ 'color ' => array (
5983
+ 'background ' => 'cheese ' ,
5984
+ ),
5985
+ ),
5986
+ ),
5987
+ ),
5988
+ 'core/group ' => array (
5989
+ 'color ' => array (
5990
+ 'background ' => 'blue ' ,
5991
+ ),
5992
+ 'variations ' => array (
5993
+ 'apricot ' => array (
5994
+ 'color ' => array (
5995
+ 'background ' => 'apricot ' ,
5996
+ ),
5997
+ ),
5998
+ ),
5999
+ ),
6000
+ ),
6001
+ ),
6002
+ );
6003
+
6004
+ $ block_nodes = $ func ->invoke (
6005
+ null ,
6006
+ $ theme_json ,
6007
+ array (),
6008
+ array (
6009
+ 'include_node_paths_only ' => true ,
6010
+ 'include_block_style_variations ' => true ,
6011
+ )
6012
+ );
6013
+
6014
+ $ expected = array (
6015
+ array (
6016
+ 'path ' => array ( 'styles ' , 'blocks ' , 'core/button ' ),
6017
+ 'variations ' => array (
6018
+ array (
6019
+ 'path ' => array ( 'styles ' , 'blocks ' , 'core/button ' , 'variations ' , 'cheese ' ),
6020
+ ),
6021
+ ),
6022
+ ),
6023
+ array (
6024
+ 'path ' => array ( 'styles ' , 'blocks ' , 'core/group ' ),
6025
+ 'variations ' => array (
6026
+ array (
6027
+ 'path ' => array ( 'styles ' , 'blocks ' , 'core/group ' , 'variations ' , 'apricot ' ),
6028
+ ),
6029
+ ),
6030
+ ),
6031
+ );
6032
+
6033
+ $ this ->assertEquals ( $ expected , $ block_nodes );
6034
+ }
5958
6035
}
0 commit comments