コード例 #1
0
ファイル: ShortcodeCest.php プロジェクト: lucatume/idlikethis
 /**
  * @test
  * it should render extended shortcode
  */
 public function it_should_render_extended_shortcode(\FunctionalTester $I)
 {
     $content = 'Lorem ipsum [idlikethis]Some idea of mine[/idlikethis]';
     $post_id = $I->havePostInDatabase(['post_name' => 'foo', 'post_content' => $content]);
     $I->amOnPage('/foo');
     $text = "Some idea of mine";
     $I->seeElement('.idlikethis-button[data-post-id="' . $post_id . '"][data-text="' . $text . '"] button');
 }
コード例 #2
0
 /**
  * @test
  * it should create missing terms assigned to post
  */
 public function it_should_create_missing_terms_assigned_to_post(FunctionalTester $I)
 {
     $postId = $I->havePostInDatabase(['terms' => ['taxonomy_two' => ['term_one']]]);
     $termId = $I->grabTermIdFromDatabase(['name' => 'term_one']);
     $termTaxonomyId = $I->grabTermTaxonomyIdFromDatabase(['term_id' => $termId, 'taxonomy' => 'taxonomy_two']);
     $I->seeInDatabase($I->grabTermRelationshipsTableName(), ['object_id' => $postId, 'term_taxonomy_id' => $termTaxonomyId, 'term_order' => 0]);
     $I->seeInDatabase($I->grabTermTaxonomyTableName(), ['term_taxonomy_id' => $termTaxonomyId, 'taxonomy' => 'taxonomy_two', 'count' => 1]);
 }
コード例 #3
0
ファイル: WPDbCest.php プロジェクト: Bostonncity/wp-browser
 public function it_should_delete_posts(FunctionalTester $I)
 {
     $I->wantTo('delete a post');
     $table = 'wp_posts';
     $I->havePostInDatabase(13);
     $I->seeInDatabase($table, ['ID' => 13]);
     $I->dontHavePostInDatabase(['ID' => 13]);
     $I->dontSeeInDatabase($table, ['ID' => 13]);
 }
コード例 #4
0
 /**
  * @test
  * it should insert a comment when hitting the endpoint with valid params
  */
 public function it_should_insert_a_comment_when_hitting_the_endpoint_with_valid_params(\FunctionalTester $I)
 {
     $post_id = $I->havePostInDatabase(['post_title' => 'Some post']);
     $I->amOnPage('/');
     $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]');
     $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce);
     $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/button-click', ['post_id' => $post_id, 'content' => 'Some Content']);
     $I->seeResponseCodeIs(200);
     $I->seeCommentInDatabase(['comment_post_ID' => $post_id]);
 }
コード例 #5
0
 /**
  * @test
  * it should reset comments when post id is valid
  */
 public function it_should_reset_comments_when_post_id_is_valid(\FunctionalTester $I)
 {
     $post_id = $I->havePostInDatabase();
     $comment_ids = $I->haveManyCommentsInDatabase(3, $post_id, ['comment_type' => 'idlikethis']);
     $I->loginAsAdmin();
     $I->amEditingPostWithId($post_id);
     $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]');
     $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce);
     $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/admin/reset-all', ['post_id' => $post_id]);
     $I->seeResponseCodeIs(200);
     foreach ($comment_ids as $comment_id) {
         $I->dontSeeCommentInDatabase(['comment_ID' => $comment_id, 'comment_post_ID' => $post_id]);
     }
 }
コード例 #6
0
 /**
  * @test
  * it should consolidate comments when post id is valid and user can edit posts
  */
 public function it_should_consolidate_comments_when_post_id_is_valid_and_user_can_edit_posts(\FunctionalTester $I)
 {
     $post_id = $I->havePostInDatabase();
     $comment_ids = $I->haveManyCommentsInDatabase(3, $post_id, ['comment_type' => 'idlikethis', 'comment_content' => '{{n}} - foo']);
     $I->loginAsAdmin();
     $I->amEditingPostWithId($post_id);
     $wp_rest_nonce = $I->grabValueFrom('input[name="rest_nonce"]');
     $I->haveHttpHeader('X-WP-Nonce', $wp_rest_nonce);
     $I->sendAjaxPostRequest('/wp-json/idlikethis/v1/admin/consolidate-all', ['post_id' => $post_id]);
     $I->seeResponseCodeIs(200);
     foreach ($comment_ids as $comment_id) {
         $I->dontSeeCommentInDatabase(['comment_ID' => $comment_id, 'comment_post_ID' => $post_id]);
     }
     $I->seePostMetaInDatabase(['post_id' => $post_id, 'meta_key' => '_idlikethis_votes', 'meta_value' => serialize(['foo' => 3])]);
 }
コード例 #7
0
 /**
  * @test
  * it should allow not having comment in database
  */
 public function it_should_allow_not_having_comment_in_database(FunctionalTester $I)
 {
     $postId = $I->havePostInDatabase();
     $commentId = $I->haveCommentInDatabase($postId);
     $I->seeCommentInDatabase(['comment_ID' => $commentId]);
     $I->dontHaveCommentInDatabase(['comment_ID' => $commentId]);
     $I->dontSeeCommentInDatabase(['comment_ID' => $commentId]);
 }
コード例 #8
0
ファイル: WPDbPostCest.php プロジェクト: lucatume/wp-browser
 /**
  * @test
  * it should allow inserting post meta when inserting a post using meta input
  */
 public function it_should_allow_inserting_post_meta_when_inserting_a_post_using_meta_input(FunctionalTester $I)
 {
     $meta = ['one' => 'meta one', 'two' => 'meta two'];
     $id = $I->havePostInDatabase(['meta_input' => $meta]);
     $I->seeInDatabase($I->grabPostsTableName(), ['ID' => $id]);
     foreach ($meta as $meta_key => $meta_value) {
         $I->seeInDatabase($I->grabPostmetaTableName(), ['post_id' => $id, 'meta_key' => $meta_key, 'meta_value' => $meta_value]);
     }
 }
コード例 #9
0
 /**
  * @test
  * it should serialize meta value when adding array post meta
  */
 public function it_should_serialize_meta_value_when_adding_array_post_meta(FunctionalTester $I)
 {
     $id = $I->havePostInDatabase();
     $meta = ['one', 'two', 'three'];
     $I->havePostmetaInDatabase($id, 'foo', $meta);
     $I->seeInDatabase($I->grabPostmetaTableName(), ['post_id' => $id, 'meta_key' => 'foo', 'meta_value' => serialize($meta)]);
 }