-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathTestApi.php
More file actions
45 lines (31 loc) · 1.45 KB
/
Copy pathTestApi.php
File metadata and controls
45 lines (31 loc) · 1.45 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
<?php declare( strict_types=1 );
namespace lloc\MslsTests;
use Brain\Monkey\Functions;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
#[RunTestsInSeparateProcesses]
#[PreserveGlobalState( false )]
final class TestApi extends MslsUnitTestCase {
protected function setUp(): void {
parent::setUp();
require_once __DIR__ . '/../../includes/api.php';
}
public function test_msls_get_switcher_without_arguments(): void {
Functions\expect( 'apply_filters' )->once()->with( 'msls_get_output', null )->andReturn( null );
$this->assertSame( '', msls_get_switcher() );
}
public function test_msls_get_switcher_with_array(): void {
$attr = array( 'before_item' => '<li>' );
$output = \Mockery::mock();
$output->shouldReceive( 'set_tags' )->once()->with( $attr )->andReturn( 'switcher' );
Functions\expect( 'apply_filters' )->once()->with( 'msls_get_output', null )->andReturn( $output );
$this->assertSame( 'switcher', msls_get_switcher( $attr ) );
}
public function test_msls_get_switcher_coerces_non_array_to_empty_array(): void {
$output = \Mockery::mock();
$output->shouldReceive( 'set_tags' )->once()->with( array() )->andReturn( 'switcher' );
Functions\expect( 'apply_filters' )->once()->with( 'msls_get_output', null )->andReturn( $output );
// The [sc_msls] shortcode passes '' when used without attributes.
$this->assertSame( 'switcher', msls_get_switcher( '' ) );
}
}