{"id":29341,"date":"2014-05-20T16:52:31","date_gmt":"2014-05-20T16:52:31","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/rewrite-testing\/"},"modified":"2014-05-20T16:53:06","modified_gmt":"2014-05-20T16:53:06","slug":"rewrite-testing","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/rewrite-testing\/","author":6535998,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.1.1","stable_tag":"0.1.1","tested":"3.9.40","requires":"3.9","requires_php":"","requires_plugins":"","header_name":"Rewrite Rule Testing","header_author":"Matthew Boynes","header_description":"","assets_banners_color":"","last_updated":"2014-05-20 16:53:06","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/url","header_plugin_uri":"https:\/\/github.com\/alleyinteractive\/rewrite-testing","header_author_uri":"http:\/\/www.alleyinteractive.com\/","rating":5,"author_block_rating":0,"active_installs":300,"downloads":29824,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"2"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.1.1"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"918058","resolution":"1","location":"assets"},"screenshot-2.png":{"filename":"screenshot-2.png","revision":"918058","resolution":"2","location":"assets"}},"screenshots":{"1":"Sample output of passing rules","2":"Sample output of failing rules"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[939,12054,1591,14585],"plugin_category":[59],"plugin_contributors":[79615,79614],"plugin_business_model":[],"class_list":["post-29341","plugin","type-plugin","status-publish","hentry","plugin_tags-permalinks","plugin_tags-rewrite-rules","plugin_tags-testing","plugin_tags-tests","plugin_category-utilities-and-tools","plugin_contributors-alleyinteractive","plugin_contributors-mboynes","plugin_committers-mboynes"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/rewrite-testing.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/rewrite-testing\/assets\/screenshot-1.png?rev=918058","caption":"Sample output of passing rules"},{"src":"https:\/\/ps.w.org\/rewrite-testing\/assets\/screenshot-2.png?rev=918058","caption":"Sample output of failing rules"}],"raw_content":"<!--section=description-->\n<p>This plugin provides a simple interface for testing your custom rewrite rules.<\/p>\n\n<p>The purpose of this plugin is to be able to test your <em>own<\/em> rewrite rules, so\nyou're probably most interested in knowing how to do that, right? The plugin\nprovides a filter, <code>rewrite_testing_tests<\/code> to add your own tests. That filter\npasses an associative array of name =&gt; tests. The tests array is an associative\narray of URI =&gt; expected match. In the outer array, the \"name\" is arbitrary and\nfor your own reference. In the inner array, the \"URI\" is the path you want to\ntest, and the \"expected match\" is what WordPress should find as a rewrite\nmatch.<\/p>\n\n<p>Enough chit-chat, here's an example:<\/p>\n\n<pre><code>function my_rewrite_tests( $tests ) {\n  return array(\n    'Events' =&gt; array(\n      '\/event\/super-bowl\/' =&gt; 'index.php?event=$matches[1]',\n      '\/event\/super-bowl\/page\/2\/' =&gt; 'index.php?event=$matches[1]&amp;paged=$matches[2]'\n    )\n  );\n}\nadd_filter( 'rewrite_testing_tests', 'my_rewrite_tests' );\n<\/code><\/pre>\n\n<p>You can see the <code>test_cases()<\/code> method for a full suite of tests for the \"Day\nand Name\" permalink structure. It's not necessary to leave these in (in fact,\nthe above demo would wipe them out), unless you want to make sure that your\ncustom rewrites aren't affecting core rewrites. If you aren't using \"Day and\nName\" permalinks, you'll need to adjust the tests to fit your permalink\nstructure.<\/p>\n\n<h3>Todo<\/h3>\n\n<ul>\n<li>Add a debug bar extension which reads a transient; the transient would be\nupdated whenever rewrite rules are flushed. The debug bar extension would\nshow pass\/fail status and link directly to the settings page.<\/li>\n<li>Add tests for other permalink structures?<\/li>\n<li>Add a way to run this as part of phpunit<\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Upload to the \/wp-content\/plugins\/ directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Go to Tools &rarr; Rewrite Testing<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>I installed this and my tests failed, what gives?<\/dt>\n<dd><p>Out-of-the-box, this plugin is setup to test core rewrites for the \"Day and\nName\" permalink structure. The purpose of this plugin is not to test core\nrewrites; these are just to serve as a demonstration.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>0.1.1<\/h4>\n\n<p>Cosmetic updates<\/p>\n\n<h4>0.1<\/h4>\n\n<p>Initial release. Enjoy!<\/p>","raw_excerpt":"Unit test your rewrite rules from the WordPress Admin.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/29341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=29341"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/mboynes"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=29341"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=29341"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=29341"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=29341"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=29341"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=29341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}