-
Notifications
You must be signed in to change notification settings - Fork 194
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
Showing
2 changed files
with
81 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
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,39 @@ | ||
<?php | ||
|
||
namespace SenseiTest\WPML; | ||
|
||
use Sensei\WPML\Page; | ||
|
||
class Page_Test extends \WP_UnitTestCase { | ||
|
||
public function testInit_WhenCalled_AddsFilters() { | ||
/* Arrange. */ | ||
$page = new Page(); | ||
|
||
/* Act. */ | ||
$page->init(); | ||
|
||
/* Assert. */ | ||
$this->assertEquals( 10, has_filter( 'sensei_course_completed_page_id', array( $page, 'get_translated_course_completed_page_id' ) ) ); | ||
} | ||
|
||
public function testGetTranslatedCourseCompletedPageId_WhenCalled_AddsFilter() { | ||
/* Arrange. */ | ||
$page = new Page(); | ||
|
||
$filter_applied = false; | ||
$filter_function = function ( $page_id ) use ( &$filter_applied ) { | ||
$filter_applied = true; | ||
return $page_id; | ||
}; | ||
add_filter( 'wpml_object_id', $filter_function, 10, 1 ); | ||
|
||
/* Act. */ | ||
$page->get_translated_course_completed_page_id( 1 ); | ||
|
||
/* Assert. */ | ||
remove_filter( 'wpml_object_id', $filter_function, 10 ); | ||
$this->assertTrue( $filter_applied ); | ||
} | ||
|
||
} |