[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @group core 5 * @group functions 6 * @group bp_get_referer_path 7 */ 8 class BP_Tests_Core_Functions_BPGetRefererPath extends BP_UnitTestCase { 9 private $_wp_http_referer = ''; 10 private $http_referer = ''; 11 12 public function setUp() { 13 parent::setUp(); 14 15 $this->_wp_http_referer = ''; 16 $this->http_referer = ''; 17 18 if ( isset( $_REQUEST['_wp_http_referer'] ) ) { 19 $this->_wp_http_referer = $_REQUEST['_wp_http_referer']; 20 } 21 22 if ( isset( $_SERVER['HTTP_REFERER'] ) ) { 23 $this->http_referer = $_SERVER['HTTP_REFERER']; 24 } 25 } 26 27 public function tearDown() { 28 if ( isset( $_REQUEST['_wp_http_referer'] ) ) { 29 unset( $_REQUEST['_wp_http_referer'] ); 30 } 31 32 if ( isset( $_SERVER['HTTP_REFERER'] ) ) { 33 unset( $_SERVER['HTTP_REFERER'] ); 34 } 35 36 if ( $this->_wp_http_referer ) { 37 $_REQUEST['_wp_http_referer'] = $this->_wp_http_referer; 38 } 39 40 if ( $this->http_referer ) { 41 $_SERVER['HTTP_REFERER'] = $this->http_referer; 42 } 43 44 parent::tearDown(); 45 } 46 47 public function test_from__wp_http_referer_fully_qualified_uri() { 48 $home = get_option( 'home' ); 49 $_REQUEST['_wp_http_referer'] = trailingslashit( $home ) . 'foo/'; 50 $found = bp_get_referer_path(); 51 $this->assertSame( '/foo/', bp_get_referer_path() ); 52 } 53 54 public function test_from__wp_http_referer_absolute_path() { 55 $_REQUEST['_wp_http_referer'] = '/foo/'; 56 $found = bp_get_referer_path(); 57 $this->assertSame( '/foo/', bp_get_referer_path() ); 58 } 59 60 public function test_from_server_request_uri_fully_qualified_uri() { 61 $home = get_option( 'home' ); 62 $_SERVER['HTTP_REFERER'] = trailingslashit( $home ) . 'foo/'; 63 $found = bp_get_referer_path(); 64 $this->assertSame( '/foo/', bp_get_referer_path() ); 65 } 66 67 public function test_from_server_request_uri_absolute_path() { 68 $_SERVER['HTTP_REFERER'] = '/foo/'; 69 $found = bp_get_referer_path(); 70 $this->assertSame( '/foo/', bp_get_referer_path() ); 71 } 72 73 public function test__wp_http_referer_should_take_precedence_over_server_superglobal() { 74 $_SERVER['HTTP_REFERER'] = '/foo/'; 75 $_REQUEST['_wp_http_referer'] = '/bar/'; 76 $found = bp_get_referer_path(); 77 $this->assertSame( '/bar/', bp_get_referer_path() ); 78 } 79 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |