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
bm\ ( , function () {
it 'should render shortcode for last product.'
= [ => TRUE, => ];
$args 'content' 'post_type' 'products'
\ ( )
Brain\Monkey\Functions expect 'get_posts'
-> ()
once
-> ( function ( array ) {
andReturnUsing $args
if ( [ ] === ) {
$args 'post_type' 'products'
[ \ :: ( ) ];
return Mockery mock 'WP_Post'
}
} );
\ ( )
Brain\Monkey\Functions expect 'shortcode_atts'
-> ()
once
-> ( \ :: ( ), \ :: ( ), )
with type type
Mockery Mockery
'array' 'array' 'last_post'
-> ( function ( , array ) {
andReturnUsing $defaults $args
( , );
return array_merge $defaults $args
} );
\ ( )
Brain\Monkey\Functions expect 'setup_postdata'
-> ()
once
-> ( :: ( ) );
with type
Mockery 'WP_Post'
\ ( )
Brain\Monkey\Functions expect 'wp_reset_postdata'
-> ()
once
-> ();
withNoArgs
\ ( [
Brain\Monkey\Functions stubs
=> ,
'get_the_ID' 123
=> ,
'get_the_date' '15/12/2017'
=> ,
'get_the_title' 'Test Title'
=> null,
'esc_html'
=> ,
'get_the_content' '
The content!
'
] );
= ( );
$rendered $args
last_post_shortcode
= ( , );
$has_id $rendered
strpos 'id="123"'
= ( , );
$has_date $rendered
strpos '15/12/2017
'
= ( , );
$has_title $rendered
strpos '
Test Title
'
= ( , );
$has_content $rendered
strpos '
The content!
'
&& && && ;
$has_id $has_date $has_title $has_content
return
} );
Quite a lot of code...
but the limited features
of our test framework
do not help here...