WordPress.org

Make WordPress Core

Changeset 918 in tests for trunk/includes/testcase.php


Ignore:
Timestamp:
07/19/2012 03:51:42 PM (9 years ago)
Author:
nacin
Message:

When calling phpunit with a --group of a @ticket annotation (--group 12345, --group UT123), force the tests associated with them, rather than skipping them.

Minimizes the need to use WP_TESTS_FORCE_KNOWN_BUGS and makes it easier to run tests for a specific ticket.

see #49.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/testcase.php

    r906 r918  
    11<?php
    22
    3 require_once 'factory.php';
    4 require_once 'trac.php';
     3require_once dirname( __FILE__ ) . '/factory.php';
     4require_once dirname( __FILE__ ) . '/trac.php';
    55
    66class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
     7
     8    protected static $forced_tickets = array();
    79
    810    function setUp() {
     
    128130                $this->knownWPBug( $ticket );
    129131            } elseif ( 'UT' == substr( $ticket, 0, 2 ) ) {
    130                 $this->knownUTBug( substr( $ticket, 2 ) );
     132                $ticket = substr( $ticket, 2 );
     133                if ( $ticket && is_numeric( $ticket ) )
     134                    $this->knownUTBug( $ticket );
     135            } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) {
     136                $ticket = substr( $ticket, 6 );
     137                if ( $ticket && is_numeric( $ticket ) )
     138                    $this->knownPluginBug( $ticket );
    131139            }
    132140        }
     
    137145     */
    138146    function knownWPBug( $ticket_id ) {
    139         if ( ! WP_TESTS_FORCE_KNOWN_BUGS && ! TracTickets::isTracTicketClosed( 'http://core.trac.wordpress.org', $ticket_id ) ) {
     147        if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) )
     148            return;
     149        if ( ! TracTickets::isTracTicketClosed( 'http://core.trac.wordpress.org', $ticket_id ) )
    140150            $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) );
    141         }
    142151    }
    143152
     
    146155     */
    147156    function knownUTBug( $ticket_id ) {
    148         if ( ! WP_TESTS_FORCE_KNOWN_BUGS && ! TracTickets::isTracTicketClosed( 'http://unit-tests.trac.wordpress.org', $ticket_id ) ) {
     157        if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) )
     158            return;
     159        if ( ! TracTickets::isTracTicketClosed( 'http://unit-tests.trac.wordpress.org', $ticket_id ) )
    149160            $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) );
    150         }
    151161    }
    152162
     
    155165     */
    156166    function knownPluginBug( $ticket_id ) {
    157         if ( ! WP_TESTS_FORCE_KNOWN_BUGS && ! TracTickets::isTracTicketClosed( 'http://plugins.trac.wordpress.org', $ticket_id ) ) {
     167        if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) )
     168            return;
     169        if ( ! TracTickets::isTracTicketClosed( 'http://plugins.trac.wordpress.org', $ticket_id ) )
    158170            $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) );
    159         }
     171    }
     172
     173    public static function forceTicket( $ticket ) {
     174        self::$forced_tickets[] = $ticket;
    160175    }
    161176
Note: See TracChangeset for help on using the changeset viewer.