-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from 10up/fix/pages-not-scanned-161
Fix: Pages are not being scanned by Language Processing
- Loading branch information
Showing
3 changed files
with
76 additions
and
27 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,62 @@ | ||
<?php | ||
/** | ||
* Testing for the SavePostHandler class | ||
*/ | ||
|
||
namespace Classifai\Tests\Admin; | ||
|
||
use \WP_UnitTestCase; | ||
use Classifai\Admin\SavePostHandler; | ||
|
||
/** | ||
* Class SavePostHandlerTest | ||
* @package Classifai\Tests\Admin | ||
* | ||
* @group admin | ||
*/ | ||
class SavePostHandlerTest extends WP_UnitTestCase { | ||
protected $save_post_handler; | ||
|
||
/** | ||
* setup method | ||
*/ | ||
function setUp() { | ||
parent::setUp(); | ||
|
||
$this->save_post_handler = new SavePostHandler(); | ||
} | ||
|
||
function test_is_rest_route() { | ||
global $wp_filter; | ||
|
||
$saved_filters = $wp_filter['classifai_rest_bases'] ?? null; | ||
unset( $wp_filter['classifai_rest_bases'] ); | ||
|
||
$this->assertEquals( false, $this->save_post_handler->is_rest_route() ); | ||
|
||
$_SERVER['REQUEST_URI'] = '/wp-json/wp/v2/users/me'; | ||
$this->assertEquals( false, $this->save_post_handler->is_rest_route() ); | ||
|
||
$_SERVER['REQUEST_URI'] = '/wp-json/wp/v2/posts/1'; | ||
$this->assertEquals( true, $this->save_post_handler->is_rest_route() ); | ||
|
||
$_SERVER['REQUEST_URI'] = '/wp-json/wp/v2/pages/1'; | ||
$this->assertEquals( true, $this->save_post_handler->is_rest_route() ); | ||
|
||
$_SERVER['REQUEST_URI'] = '/wp-json/wp/v2/custom/1'; | ||
$this->assertEquals( false, $this->save_post_handler->is_rest_route() ); | ||
|
||
if ( ! is_null( $saved_filters ) ) { | ||
$wp_filter['classifai_rest_bases'] = $saved_filters; | ||
} | ||
|
||
add_filter( | ||
'classifai_rest_bases', | ||
function( $bases ) { | ||
$bases[] = 'custom'; | ||
return $bases; | ||
} | ||
); | ||
$this->assertEquals( true, $this->save_post_handler->is_rest_route() ); | ||
} | ||
} |