@@ -739,6 +739,8 @@ public function test_meta_query_compare_not_exists_with_another_condition_relati
739739
740740 /**
741741 * @ticket 64696
742+ *
743+ * @dataProvider data_jit_meta_query_invalidation
742744 */
743745 public function test_jit_meta_query_invalidation_adding_meta () {
744746 $ post_id = self ::factory ()->post ->create ();
@@ -785,11 +787,13 @@ public function test_jit_meta_query_invalidation_adding_meta() {
785787
786788 /**
787789 * @ticket 64696
790+ *
791+ * @dataProvider data_jit_meta_query_invalidation
788792 */
789793 public function test_jit_meta_query_invalidation_updating_meta () {
790794 $ post_id = self ::factory ()->post ->create ();
791795 wp_cache_set_posts_last_changed ();
792- add_post_meta ( $ post_id , 'foo ' , 'bar ' );
796+ add_post_meta ( $ post_id , 'foo ' , 'baz ' );
793797
794798 // Query posts by meta data.
795799 $ query = new WP_Query (
@@ -798,7 +802,7 @@ public function test_jit_meta_query_invalidation_updating_meta() {
798802 'meta_query ' => array (
799803 array (
800804 'key ' => 'foo ' ,
801- 'value ' => 'baz ' ,
805+ 'value ' => 'bar ' ,
802806 ),
803807 ),
804808 )
@@ -807,7 +811,7 @@ public function test_jit_meta_query_invalidation_updating_meta() {
807811 $ posts_last_changed_initial = wp_cache_get_last_changed ( 'posts ' );
808812
809813 // Update post meta.
810- update_post_meta ( $ post_id , 'foo ' , 'baz ' );
814+ update_post_meta ( $ post_id , 'foo ' , 'bar ' );
811815
812816 // Confirm last changed has not updated.
813817 $ this ->assertSame ( $ posts_last_changed_initial , wp_cache_get_last_changed ( 'posts ' ), 'Updating meta data should not invalidate post query cache. ' );
@@ -819,7 +823,7 @@ public function test_jit_meta_query_invalidation_updating_meta() {
819823 'meta_query ' => array (
820824 array (
821825 'key ' => 'foo ' ,
822- 'value ' => 'baz ' ,
826+ 'value ' => 'bar ' ,
823827 ),
824828 ),
825829 )
@@ -833,6 +837,8 @@ public function test_jit_meta_query_invalidation_updating_meta() {
833837
834838 /**
835839 * @ticket 64696
840+ *
841+ * @dataProvider data_jit_meta_query_invalidation
836842 */
837843 public function test_jit_meta_query_invalidation_deleting_meta () {
838844 $ post_id = self ::factory ()->post ->create ();
@@ -878,6 +884,51 @@ public function test_jit_meta_query_invalidation_deleting_meta() {
878884 $ this ->assertNotContains ( $ post_id , $ query ->posts , 'Queried post should not be in results after meta data deleted. ' );
879885 }
880886
887+ /**
888+ * Data provider for:
889+ * - test_jit_meta_query_invalidation_adding_meta
890+ * - test_jit_meta_query_invalidation_updating_meta
891+ * - test_jit_meta_query_invalidation_deleting_meta
892+ *
893+ * @return array<string, array> Data provider.
894+ */
895+ public function data_jit_meta_query_invalidation () {
896+ return array (
897+ 'meta_query key only ' => array (
898+ 'meta_query ' => array (
899+ array (
900+ 'key ' => 'foo ' ,
901+ ),
902+ ),
903+ ),
904+ 'meta_query value only ' => array (
905+ 'meta_query ' => array (
906+ array (
907+ 'value ' => 'bar ' ,
908+ ),
909+ ),
910+ ),
911+ 'meta_query key and value ' => array (
912+ 'meta_query ' => array (
913+ array (
914+ 'key ' => 'foo ' ,
915+ 'value ' => 'bar ' ,
916+ ),
917+ ),
918+ ),
919+ 'meta_key top level only ' => array (
920+ 'meta_key ' => 'foo ' ,
921+ ),
922+ 'meta_value top level only ' => array (
923+ 'meta_value ' => 'bar ' ,
924+ ),
925+ 'meta_key and meta_value top level ' => array (
926+ 'meta_key ' => 'foo ' ,
927+ 'meta_value ' => 'bar ' ,
928+ ),
929+ );
930+ }
931+
881932 /**
882933 * @ticket 24093
883934 */
0 commit comments