-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Dependency Injection to register the editor metabox inside the Ad…
…min class
- Loading branch information
1 parent
0f6eff8
commit c95e2be
Showing
3 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Test class for the editor metabox. | ||
* | ||
* @package Accessibility_Checker | ||
*/ | ||
|
||
use EDAC\Admin\Admin; | ||
use EDAC\Admin\Meta_Boxes; | ||
|
||
/** | ||
* Tests for the editor meta box class. | ||
*/ | ||
class MetaBoxesTest extends WP_UnitTestCase { | ||
|
||
/** | ||
* Test the hooks are added only in admin. | ||
* | ||
* @return void | ||
*/ | ||
public function test_meta_boxes_are_registered_in_admin(): void { | ||
|
||
$meta_boxes = $this->getMockBuilder( Meta_Boxes::class ) | ||
->onlyMethods( array( 'register_meta_boxes' ) ) | ||
->getMock(); | ||
|
||
$meta_boxes->expects( $this->once() ) | ||
->method( 'register_meta_boxes' ); | ||
|
||
$this->invoke_admin_init( $meta_boxes ); | ||
do_action( 'add_meta_boxes' ); | ||
} | ||
|
||
/** | ||
* Test the init_hooks method. | ||
* | ||
* @return void | ||
*/ | ||
public function test_init_hooks(): void { | ||
$meta_boxes = new Meta_Boxes(); | ||
$meta_boxes->init_hooks(); | ||
|
||
$this->assertEquals( | ||
10, | ||
has_action( | ||
'add_meta_boxes', | ||
array( | ||
$meta_boxes, | ||
'register_meta_boxes', | ||
) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Test the render method. | ||
* | ||
* @return void | ||
*/ | ||
public function test_render(): void { | ||
$meta_boxes = new Meta_Boxes(); | ||
$meta_boxes->render(); | ||
|
||
$this->expectOutputRegex( '/^<div id="edac-tabs">/' ); | ||
} | ||
|
||
/** | ||
* Invoke the admin init method. | ||
* | ||
* @param Meta_Boxes $meta_boxes The metabox class. | ||
* @return void | ||
*/ | ||
private function invoke_admin_init( $meta_boxes ): void { | ||
$admin = new Admin( $meta_boxes ); | ||
$admin->init(); | ||
} | ||
} |