forked from wielebenwir/commonsbooking
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28c2a93
commit 0e37241
Showing
3 changed files
with
51 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace CommonsBooking\Tests\API; | ||
|
||
/** | ||
* Abstract test case which implicitly tests REST Routes | ||
*/ | ||
class CB_REST_Route_UnitTestCase extends CB_REST_UnitTestCase { | ||
|
||
protected $ENDPOINT; | ||
|
||
public function testRoute() { | ||
$this->assertNotNull( $this->ENDPOINT ); | ||
$routes = $this->server->get_routes(); | ||
$this->assertArrayHasKey( $this->ENDPOINT, $routes ); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace CommonsBooking\Tests\API; | ||
|
||
use CommonsBooking\Plugin; | ||
use CommonsBooking\Settings\Settings; | ||
|
||
/** | ||
* Abstract Unit Test case, which initializes REST functionality | ||
*/ | ||
class CB_REST_UnitTestCase extends \WP_UnitTestCase { | ||
|
||
protected $server; | ||
|
||
protected $ENDPOINT; | ||
|
||
public function setUp() : void { | ||
parent::setUp(); | ||
/** @var WP_REST_Server $wp_rest_server */ | ||
global $wp_rest_server; | ||
$this->server = $wp_rest_server = new \WP_REST_Server; | ||
|
||
// Enables api | ||
Settings::updateOption( 'commonsbooking_options_api', 'api-activated', 'on' ); | ||
Settings::updateOption( 'commonsbooking_options_api', 'apikey_not_required', 'on' ); | ||
|
||
// Registers routes (via rest_api_init hook) | ||
( new Plugin() )->initRoutes(); | ||
|
||
// Applies hook | ||
do_action( 'rest_api_init' ); | ||
} | ||
} |