Index: trunk/phase3/tests/phpunit/includes/MWNamespaceTest.php |
— | — | @@ -535,5 +535,35 @@ |
536 | 536 | $this->assertFalse( MWNamespace::hasGenderDistinction( NS_TALK ) ); |
537 | 537 | |
538 | 538 | } |
| 539 | + |
| 540 | + ####### HELPERS ########################################################### |
| 541 | + function __call( $method, $args ) { |
| 542 | + // Call the real method if it exists |
| 543 | + if( method_exists($this, $method ) ) { |
| 544 | + return $this->$method( $args ); |
| 545 | + } |
| 546 | + |
| 547 | + if( preg_match( '/^assert(Has|Is)(Not|)(Subject|Talk)$/', $method, $m ) ) { |
| 548 | + # Interprets arguments: |
| 549 | + $ns = $args[0]; |
| 550 | + $msg = isset($args[1]) ? $args[1] : " dummy message"; |
| 551 | + |
| 552 | + # Forge the namespace constant name: |
| 553 | + $ns_name = "NS_" . strtoupper( MWNamespace::getCanonicalName( $ns ) ); |
| 554 | + # ... and the MWNamespace method name |
| 555 | + $nsMethod = strtolower( $m[1] ) . $m[3]; |
| 556 | + |
| 557 | + $expect = ($m[2] === ''); |
| 558 | + $expect_name = $expect ? 'TRUE' : 'FALSE'; |
| 559 | + |
| 560 | + return $this->assertEquals( $expect, |
| 561 | + MWNamespace::$nsMethod( $ns, $msg ), |
| 562 | + "MWNamespace::$nsMethod( $ns_name ) should returns $expect_name" |
| 563 | + ); |
| 564 | + } |
| 565 | + |
| 566 | + throw new Exception( __METHOD__ . " could not find a method named $method\n" ); |
| 567 | + } |
| 568 | + |
539 | 569 | } |
540 | 570 | |