Changeset 1102571
- Timestamp:
- 03/01/2015 03:07:42 PM (11 years ago)
- Location:
- wp-on-routes/tags/0.2.0
- Files:
-
- 3 edited
-
README.md (modified) (2 diffs)
-
tests/instructions.txt (modified) (3 diffs)
-
tests/test-body.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-on-routes/tags/0.2.0/README.md
r1102153 r1102571 76 76 ``` 77 77 78 In example above, if you target `/foo/a/b/c/bar/test`, browser will answer with HTTP status 200, with following code, with header and footer included :78 In example above, if you target `/foo/a/b/c/bar/test`, browser will answer with HTTP status 200, with following code, with header and footer included, only in Firefox browser: 79 79 80 80 ``` … … 120 120 121 121 Reference to tests/instructions.txt to read how to test output of your WordPress website. 122 123 I am using wp-cli to generate testing environment: https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests. 124 125 So, before any testing run similar command: `bash bin/install-wp-tests.sh wor_test_db root root localhost latest`. -
wp-on-routes/tags/0.2.0/tests/instructions.txt
r1102153 r1102571 1 This file contains data for routes to test. 1 This file contains data for routes to test. 2 2 3 Place the code below into your theme's functions.php and run phpunit 3 from inside wp-on-routes plugin directory. 4 Before you run phpunit make sure to export WOR_SITE variable, e.g. `export WOR_SITE=http://wor.dev` from your command line interface. 4 from inside wp-on-routes plugin directory. 5 6 Before you run phpunit make sure to export WOR_SITE variable, 7 e.g. `export WOR_SITE=http://wor.dev` from your command line interface. 5 8 6 9 … … 31 34 'action' => 'wor_params_intro_2' 32 35 ) 36 ), 37 array( 38 'get' => array( 39 'path' => '/red/green/blue/:param?', 40 'body' => 'no param' 41 ) 42 ), 43 array( 44 'get' => array( 45 'path' => '/red/*/blue/:param?', 46 'body' => 'params & splats', 47 'action' => 'wor_params_splats' 48 ) 33 49 ) 34 50 ); … … 42 58 } 43 59 60 function wor_print_3() { 61 echo 'Params & splats: ' . $_GET['param'] . ', ' . $_GET['splats'][0]; 62 } 63 44 64 add_action('wor_params_intro', 'wor_print'); 45 65 add_action('wor_params_intro_2', 'wor_print_2'); 66 add_action('wor_params_splats', 'wor_print_3'); -
wp-on-routes/tags/0.2.0/tests/test-body.php
r1102153 r1102571 25 25 $body = wp_remote_retrieve_body(wp_remote_get("{$home_url}/foo/bar/keyboard/mouse")); 26 26 $this->assertEquals('Params: keyboard, mouse', $body); 27 28 // without optional parameter `/red/green/blue/:param?` 29 $body = wp_remote_retrieve_body(wp_remote_get("{$home_url}/red/green/blue")); 30 $this->assertEquals('no param', $body); 31 32 // with optional parameter and splats `/red/*/blue/:param?` 33 $body = wp_remote_retrieve_body(wp_remote_get("{$home_url}/red/a/b/c/blue/purple")); 34 $this->assertEquals('Params & splats: purple, a/b/c', $body); 27 35 } 28 36
Note: See TracChangeset
for help on using the changeset viewer.