| 1 | <?php |
| 2 | |
| 3 | class Tests_Xmlrpc_Remove_Post_Data extends WP_UnitTestCase { |
| 4 | |
| 5 | |
| 6 | function test_null(){ |
| 7 | $this->assertEquals( '' , xmlrpc_removepostdata( null ) ); |
| 8 | } |
| 9 | |
| 10 | function test_xmlrpc_removepostdata_empty_string(){ |
| 11 | $this->assertEquals( '' , xmlrpc_removepostdata( '' ) ); |
| 12 | } |
| 13 | |
| 14 | function test_xmlrpc_removepostdata_good_title_valid_category(){ |
| 15 | $this->assertEquals( 'rest of content' , xmlrpc_removepostdata( '<title>good_title</title><category>good_category</category>rest of content' ) ); |
| 16 | } |
| 17 | |
| 18 | function test_xmlrpc_removepostdata_only_valid_title(){ |
| 19 | $this->assertEquals( '' , xmlrpc_removepostdata( '<title>good_title</title>' ) ); |
| 20 | } |
| 21 | |
| 22 | function test_xmlrpc_removepostdata_nested_titles(){ |
| 23 | $this->assertEquals( '</title>' , xmlrpc_removepostdata( '<title><title>good_title</title></title><category>bla</category>' ) ); |
| 24 | } |
| 25 | |
| 26 | function test_xmlrpc_removepostdata_multiple_categories(){ |
| 27 | $this->assertEquals( '' , xmlrpc_removepostdata( '<title>good_title</title><category>good category 1 </category><category>good category 2 </category>' ) ); |
| 28 | } |
| 29 | |
| 30 | function test_xmlrpc_removepostdata_xmlrpc_bad_close_tag() { |
| 31 | |
| 32 | $this->assertEquals( '<title>title</title dddddd>' , xmlrpc_removepostdata( '<title>title</title dddddd><category>good category 1 </category>' ) ); |
| 33 | } |
| 34 | |
| 35 | function test_xmlrpc_removepostdata_attribute_in_tag() { |
| 36 | |
| 37 | $this->assertEquals( '<title id="id">title</title>' , xmlrpc_removepostdata( '<title id="id">title</title><category>good category 1 </category>' ) ); |
| 38 | } |
| 39 | |
| 40 | function test_xmlrpc_removepostdata_attribute_in_cateogry() { |
| 41 | $this->assertEquals( '<category id="id">good category 1 </category>' , xmlrpc_removepostdata( '<title>title</title><category id="id">good category 1 </category>' ) ); |
| 42 | } |
| 43 | |
| 44 | } |
| 45 | |
| 46 | ?> |
| 47 | No newline at end of file |