Created
August 3, 2016 19:02
-
-
Save JDGrimes/442cfdbcc9710043a369e4cef5b60c26 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Test that points hooks that don't auto-reverse don't refire after import. | |
* | |
* @since 1.0.0 | |
*/ | |
public function test_imported_non_auto_reversing_hook_does_not_refire() { | |
$legacy_slug = 'comment'; | |
$settings = array( | |
'points' => 10, | |
'post_type' => 'post', | |
'auto_reverse' => 0, | |
); | |
$this->create_points_type(); | |
$hook_type = "wordpoints_{$legacy_slug}_points_hook"; | |
$hook = wordpointstests_add_points_hook( $hook_type, $settings ); | |
$hook->set_option( 'disable_auto_reverse_label', 'Test label.' ); | |
$user_id = $this->factory->user->create(); | |
$post_id = $this->factory->post->create(); | |
$comment_id = $this->factory->comment->create( | |
array( | |
'comment_post_ID' => $post_id, | |
'user_id' => $user_id, | |
) | |
); | |
$this->assertEquals( | |
$settings['points'] | |
, wordpoints_get_points( $user_id, 'points' ) | |
); | |
$this->factory->comment->update_object( | |
$comment_id | |
, array( 'comment_approved' => 0 ) | |
); | |
$this->assertEquals( | |
$settings['points'] | |
, wordpoints_get_points( $user_id, 'points' ) | |
); | |
$this->import(); | |
$this->assertCount( | |
1 | |
, wordpoints_hooks()->get_reaction_store( 'points' )->get_reactions() | |
); | |
$this->factory->comment->update_object( | |
$post_id | |
, array( 'comment_approved' => 1 ) | |
); | |
$this->assertEquals( | |
$settings['points'] | |
, wordpoints_get_points( $user_id, 'points' ) | |
); | |
// Create another comment to make sure the imported hook is working. | |
$this->factory->comment->create( | |
array( | |
'comment_post_ID' => $post_id, | |
'user_id' => $user_id, | |
) | |
); | |
$this->assertEquals( | |
2 * $settings['points'] | |
, wordpoints_get_points( $user_id, 'points' ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment