@@ -20,8 +20,8 @@ tlib_parallel_info_t parallel_info
20
20
#define FUNCTION_NAME "global_function"
21
21
22
22
static void test_wraprecs_hashmap () {
23
- nruserfn_t * wraprec , * found_wraprec ;
24
- zend_string * func_name , * scope_name , * method_name ;
23
+ nruserfn_t * wraprec , * another_method_wraprec , * yet_another_method_wraprec , * found_wraprec ;
24
+ zend_string * func_name , * scope_name , * method_name , * scope , * method ;
25
25
bool is_new_wraprec = false;
26
26
bool * is_new_wraprec_tests [] = {NULL , & is_new_wraprec };
27
27
@@ -104,6 +104,43 @@ static void test_wraprecs_hashmap() {
104
104
found_wraprec = nr_php_user_instrument_wraprec_hashmap_get (method_name , NULL );
105
105
tlib_pass_if_null ("getting scoped method without scope" , found_wraprec );
106
106
107
+ another_method_wraprec = nr_php_user_instrument_wraprec_hashmap_add (NR_PSTR (SCOPE_NAME "::anotherMethod" ),
108
+ is_new_wraprec_ptr );
109
+ tlib_pass_if_not_null ("adding another scoped method" , another_method_wraprec );
110
+ if (NULL != is_new_wraprec_ptr ) {
111
+ tlib_pass_if_true ("adding another scoped method" , * is_new_wraprec_ptr ,
112
+ "expected true for is_new_wraprec" );
113
+ }
114
+ scope = zend_string_init_fast (NR_PSTR (SCOPE_NAME ));
115
+ method = zend_string_init_fast (NR_PSTR ("anotherMethod" ));
116
+ found_wraprec = nr_php_user_instrument_wraprec_hashmap_get (method , scope );
117
+ tlib_pass_if_ptr_equal ("getting another scoped method" , another_method_wraprec , found_wraprec );
118
+
119
+ another_method_wraprec = nr_php_user_instrument_wraprec_hashmap_add (NR_PSTR (SCOPE_NAME "::anotherMethod" ),
120
+ is_new_wraprec_ptr );
121
+ tlib_pass_if_not_null ("adding another scoped method one more time" , another_method_wraprec );
122
+ if (NULL != is_new_wraprec_ptr ) {
123
+ tlib_pass_if_false ("adding another scoped method one more time" , * is_new_wraprec_ptr ,
124
+ "expected false for is_new_wraprec" );
125
+ }
126
+ tlib_pass_if_ptr_equal ("getting another scoped method one more time" , another_method_wraprec , found_wraprec );
127
+ zend_string_free (method );
128
+ zend_string_free (scope );
129
+
130
+ yet_another_method_wraprec = nr_php_user_instrument_wraprec_hashmap_add (NR_PSTR (SCOPE_NAME "::anotherMethodStill" ),
131
+ is_new_wraprec_ptr );
132
+ tlib_pass_if_not_null ("adding yet another scoped method" , yet_another_method_wraprec );
133
+ if (NULL != is_new_wraprec_ptr ) {
134
+ tlib_pass_if_true ("adding yet another scoped method" , * is_new_wraprec_ptr ,
135
+ "expected true for is_new_wraprec" );
136
+ }
137
+ scope = zend_string_init_fast (NR_PSTR (SCOPE_NAME ));
138
+ method = zend_string_init_fast (NR_PSTR ("anotherMethodStill" ));
139
+ found_wraprec = nr_php_user_instrument_wraprec_hashmap_get (method , scope );
140
+ tlib_pass_if_ptr_equal ("getting another scoped method" , yet_another_method_wraprec , found_wraprec );
141
+ zend_string_free (method );
142
+ zend_string_free (scope );
143
+
107
144
nr_php_user_instrument_wraprec_hashmap_destroy ();
108
145
}
109
146
0 commit comments