Make WordPress Core

Changeset 139 in tests


Ignore:
Timestamp:
12/14/2007 04:38:27 AM (17 years ago)
Author:
tellyworth
Message:

new tests for the attachment importer

Location:
wp-testcase
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_import_wp.php

    r137 r139  
    7979    // use this to generate the tests seen in test_all_posts()
    8080    function _test_generate() {
    81         $this->_import_wp(DIR_TESTDATA.'/export/asdftestblog1.2007-12-11.xml', array('User A', 'User B'));
     81        $this->_import_wp(DIR_TESTDATA.'/export/asdftestblog1.2007-12-14.xml', array('User A', 'User B'));
    8282        $this->posts = get_posts('numberposts=500&post_type=&post_status=&orderby=post_date DESC,ID');
    8383        echo $this->_generate_post_content_test($this->posts, false);
     
    8686    function test_all_posts() {
    8787        global $wpdb;
    88         $this->_import_wp(DIR_TESTDATA.'/export/asdftestblog1.2007-12-11.xml', array('User A', 'User B'));
     88        $this->_import_wp(DIR_TESTDATA.'/export/asdftestblog1.2007-12-14.xml', array('User A', 'User B'));
    8989       
    9090        // check the tag and category counts
     
    284284        $this->assertEquals("2007-12-03 08:07:28", $post->post_date);
    285285        $this->assertEquals("2007-12-02 22:07:28", $post->post_date_gmt);
    286         $this->assertEquals("Here's an mp3 file that was uploaded as an attachment:\n\n<a href=\"http://asdftestblog1.wordpress.com/files/2007/12/yue-04-juan_manuel_fangio.mp3\" title=\"Juan Manuel Fangio by Yue\">Juan Manuel Fangio by Yue</a>\n\nAnd here's a link to an external mp3 file:\n\n<a href=\"http://generalfuzz.net/mp3/Cool%20Aberrations/acclimate.mp3\"> Acclimate by General Fuzz </a>\n\nBoth are CC licensed.", $post->post_content);
     286        $this->assertEquals("Here's an mp3 file that was uploaded as an attachment:\n\n<a href=\"http://example.com/wp-content/uploads/2007/12/yue-04-juan_manuel_fangio.mp3\" title=\"Juan Manuel Fangio by Yue\">Juan Manuel Fangio by Yue</a>\n\nAnd here's a link to an external mp3 file:\n\n<a href=\"http://generalfuzz.net/mp3/Cool%20Aberrations/acclimate.mp3\"> Acclimate by General Fuzz </a>\n\nBoth are CC licensed.", $post->post_content);
    287287        $this->assertEquals("Test with enclosures", $post->post_title);
    288288        $this->assertEquals("0", $post->post_category);
     
    890890        $this->assertEquals("2007-09-05 14:41:08", $post->post_date);
    891891        $this->assertEquals("2007-09-05 04:41:08", $post->post_date_gmt);
    892         $this->assertEquals("All the HTML tags listed in the <a href=\"http://faq.wordpress.com/2006/06/08/allowed-html-tags/\">FAQ</a>:\n\n<address>an address</address>\n<a href=\"http://example.com\">a link</a>\n<abbr title=\"abbreviation\">abbr.</abbr>\n<acronym title=\"acronym\">acr.</acronym>\n<b>bold<b>\n<big>big</big>\n<blockquote>a blockquote</blockquote>\nline<br />break\na citation\n\"class\" - eh?\n<code>some code</code>\n<del>deleted text</del>\n<div>a div</div>\n<em>emphasis</em>\n<font>font tags are bad</font>\n<h1>heading 1</h1>\n<h2>heading 2</h2>\n<h3>heading 3</h3>\n<h4>heading 4</h4>\n<h5>heading 5</h5>\n<h6>heading 6</h6>\n<i>italic</i>\n<img src=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-300px.jpg\" />\n<ins>inserted text</ins>\n<kbd>keyboard text</kbd>\n<p>a paragraph</p>\n<pre>pre-\nformatted\ntext</pre>\n<q>a quote</q>\n<s>strike</s>\n<strong>strong</strong>\n<sub>subtext</sub>\n<sup>supertext</sup>\n<tt>teletype text</tt>\n<var>variable</var>\n\n\nList tags:\n\n<dl>\n<dt>term</dt>\n<dd>definition</dd>\n<dt>term 2</dt>\n<dd>definition 2</dd>\n</dl>\n\n<ul>\n<li>item 1</li>\n<li>item 2</li>\n</ul>\n\n<ol>\n<li>item 1</li>\n<li>item 2</li>\n</ol>\n\n\nTable tags:\n\n<table border=\"1\">\n<caption>table caption</caption>\n<col />\n<col />\n<thead>\n<tr>\n<th>heading 1</th>\n<th>heading 2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Cell 1</td>\n<td>Cell 2</td>\n</tr>\n</tbody>\n<tfoot>\n<tr>\n<td>footer 1</td>\n<td>footer 2</td>\n</tr>\n</tfoot>\n</table>", $post->post_content);
     892        $this->assertEquals("All the HTML tags listed in the <a href=\"http://faq.wordpress.com/2006/06/08/allowed-html-tags/\">FAQ</a>:\n\n<address>an address</address>\n<a href=\"http://example.com\">a link</a>\n<abbr title=\"abbreviation\">abbr.</abbr>\n<acronym title=\"acronym\">acr.</acronym>\n<b>bold<b>\n<big>big</big>\n<blockquote>a blockquote</blockquote>\nline<br />break\na citation\n\"class\" - eh?\n<code>some code</code>\n<del>deleted text</del>\n<div>a div</div>\n<em>emphasis</em>\n<font>font tags are bad</font>\n<h1>heading 1</h1>\n<h2>heading 2</h2>\n<h3>heading 3</h3>\n<h4>heading 4</h4>\n<h5>heading 5</h5>\n<h6>heading 6</h6>\n<i>italic</i>\n<img src=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-300px.jpg\" />\n<ins>inserted text</ins>\n<kbd>keyboard text</kbd>\n<p>a paragraph</p>\n<pre>pre-\nformatted\ntext</pre>\n<q>a quote</q>\n<s>strike</s>\n<strong>strong</strong>\n<sub>subtext</sub>\n<sup>supertext</sup>\n<tt>teletype text</tt>\n<var>variable</var>\n\n\nList tags:\n\n<dl>\n<dt>term</dt>\n<dd>definition</dd>\n<dt>term 2</dt>\n<dd>definition 2</dd>\n</dl>\n\n<ul>\n<li>item 1</li>\n<li>item 2</li>\n</ul>\n\n<ol>\n<li>item 1</li>\n<li>item 2</li>\n</ol>\n\n\nTable tags:\n\n<table border=\"1\">\n<caption>table caption</caption>\n<col />\n<col />\n<thead>\n<tr>\n<th>heading 1</th>\n<th>heading 2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Cell 1</td>\n<td>Cell 2</td>\n</tr>\n</tbody>\n<tfoot>\n<tr>\n<td>footer 1</td>\n<td>footer 2</td>\n</tr>\n</tfoot>\n</table>", $post->post_content);
    893893        $this->assertEquals("Raw HTML code", $post->post_title);
    894894        $this->assertEquals("0", $post->post_category);
     
    21382138        $this->assertEquals("2007-09-04 09:37:59", $post->post_date);
    21392139        $this->assertEquals("2007-09-03 23:37:59", $post->post_date_gmt);
    2140         $this->assertEquals("Align right:\n\n<img SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-300px.jpg\" ALT=\"2007-06-30-dsc_4711-300px.jpg\" ALIGN=\"right\" />\n\nAlign left:\n\n<img SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-300px.jpg\" ALT=\"2007-06-30-dsc_4711-300px.jpg\" />", $post->post_content);
     2140        $this->assertEquals("Align right:\n\n<img SRC=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-300px.jpg\" ALT=\"2007-06-30-dsc_4711-300px.jpg\" ALIGN=\"right\" />\n\nAlign left:\n\n<img SRC=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-300px.jpg\" ALT=\"2007-06-30-dsc_4711-300px.jpg\" />", $post->post_content);
    21412141        $this->assertEquals("Image align test", $post->post_title);
    21422142        $this->assertEquals("0", $post->post_category);
     
    21722172        $this->assertEquals("2007-09-04 09:36:28", $post->post_date);
    21732173        $this->assertEquals("2007-09-03 23:36:28", $post->post_date_gmt);
    2174         $this->assertEquals("Three thumbs with links:\n\n<a TITLE=\"2007-06-30-dsc_4700-1.jpg\" HREF=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg\"><img ALT=\"2007-06-30-dsc_4700-1.jpg\" SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.thumbnail.jpg\" /></a><a TITLE=\"2007-06-30-dsc_4711-900px.jpg\" HREF=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-900px.jpg\"><img ALT=\"2007-06-30-dsc_4711-900px.jpg\" SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-900px.thumbnail.jpg\" /></a><a TITLE=\"2007-06-30-dsc_4711-300px.jpg\" HREF=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-300px.jpg\"><img ALT=\"2007-06-30-dsc_4711-300px.jpg\" SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-300px.thumbnail.jpg\" /></a>", $post->post_content);
     2174        $this->assertEquals("Three thumbs with links:\n\n<a TITLE=\"2007-06-30-dsc_4700-1.jpg\" HREF=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4700-1.jpg\"><img ALT=\"2007-06-30-dsc_4700-1.jpg\" SRC=\"http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.thumbnail.jpg\" /></a><a TITLE=\"2007-06-30-dsc_4711-900px.jpg\" HREF=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-900px.jpg\"><img ALT=\"2007-06-30-dsc_4711-900px.jpg\" SRC=\"http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4711-900px.thumbnail.jpg\" /></a><a TITLE=\"2007-06-30-dsc_4711-300px.jpg\" HREF=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-300px.jpg\"><img ALT=\"2007-06-30-dsc_4711-300px.jpg\" SRC=\"http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4711-300px.thumbnail.jpg\" /></a>", $post->post_content);
    21752175        $this->assertEquals("Test with thumbnails", $post->post_title);
    21762176        $this->assertEquals("0", $post->post_category);
     
    22062206        $this->assertEquals("2007-09-04 09:35:23", $post->post_date);
    22072207        $this->assertEquals("2007-09-03 23:35:23", $post->post_date_gmt);
    2208         $this->assertEquals("Image is 900x598px, resized in editor to 329x222.\n\n<a href=\"http://asdftestblog1.wordpress.com/2007/09/04/test-with-wide-image/9/\" title=\"2007-06-30-dsc_4711-900px.jpg\" rel=\"attachment wp-att-9\"><img src=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-900px.jpg\" alt=\"2007-06-30-dsc_4711-900px.jpg\" height=\"222\" width=\"329\" /></a>", $post->post_content);
     2208        $this->assertEquals("Image is 900x598px, resized in editor to 329x222.\n\n<a href=\"http://asdftestblog1.wordpress.com/2007/09/04/test-with-wide-image/9/\" title=\"2007-06-30-dsc_4711-900px.jpg\" rel=\"attachment wp-att-9\"><img src=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-900px.jpg\" alt=\"2007-06-30-dsc_4711-900px.jpg\" height=\"222\" width=\"329\" /></a>", $post->post_content);
    22092209        $this->assertEquals("Test with wide image resized", $post->post_title);
    22102210        $this->assertEquals("0", $post->post_category);
     
    22402240        $this->assertEquals("2007-09-04 09:31:31", $post->post_date);
    22412241        $this->assertEquals("2007-09-03 23:31:31", $post->post_date_gmt);
    2242         $this->assertEquals("Image is 900x598px, not resized in editor.\n\n<a TITLE=\"2007-06-30-dsc_4711-900px.jpg\" REL=\"attachment wp-att-9\" HREF=\"http://asdftestblog1.wordpress.com/?attachment_id=9\"><img ALT=\"2007-06-30-dsc_4711-900px.jpg\" SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-900px.jpg\" /></a>", $post->post_content);
     2242        $this->assertEquals("Image is 900x598px, not resized in editor.\n\n<a TITLE=\"2007-06-30-dsc_4711-900px.jpg\" REL=\"attachment wp-att-9\" HREF=\"http://asdftestblog1.wordpress.com/?attachment_id=9\"><img ALT=\"2007-06-30-dsc_4711-900px.jpg\" SRC=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-900px.jpg\" /></a>", $post->post_content);
    22432243        $this->assertEquals("Test with wide image", $post->post_title);
    22442244        $this->assertEquals("0", $post->post_category);
     
    23082308        $this->assertEquals("2007-09-04 09:30:02", $post->post_date);
    23092309        $this->assertEquals("2007-09-03 23:30:02", $post->post_date_gmt);
    2310         $this->assertEquals("Image is 300x199, not resized in editor.\n\n<a TITLE=\"2007-06-30-dsc_4711-300px.jpg\" REL=\"attachment wp-att-7\" HREF=\"http://asdftestblog1.wordpress.com/?attachment_id=7\"><img ALT=\"2007-06-30-dsc_4711-300px.jpg\" SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4711-300px.jpg\" /></a>", $post->post_content);
     2310        $this->assertEquals("Image is 300x199, not resized in editor.\n\n<a TITLE=\"2007-06-30-dsc_4711-300px.jpg\" REL=\"attachment wp-att-7\" HREF=\"http://asdftestblog1.wordpress.com/?attachment_id=7\"><img ALT=\"2007-06-30-dsc_4711-300px.jpg\" SRC=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4711-300px.jpg\" /></a>", $post->post_content);
    23112311        $this->assertEquals("Test with image", $post->post_title);
    23122312        $this->assertEquals("0", $post->post_category);
     
    26642664        $this->assertEquals("0000-00-00 00:00:00", $post->post_date);
    26652665        $this->assertEquals("0000-00-00 00:00:00", $post->post_date_gmt);
    2666         $this->assertEquals("Image file attached, 300px high.\n\n<a TITLE=\"2007-06-30-dsc_4700-1.jpg\" REL=\"attachment wp-att-25\" HREF=\"http://asdftestblog1.wordpress.com/?attachment_id=25\"><img ALT=\"2007-06-30-dsc_4700-1.jpg\" SRC=\"http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg\" /></a>", $post->post_content);
     2666        $this->assertEquals("Image file attached, 300px high.\n\n<a TITLE=\"2007-06-30-dsc_4700-1.jpg\" REL=\"attachment wp-att-25\" HREF=\"http://asdftestblog1.wordpress.com/?attachment_id=25\"><img ALT=\"2007-06-30-dsc_4700-1.jpg\" SRC=\"http://example.com/wp-content/uploads/2007/09/2007-06-30-dsc_4700-1.jpg\" /></a>", $post->post_content);
    26672667        $this->assertEquals("Draft post with file attached", $post->post_title);
    26682668        $this->assertEquals("0", $post->post_category);
  • wp-testcase/test_includes_functions.php

    r114 r139  
    6868}
    6969
     70class TestHTTPFunctions extends WPTestCase {
     71
     72    function test_head_request() {
     73        // this url give a direct 200 response
     74        $url = 'http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     75       
     76        $headers = wp_get_http_headers($url);
     77       
     78        $this->assertTrue( is_array($headers) );
     79        $this->assertEquals( 'image/jpeg', $headers['content-type'] );
     80        $this->assertEquals( '40148', $headers['content-length'] );
     81        $this->assertEquals( '200', $headers['response'] );
     82    }
     83   
     84    function test_head_redirect() {
     85        // this url will 302 redirect
     86        $url = 'http://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
     87       
     88        $headers = wp_get_http_headers($url);
     89       
     90        $this->assertTrue( is_array($headers) );
     91        $this->assertEquals( 'image/jpeg', $headers['content-type'] );
     92        $this->assertEquals( '40148', $headers['content-length'] );
     93        $this->assertEquals( '200', $headers['response'] );
     94    }
     95   
     96    function test_head_404() {
     97        $url = 'http://asdftestblog1.wordpress.com/files/2007/09/asdfasdfasdf.jpg';
     98       
     99        $headers = wp_get_http_headers($url);
     100       
     101        $this->assertTrue( is_array($headers) );
     102        $this->assertEquals( '404', $headers['response'] );
     103    }
     104       
     105
     106    function test_get_request() {
     107        $url = 'http://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
     108        $file = tempnam('/tmp', 'testfile');
     109       
     110        $headers = wp_get_http($url, $file);
     111       
     112        // should return the same headers as a head request
     113        $this->assertTrue( is_array($headers) );
     114        $this->assertEquals( 'image/jpeg', $headers['content-type'] );
     115        $this->assertEquals( '40148', $headers['content-length'] );
     116        $this->assertEquals( '200', $headers['response'] );
     117       
     118        // make sure the file is ok
     119        $this->assertEquals( 40148, filesize($file) );
     120        $this->assertEquals( 'b0371a0fc575fcf77f62cd298571f53b', md5_file($file) );
     121    }
     122
     123}
    70124
    71125?>
Note: See TracChangeset for help on using the changeset viewer.