-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
failing test, that I can't figure out
- Loading branch information
1 parent
5be1c95
commit b7eafc0
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
test/unit/php/includes/core/classes/endpoints/class-test-endpoint.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,87 @@ | ||
<?php | ||
/** | ||
* Class handles unit tests for GatherPress\Core\Endpoints\Endpoint. | ||
* | ||
* @package GatherPress\Core | ||
* @since 1.0.0 | ||
*/ | ||
|
||
namespace GatherPress\Tests\Core\Endpoints; | ||
|
||
use GatherPress\Core\Endpoints\Endpoint; | ||
use GatherPress\Core\Endpoints\Endpoint_Redirect; | ||
use GatherPress\Core\Endpoints\Endpoint_Template; | ||
use PMC\Unit_Test\Base; | ||
use PMC\Unit_Test\Utility; | ||
|
||
/** | ||
* Class Test_Endpoint. | ||
* | ||
* @coversDefaultClass \GatherPress\Core\Endpoints\Endpoint | ||
* @group endpoints | ||
*/ | ||
class Test_Endpoint extends Base { | ||
/** | ||
* Coverage for __construct method. | ||
* | ||
* @covers ::__construct | ||
* | ||
* @return void | ||
public function test___construct(): void { | ||
$slug = 'custom-endpoint'; | ||
$callback = function () { | ||
return array( | ||
'file_name' => 'endpoint-template.php', | ||
'dir_path' => '/path/to/theme', | ||
); | ||
}; | ||
$plugin_default = '/mock/plugin/templates'; | ||
$template_default = '/default/template.php'; | ||
// Create a mock for Endpoint. | ||
$endpoint_template = new Endpoint_Template( $slug, $callback, $plugin_default ); | ||
} */ | ||
|
||
/** | ||
* Coverage for get_slugs method. | ||
* | ||
* @covers ::get_slugs | ||
* | ||
* @return void | ||
*/ | ||
public function test_get_slugs(): void { | ||
|
||
// // Simulate 'init' hook being fired | ||
// \do_action('init'); | ||
|
||
$callback = function(){}; | ||
$instance = new Endpoint( | ||
'query_var', | ||
'post', | ||
$callback, | ||
array( | ||
new Endpoint_Template( 'endpoint_template_1', $callback ), | ||
new Endpoint_Template( 'endpoint_template_2', $callback ), | ||
new Endpoint_Redirect( 'endpoint_redirect_1', $callback ), | ||
), | ||
'reg_ex', | ||
); | ||
// var_dump($instance->types); | ||
|
||
$this->assertSame( | ||
array( | ||
'endpoint_template_1', | ||
'endpoint_template_2', | ||
'endpoint_redirect_1', | ||
), | ||
Utility::invoke_hidden_method( $instance, 'get_slugs' ), | ||
'Failed to assert that endpoint slugs match.' | ||
); | ||
|
||
// $this->mock->wp()->reset(); | ||
|
||
} | ||
|
||
} |