Make WordPress Core

Ticket #5305: 5305-unittests.diff

File 5305-unittests.diff, 1.1 KB (added by MikeHansenMe, 10 years ago)

see #30284

  • tests/phpunit/tests/post.php

    diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php
    index 7e1f6e8..a4c6822 100644
    a b class Tests_Post extends WP_UnitTestCase { 
    439439        }
    440440
    441441        /**
     442         * @ticket 5305
     443         */
     444        function test_permalink_without_title() {
     445                // bug: permalink doesn't work if post title is empty
     446                // might only fail if the post ID is greater than four characters
     447
     448                global $wp_rewrite;
     449                $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     450
     451                $post = array(
     452                        'post_author' => $this->author_id,
     453                        'post_status' => 'publish',
     454                        'post_content' => rand_str(),
     455                        'post_title' => '',
     456                        'post_date' => '2007-10-31 06:15:00',
     457                );
     458
     459                // insert a post and make sure the ID is ok
     460                $id = $this->post_ids[] = wp_insert_post($post);
     461
     462                $plink = get_permalink($id);
     463
     464                // permalink should include the post ID at the end
     465                $this->assertEquals(get_option('siteurl').'/2007/10/31/'.$id.'/', $plink);
     466
     467                $wp_rewrite->set_permalink_structure('');
     468        }
     469
     470        /**
    442471         * @ticket 21013
    443472         */
    444473        function test_wp_unique_post_slug_with_non_latin_slugs() {