Exemplo n.º 1
0
 /**
  * @test
  * it should allow having many comments with number placeholder
  */
 public function it_should_allow_having_many_comments_with_number_placeholder(FunctionalTester $I)
 {
     $postId = $I->havePostInDatabase();
     $overrides = ['comment_author' => 'Luca', 'comment_author_email' => '*****@*****.**', 'comment_author_url' => 'https://theaveragedev.com', 'comment_author_IP' => '111.222.333.444', 'comment_date' => Date::now(), 'comment_date_gmt' => Date::gmtNow(), 'comment_content' => "No comment", 'comment_karma' => '3', 'comment_approved' => '0', 'comment_agent' => 'some agent', 'comment_type' => 'status', 'comment_parent' => 23, 'user_id' => 12];
     $ids = $I->haveManyCommentsInDatabase(5, $postId, $overrides);
     $I->assertEquals(5, count($ids));
     for ($i = 0; $i < count($ids); $i++) {
         foreach ($overrides as $key => $value) {
             $I->seeInDatabase($I->grabCommentsTableName(), ['comment_post_ID' => $postId, 'comment_ID' => $ids[$i], $key => str_replace('{{n}}', $i, $value)]);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @test
  * it should allow overriding with n key when having many posts
  */
 public function it_should_allow_overriding_with_n_key_when_having_many_posts(FunctionalTester $I)
 {
     $table = $I->grabPostsTableName();
     Date::_injectNow(time() - 300);
     $now = Date::now();
     $gmtNow = Date::gmtNow();
     $overrides = ['post_author' => '{{n}}', 'post_date' => $now, 'post_date_gmt' => $gmtNow, 'post_content' => "Post content {{n}}", 'post_title' => 'Post title {{n}}', 'post_excerpt' => "Post excerpt {{n}}", 'post_status' => 'draft', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_password' => '{{n}}foo{{n}}', 'post_name' => 'post-title-{{n}}', 'to_ping' => 1, 'pinged' => 1, 'post_modified' => $now, 'post_modified_gmt' => $gmtNow, 'post_content_filtered' => 'Foo bar {{n}}{{n}}', 'post_parent' => 23, 'guid' => 'http://example.com/?p={{n}}&var={{n}}', 'menu_order' => '{{n}}', 'post_type' => 'antother_type'];
     $post_ids = $I->haveManyPostsInDatabase(3, $overrides);
     foreach ($overrides as $key => $value) {
         for ($i = 0; $i < count($post_ids); $i++) {
             $post_id = $post_ids[$i];
             $processedValue = str_replace('{{n}}', $i, $value);
             $I->seeInDatabase($table, ['ID' => $post_id, $key => $processedValue]);
         }
     }
 }
Exemplo n.º 3
0
 protected static function getDefaults($id, $url)
 {
     $title = self::generateTitle($id);
     $defaults = array('post_author' => 1, 'post_date' => Date::now(), 'post_date_gmt' => Date::gmtNow(), 'post_content' => self::generateContent($id), 'post_title' => $title, 'post_excerpt' => self::generateExcerpt($id), 'post_status' => 'publish', 'comment_status' => 'open', 'ping_status' => 'open', 'post_password' => '', 'post_name' => (new Slugifier())->slugify($title), 'to_ping' => '', 'pinged' => '', 'post_modified' => Date::now(), 'post_modified_gmt' => Date::gmtNow(), 'post_content_filtered' => '', 'post_parent' => 0, 'guid' => "{$url}/?p={$id}", 'menu_order' => 0, 'post_type' => 'post');
     return $defaults;
 }