Make WordPress Core

Ticket #34121: 34121.3.diff

File 34121.3.diff, 2.5 KB (added by miqrogroove, 11 years ago)
  • tests/phpunit/includes/utils.php

     
    419419                        preg_match( $pattern, $subject );
    420420                        break;
    421421                case 'match_all':
    422                         preg_match_all( $pattern, $subject );
     422                        $matches = array();
     423                        preg_match_all( $pattern, $subject, $matches );
    423424                        break;
    424425                }
    425426
    … …  
    432433                        continue;
    433434                case PREG_RECURSION_LIMIT_ERROR:
    434435                        trigger_error('PCRE recursion limit encountered before backtrack limit.');
    435                         break;
     436                        return;
    436437                case PREG_BAD_UTF8_ERROR:
    437438                        trigger_error('UTF-8 error during PCRE benchmark.');
    438                         break;
     439                        return;
    439440                case PREG_INTERNAL_ERROR:
    440441                        trigger_error('Internal error during PCRE benchmark.');
    441                         break;
     442                        return;
    442443                default:
    443                         trigger_error('Unexpected error during PCRE benchmark.');       
     444                        trigger_error('Unexpected error during PCRE benchmark.');
     445                        return;
    444446                }
    445447        }
    446448
  • tests/phpunit/tests/formatting/WpHtmlSplit.php

     
     1<?php
     2
     3/**
     4 * @group formatting
     5 */
     6class Tests_Formatting_WpHtmlSplit extends WP_UnitTestCase {
     7
     8        /**
     9         * Basic functionality goes here.
     10         *
     11         * @dataProvider data_basic_features
     12         */
     13        function test_basic_features( $input, $output ) {
     14                return $this->assertEquals( $output, wp_html_split( $input ) );
     15        }
     16
     17        function data_basic_features() {
     18                return array(
     19                        array(
     20                                'abcd efgh',
     21                                array( 'abcd efgh' ),
     22                        ),
     23                        array(
     24                                'abcd <html> efgh',
     25                                array( 'abcd ', '<html>', ' efgh' ),
     26                        ),
     27                        array(
     28                                'abcd <!-- <html> --> efgh',
     29                                array( 'abcd ', '<!-- <html> -->', ' efgh' ),
     30                        ),
     31                        array(
     32                                'abcd <![CDATA[ <html> ]]> efgh',
     33                                array( 'abcd ', '<![CDATA[ <html> ]]>', ' efgh' ),
     34                        ),
     35                );
     36        }
     37
     38        /**
     39         * Automated performance testing of the main regex.
     40         *
     41         * @dataProvider data_whole_posts
     42         */
     43        function test_pcre_performance( $input ) {
     44                $regex = get_html_split_regex();
     45                $result = benchmark_pcre_backtracking( $regex, $input, 'split' );
     46                return $this->assertLessThan( 200, $result );
     47        }
     48
     49        function data_whole_posts() {
     50                require_once( DIR_TESTDATA . '/formatting/whole-posts.php' );
     51                return data_whole_posts();
     52        }
     53}
     54 No newline at end of file