Skip to content

Commit

Permalink
test for update_post_term_relations
Browse files Browse the repository at this point in the history
  • Loading branch information
torounit committed May 29, 2022
1 parent 5059bdb commit 88b5cc1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
23 changes: 22 additions & 1 deletion tests/Term_Manager_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,28 @@ class Term_Manager_Test extends WP_UnitTestCase {
* Test for Term_Manager::update_post_term_relations().
*/
public function test_update_post_term_relations() {
$this->assertEquals( 1, 1 );
$term_manager = new Term_Manager( 'schedule_terms', 'schedule_terms_active' );

$category_id = $this->factory()->category->create( array( 'name' => 'category-1' ) );
update_term_meta( $category_id, 'schedule_terms_active', true );

$post_id = $this->factory()->post->create();
add_post_meta(
$post_id,
'schedule_terms',
array(
'type' => 'attach',
'taxonomy' => 'category',
'term' => 'category-1',
'datetime' => '2012-07-05T22:09:28+09:00',
),
false
);


$term_manager->update_post_term_relations( $post_id );

$this->assertTrue( has_category( 'category-1', $post_id ) );
}

/**
Expand Down
9 changes: 0 additions & 9 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,5 @@
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';


/**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/schedule-terms.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';

0 comments on commit 88b5cc1

Please sign in to comment.