Make WordPress Core

Changeset 866 in tests


Ignore:
Timestamp:
07/02/2012 06:25:12 PM (14 years ago)
Author:
nacin
Message:

Move the hooks test involving a closure to a separate file so it may be isolated for PHP 5.3+. see [862]. fixes #101.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpunit.xml

    r865 r866  
    88        <testsuite>
    99            <directory suffix=".php">wp-testcase</directory>
     10            <file phpVersion="5.3.0" phpVersionOperator=">=">wp-testcase/test_actions_closures.php</file>
    1011            <exclude>wp-testcase/test_query_results.php</exclude>
    1112        </testsuite>
  • trunk/wp-testcase/test_actions.php

    r862 r866  
    240240        }
    241241
    242         function test_action_closure() {
    243                 if ( version_compare( PHP_VERSION, '5.3', '<' ) )
    244                         $this->markTestSkipped( 'Closures are a PHP 5.3 feature.' );
    245 
    246                 $this->knownWPBug(10493);
    247 
    248                 $tag = rand_str();
    249                 $closure = function($a, $b) { $GLOBALS[$a] = $b;};
    250                 add_action($tag, $closure, 10, 2);
    251 
    252                 $this->assertSame( 10, has_action($tag, $closure) );
    253 
    254                 $context = array( rand_str(), rand_str() );
    255                 do_action($tag, $context[0], $context[1]);
    256 
    257                 $this->assertSame($GLOBALS[$context[0]], $context[1]);
    258 
    259                 $tag2 = rand_str();
    260                 $closure2 = function() { $GLOBALS['closure_no_args'] = true;};
    261                 add_action($tag2, $closure2);
    262 
    263                 $this->assertSame( 10, has_action($tag2, $closure2) );
    264 
    265                 do_action($tag2);
    266 
    267                 $this->assertTrue($GLOBALS['closure_no_args']);
    268 
    269         }
    270 
    271242}
Note: See TracChangeset for help on using the changeset viewer.