Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
50.00% |
1 / 2 |
|
66.67% |
2 / 3 |
CRAP | |
92.31% |
12 / 13 |
| mg_factory_method_function_Test | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
12 / 12 |
| for_controller_callback_must_return_a_method_that_are_associated_with_controller | |
100.00% |
1 / 1 |
1 | |
100.00% |
5 / 5 |
|||
| pass_none_string_as_first_argument | |
100.00% |
1 / 1 |
1 | |
100.00% |
7 / 7 |
|||
| _sample_test_controller | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| <?php | |
| class mg_factory_method_function_Test extends WP_UnitTestCase { | |
| /** | |
| * @test | |
| * @covers mg_factory_method | |
| */ | |
| public function for_controller_callback_must_return_a_method_that_are_associated_with_controller() { | |
| $controller_callback = '_sample_test_controller@index'; | |
| $result = mg_factory_method( $controller_callback ); | |
| $expected = [ | |
| 'callable' => [ | |
| '_sample_test_controller', | |
| 'controller_call_method', | |
| ], | |
| 'args' => [ | |
| '_sample_test_controller', | |
| 'index', | |
| ] | |
| ]; | |
| $this->assertSame( $expected, $result ); | |
| } | |
| /** | |
| * @test | |
| */ | |
| public function pass_none_string_as_first_argument() { | |
| $class = new stdClass(); | |
| $result = mg_factory_method( $class, FALSE ); | |
| $this->assertFalse( $result ); | |
| $class = range( 1, 4 ); | |
| $result = mg_factory_method( $class, 123 ); | |
| $this->assertSame( 123, $result ); | |
| } | |
| } | |
| class _sample_test_controller extends Migrator_Controller { | |
| public function index() { | |
| } | |
| } |