-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathprofile-queries.feature
More file actions
115 lines (103 loc) · 2.6 KB
/
profile-queries.feature
File metadata and controls
115 lines (103 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Feature: Profile database queries
Scenario: Show all database queries
Given a WP install
And a wp-content/mu-plugins/test-queries.php file:
"""
<?php
add_action( 'init', function() {
global $wpdb;
$wpdb->query( "SELECT 1 as test_query_one" );
$wpdb->query( "SELECT 2 as test_query_two" );
});
"""
When I run `wp profile queries --fields=query,time`
Then STDOUT should contain:
"""
query
"""
And STDOUT should contain:
"""
time
"""
And STDOUT should contain:
"""
SELECT 1 as test_query_one
"""
And STDOUT should contain:
"""
SELECT 2 as test_query_two
"""
And STDOUT should contain:
"""
total
"""
And STDERR should be empty
Scenario: Show queries with specific fields
Given a WP install
When I run `wp profile queries --fields=query,time`
Then STDOUT should contain:
"""
query
"""
And STDOUT should contain:
"""
time
"""
And STDOUT should contain:
"""
SELECT
"""
And STDERR should be empty
Scenario: Order queries by execution time
Given a WP install
When I run `wp profile queries --fields=time --orderby=time --order=DESC`
Then STDOUT should contain:
"""
time
"""
And STDERR should be empty
Scenario: Display queries in JSON format
Given a WP install
When I run `wp profile queries --format=json --fields=query,time`
Then STDOUT should contain:
"""
"query"
"""
And STDOUT should contain:
"""
"time"
"""
And STDERR should be empty
Scenario: Filter queries by hook
Given a WP install
And a wp-content/mu-plugins/query-test.php file:
"""
<?php
add_action( 'init', function() {
global $wpdb;
$wpdb->query( "SELECT 1 as test_query" );
});
"""
When I run `wp profile queries --hook=init --fields=query,callback`
Then STDOUT should contain:
"""
SELECT 1 as test_query
"""
And STDERR should be empty
Scenario: Filter queries by callback
Given a WP install
And a wp-content/mu-plugins/callback-test.php file:
"""
<?php
function my_test_callback() {
global $wpdb;
$wpdb->query( "SELECT 2 as callback_test" );
}
add_action( 'init', 'my_test_callback' );
"""
When I run `wp profile queries --callback=my_test_callback --fields=query,hook`
Then STDOUT should contain:
"""
SELECT 2 as callback_test
"""
And STDERR should be empty