-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for
Controller::__construct()
(#219)
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 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
44 changes: 44 additions & 0 deletions
44
tests/phpunit/tests/Controller/Controller_ConstructTest.php
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,44 @@ | ||
<?php | ||
/** | ||
* Class Controller_ConstructTest | ||
* | ||
* @package AspireUpdate | ||
*/ | ||
|
||
/** | ||
* Tests for Controller::__construct() | ||
* | ||
* @covers \AspireUpdate\Controller::__construct | ||
*/ | ||
class Controller_ConstructTest extends WP_UnitTestCase { | ||
/** | ||
* Test that hooks are added. | ||
* | ||
* @dataProvider data_hooks_and_methods | ||
* | ||
* @string $hook The hook's name. | ||
* @string $method The method to hook. | ||
*/ | ||
public function test_should_add_hooks( $hook, $method ) { | ||
$controller = new AspireUpdate\Controller(); | ||
$this->assertIsInt( has_action( $hook, [ $controller, $method ] ) ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array[] | ||
*/ | ||
public function data_hooks_and_methods() { | ||
return [ | ||
'wp_ajax_aspireupdate_clear_log -> clear_log' => [ | ||
'hook' => 'wp_ajax_aspireupdate_clear_log', | ||
'method' => 'clear_log', | ||
], | ||
'wp_ajax_aspireupdate_read_log -> read_log' => [ | ||
'hook' => 'wp_ajax_aspireupdate_read_log', | ||
'method' => 'read_log', | ||
], | ||
]; | ||
} | ||
} |