WordPress.org

Make WordPress Core

Changeset 205 in tests


Ignore:
Timestamp:
04/25/2008 12:30:53 AM (10 years ago)
Author:
tellyworth
Message:

test gallery and shortcode output with the_content filtering

Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_post_output.php

    r191 r205  
    6060}
    6161
    62 
    63 
     62class WPTestShortcodeOutput1 extends _WPTestSinglePost {
     63    function setUp() {
     64
     65        $this->post_content =<<<EOF
     66[dumptag foo="bar" baz="123"]
     67
     68[dumptag foo=123 baz=bar]
     69
     70[dumptag http://example.com]
     71
     72EOF;
     73
     74        parent::setUp();
     75    }
     76
     77    function test_the_content() {
     78        $this->_do_post();
     79        $expected =<<<EOF
     80foo = bar
     81baz = 123
     82foo = 123
     83baz = bar
     840 = http://example.com
     85
     86EOF;
     87
     88        $this->assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
     89    }
     90}
     91
     92class WPTestShortcodeOutputParagraph extends _WPTestSinglePost {
     93    function setUp() {
     94
     95        $this->post_content =<<<EOF
     96Graf by itself:
     97
     98[paragraph]my graf[/paragraph]
     99
     100  [paragraph foo="bar"]another graf with whitespace[/paragraph] 
     101
     102An [paragraph]inline graf[/paragraph], this doesn't make much sense.
     103
     104A graf with a single EOL first:
     105[paragraph]blah[/paragraph]
     106
     107EOF;
     108
     109        parent::setUp();
     110    }
     111
     112    function test_the_content() {
     113        $this->_do_post();
     114        $expected =<<<EOF
     115<p>Graf by itself:</p>
     116<p class='graf'>my graf</p>
     117
     118  <p class='graf'>another graf with whitespace</p>
     119
     120<p>An <p class='graf'>inline graf</p>
     121, this doesn&#8217;t make much sense.</p>
     122<p>A graf with a single EOL first:<br />
     123<p class='graf'>blah</p>
     124</p>
     125
     126EOF;
     127
     128        $this->assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
     129    }
     130}
     131
     132class WPTestGalleryPost extends _WPDataset1 {
     133    function setUp() {
     134        parent::setUp();
     135        global $wp_rewrite;
     136        $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     137        $wp_rewrite->flush_rules();
     138    }
     139   
     140    function test_the_content() {
     141        // permalink page
     142        $this->http('/2008/04/01/simple-gallery-test/');
     143        the_post();
     144        // filtered output
     145        $out = get_echo('the_content');
     146       
     147        $expected = <<<EOF
     148<p>There are ten images attached to this post.  Here&#8217;s a gallery:</p>
     149
     150        <style type='text/css'>
     151            .gallery {
     152                margin: auto;
     153            }
     154            .gallery-item {
     155                float: left;
     156                margin-top: 10px;
     157                text-align: center;
     158                width: 33%;         }
     159            .gallery img {
     160                border: 2px solid #cfcfcf;
     161            }
     162            .gallery-caption {
     163                margin-left: 0;
     164            }
     165        </style>
     166        <!-- see gallery_shortcode() in wp-includes/media.php -->
     167        <div class='gallery'><dl class='gallery-item'>
     168            <dt class='gallery-icon'>
     169                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20040724_152504_53/' title='dsc20040724_152504_53'><img src="http://example.com/wp-content/uploads/2008/04/dsc20040724_152504_537.jpg" class="attachment-thumbnail" alt="" /></a>
     170            </dt></dl><dl class='gallery-item'>
     171            <dt class='gallery-icon'>
     172                <a href='http://example.com/2008/04/01/simple-gallery-test/canola/' title='canola'><img src="http://example.com/wp-content/uploads/2008/04/canola3.jpg" class="attachment-thumbnail" alt="" /></a>
     173            </dt></dl><dl class='gallery-item'>
     174            <dt class='gallery-icon'>
     175                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050315_145007_13/' title='dsc20050315_145007_13'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050315_145007_134.jpg" class="attachment-thumbnail" alt="" /></a>
     176            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     177            <dt class='gallery-icon'>
     178                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050604_133440_34/' title='dsc20050604_133440_34'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050604_133440_343.jpg" class="attachment-thumbnail" alt="" /></a>
     179            </dt></dl><dl class='gallery-item'>
     180            <dt class='gallery-icon'>
     181                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050831_165238_33/' title='dsc20050831_165238_33'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050831_165238_333.jpg" class="attachment-thumbnail" alt="" /></a>
     182            </dt></dl><dl class='gallery-item'>
     183            <dt class='gallery-icon'>
     184                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050901_105100_21/' title='dsc20050901_105100_21'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050901_105100_213.jpg" class="attachment-thumbnail" alt="" /></a>
     185            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     186            <dt class='gallery-icon'>
     187                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050813_115856_5/' title='dsc20050813_115856_5'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050813_115856_54.jpg" class="attachment-thumbnail" alt="" /></a>
     188            </dt></dl><dl class='gallery-item'>
     189            <dt class='gallery-icon'>
     190                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050720_123726_27/' title='dsc20050720_123726_27'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050720_123726_274.jpg" class="attachment-thumbnail" alt="" /></a>
     191            </dt></dl><dl class='gallery-item'>
     192            <dt class='gallery-icon'>
     193                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050727_091048_22/' title='Title: Seedlings'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050727_091048_224.jpg" class="attachment-thumbnail" alt="" /></a>
     194            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     195            <dt class='gallery-icon'>
     196                <a href='http://example.com/2008/04/01/simple-gallery-test/dsc20050726_083116_18/' title='dsc20050726_083116_18'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050726_083116_184.jpg" class="attachment-thumbnail" alt="" /></a>
     197            </dt></dl>
     198            <br style='clear: both;' />
     199        </div>
     200
     201<p>It&#8217;s the simplest form of the gallery tag.  All images are from the public domain site burningwell.org.</p>
     202<p>The images have various combinations of titles, captions and descriptions.</p>
     203EOF;
     204        $this->assertEquals(strip_ws($expected), strip_ws($out));
     205    }
     206
     207    function test_gallery_attributes() {
     208        // make sure the gallery shortcode attributes are parsed correctly
     209       
     210        $id = 575;
     211        $post = get_post($id);
     212        $post->post_content = '[gallery columns="1" size="medium"]';
     213        wp_update_post($post);
     214       
     215        // permalink page
     216        $this->http('/2008/04/01/simple-gallery-test/');
     217        the_post();
     218        // filtered output
     219        $out = get_echo('the_content');
     220
     221        $expected = <<<EOF
     222        <style type='text/css'>
     223            .gallery {
     224                margin: auto;
     225            }
     226            .gallery-item {
     227                float: left;
     228                margin-top: 10px;
     229                text-align: center;
     230                width: 100%;            }
     231            .gallery img {
     232                border: 2px solid #cfcfcf;
     233            }
     234            .gallery-caption {
     235                margin-left: 0;
     236            }
     237        </style>
     238        <!-- see gallery_shortcode() in wp-includes/media.php -->
     239        <div class='gallery'><dl class='gallery-item'>
     240            <dt class='gallery-icon'>
     241                <a href='http://example.com/?attachment_id=565' title='dsc20040724_152504_53'><img src="http://example.com/wp-content/uploads/2008/04/dsc20040724_152504_537.jpg" class="attachment-medium" alt="" /></a>
     242            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     243            <dt class='gallery-icon'>
     244                <a href='http://example.com/?attachment_id=566' title='canola'><img src="http://example.com/wp-content/uploads/2008/04/canola3.jpg" class="attachment-medium" alt="" /></a>
     245            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     246            <dt class='gallery-icon'>
     247                <a href='http://example.com/?attachment_id=567' title='dsc20050315_145007_13'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050315_145007_134.jpg" class="attachment-medium" alt="" /></a>
     248            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     249            <dt class='gallery-icon'>
     250                <a href='http://example.com/?attachment_id=568' title='dsc20050604_133440_34'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050604_133440_343.jpg" class="attachment-medium" alt="" /></a>
     251            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     252            <dt class='gallery-icon'>
     253                <a href='http://example.com/?attachment_id=569' title='dsc20050831_165238_33'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050831_165238_333.jpg" class="attachment-medium" alt="" /></a>
     254            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     255            <dt class='gallery-icon'>
     256                <a href='http://example.com/?attachment_id=570' title='dsc20050901_105100_21'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050901_105100_213.jpg" class="attachment-medium" alt="" /></a>
     257            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     258            <dt class='gallery-icon'>
     259                <a href='http://example.com/?attachment_id=571' title='dsc20050813_115856_5'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050813_115856_54.jpg" class="attachment-medium" alt="" /></a>
     260            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     261            <dt class='gallery-icon'>
     262                <a href='http://example.com/?attachment_id=572' title='dsc20050720_123726_27'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050720_123726_274.jpg" class="attachment-medium" alt="" /></a>
     263            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     264            <dt class='gallery-icon'>
     265                <a href='http://example.com/?attachment_id=573' title='Title: Seedlings'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050727_091048_224.jpg" class="attachment-medium" alt="" /></a>
     266            </dt></dl><br style="clear: both" /><dl class='gallery-item'>
     267            <dt class='gallery-icon'>
     268                <a href='http://example.com/?attachment_id=574' title='dsc20050726_083116_18'><img src="http://example.com/wp-content/uploads/2008/04/dsc20050726_083116_184.jpg" class="attachment-medium" alt="" /></a>
     269            </dt></dl><br style="clear: both" />
     270            <br style='clear: both;' />
     271        </div>
     272
     273EOF;
     274        $this->assertEquals(strip_ws($expected), strip_ws($out));
     275    }
     276
     277}
    64278
    65279
Note: See TracChangeset for help on using the changeset viewer.