Make WordPress Core


Ignore:
Timestamp:
01/30/2015 04:47:44 PM (12 years ago)
Author:
boonebgorges
Message:

Introduce setExpectedDeprecated() and setExpectedIncorrectUsage() methods to `WP_UnitTestCase.

These methods provide a procedural alternative to the @expectedDeprecated
and @expectedIncorrectUsage test annotations, and parallel PHPUnit's native
setExpectedException().

Props prasoon2211, jdgrimes.
Fixes #28486.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/includes/helpers.php

    r31046 r31306  
    169169                $this->assertFalse( isset( $stati['foo'] ) );
    170170        }
     171
     172        /**
     173         * @ticket 28486
     174         */
     175        public function test_setExpectedDeprecated() {
     176                $this->setExpectedDeprecated( 'Tests_TestHelpers::mock_deprecated' );
     177                $this->mock_deprecated();
     178        }
     179
     180        /**
     181         * @ticket 28486
     182         */
     183        public function test_setExpectedIncorrectUsage() {
     184                $this->setExpectedIncorrectUsage( 'Tests_TestHelpers::mock_incorrect_usage' );
     185                $this->mock_incorrect_usage();
     186        }
     187
     188        protected function mock_deprecated() {
     189                _deprecated_function( __METHOD__, '2.5' );
     190        }
     191
     192        protected function mock_incorrect_usage() {
     193                _doing_it_wrong( __METHOD__, __( 'Incorrect usage test' ), '2.5' );
     194        }
    171195}
Note: See TracChangeset for help on using the changeset viewer.