-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathTestMslsMetaBox.php
54 lines (38 loc) · 1.62 KB
/
TestMslsMetaBox.php
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
<?php declare( strict_types=1 );
namespace lloc\MslsTests;
use Brain\Monkey\Functions;
use lloc\Msls\MslsBlogCollection;
use lloc\Msls\MslsJson;
use lloc\Msls\MslsMetaBox;
use lloc\Msls\MslsOptions;
class TestMslsMetaBox extends MslsUnitTestCase {
protected function setUp(): void {
$options = \Mockery::mock( MslsOptions::class );
$collection = \Mockery::mock( MslsBlogCollection::class );
$this->test = new MslsMetaBox( $options, $collection );
}
public function test_suggest(): void {
$json = '{"some":"JSON"}';
Functions\when( 'wp_die' )->justEcho( $json );
$this->expectOutputString( '{"some":"JSON"}' );
MslsMetaBox::suggest();
}
public function test_get_suggested_fields_no_posts(): void {
Functions\expect( 'wp_reset_postdata' )->once();
Functions\expect( 'restore_current_blog' )->once();
Functions\expect( 'get_posts' )->once()->andReturn( array() );
$json = \Mockery::mock( MslsJson::class );
$args = array();
$this->assertEquals( $json, MslsMetaBox::get_suggested_fields( $json, $args ) );
}
public function test_render_option_selected(): void {
Functions\expect( 'selected' )->once()->andReturn( 'selected="selected"' );
Functions\expect( 'get_the_title' )->once()->andReturn( 'Test' );
$this->assertEquals( '<option value="1" selected="selected">Test</option>', $this->test->render_option( 1, 1 ) );
}
public function test_render_option_not_selected(): void {
Functions\expect( 'selected' )->once()->andReturn( '' );
Functions\expect( 'get_the_title' )->once()->andReturn( 'Test' );
$this->assertEquals( '<option value="1" >Test</option>', $this->test->render_option( 1, 2 ) );
}
}