| | 1 | <?php |
| | 2 | /** |
| | 3 | * Test cases for deprecated functions |
| | 4 | * |
| | 5 | * @package WordPress |
| | 6 | * @subpackage Unit Tests |
| | 7 | * @since 3.4.0 |
| | 8 | */ |
| | 9 | class TestDeprecatedFunctions extends WPTestCase { |
| | 10 | |
| | 11 | /** |
| | 12 | * List of functions that have been passed through _deprecated_function() |
| | 13 | * @var string[] |
| | 14 | */ |
| | 15 | protected $_deprecated_functions = array(); |
| | 16 | |
| | 17 | /** |
| | 18 | * Set up the test fixture |
| | 19 | * @return void |
| | 20 | */ |
| | 21 | public function setUp() { |
| | 22 | parent::setUp(); |
| | 23 | $this->_deprecated_functions = array(); |
| | 24 | add_action( 'deprecated_function_run' , array( $this, 'deprecated_function' ) ); |
| | 25 | add_action( 'deprecated_function_trigger_error', '__return_false' ); |
| | 26 | } |
| | 27 | |
| | 28 | /** |
| | 29 | * Tear down the test fixture |
| | 30 | * @return void |
| | 31 | */ |
| | 32 | public function teardown() { |
| | 33 | remove_action( 'deprecated_function_run' , array( $this, 'deprecated_function' ) ); |
| | 34 | remove_action( 'deprecated_function_trigger_error', '__return_false' ); |
| | 35 | parent::tearDown(); |
| | 36 | } |
| | 37 | |
| | 38 | /** |
| | 39 | * Catch functions that have passed through _deprecated_function |
| | 40 | * @param string $func |
| | 41 | * @return void |
| | 42 | */ |
| | 43 | public function deprecated_function( $func ) { |
| | 44 | if ( !array_key_exists( $func, $this->_deprecated_functions ) ) { |
| | 45 | $this->_deprecated_functions[$func] = 0; |
| | 46 | } |
| | 47 | $this->_deprecated_functions[$func]++; |
| | 48 | } |
| | 49 | |
| | 50 | /** |
| | 51 | * Test that url_is_accessable_via_ssl is deprecated |
| | 52 | * @return void |
| | 53 | */ |
| | 54 | public function test_url_is_accessable_via_ssl() { |
| | 55 | $this->knownWPBug( 19555 ); |
| | 56 | add_filter( 'https_ssl_verify', '__return_false' ); |
| | 57 | $ret = url_is_accessable_via_ssl( 'http://api.wordpress.org/secret-key/1.1/' ); |
| | 58 | remove_filter( 'https_ssl_verify', '__return_false' ); |
| | 59 | $this->assertTrue( $ret ); |
| | 60 | $this->assertArrayHasKey( 'url_is_accessable_via_ssl', $this->_deprecated_functions ); |
| | 61 | } |
| | 62 | } |