Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 23 |
| BS_Deffer_Callback_Test | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 23 |
| try_to_queue_a_hook_that_is_fired_before | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 9 |
|||
| queue_a_callback_with_valid_options | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 13 |
|||
| output | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| <?php | |
| /** | |
| * @coversDefaultClass BS_Deffer_Callback | |
| */ | |
| class BS_Deffer_Callback_Test extends WP_UnitTestCase { | |
| /** | |
| * @covers ::queue | |
| * @covers ::can_queue | |
| * | |
| * @test | |
| */ | |
| public function try_to_queue_a_hook_that_is_fired_before() { | |
| $hook = 'better-studio'; | |
| do_action( $hook, '' ); | |
| $mock = $this->createMock( 'BS_Deffer_Callback_Test' ); | |
| $mock->expects( $this->never() ) | |
| ->method( 'output' ); | |
| $result = BS_Deffer_Callback::queue( $hook, [ | |
| 'callback' => array( $mock, 'output' ), | |
| ] ); | |
| $this->assertFalse( $result ); | |
| } | |
| /** | |
| * @test | |
| * | |
| * @covers ::queue | |
| * @covers ::set_stack | |
| * @covers ::get_stack | |
| * @covers ::run_queue | |
| */ | |
| public function queue_a_callback_with_valid_options() { | |
| $hook = 'better-studio-2'; | |
| $params = [ | |
| [ | |
| 'a' => 'string', | |
| 'b' => 12.34, | |
| ], | |
| ]; | |
| $mock = $this->createMock( 'BS_Deffer_Callback_Test' ); | |
| $mock->expects( $this->exactly( 2 ) ) | |
| ->method( 'output' ) | |
| ->with( $this->equalTo( $params[0] ) ); | |
| $result = BS_Deffer_Callback::queue( $hook, [ | |
| 'callback' => array( $mock, 'output' ), | |
| 'params' => $params, | |
| ] ); | |
| $this->assertTrue( $result ); | |
| do_action( $hook, '' ); | |
| do_action( $hook, '' ); | |
| } | |
| public function output() { | |
| } | |
| } |