Changeset 42343 for trunk/tests/phpunit/tests/pomo/pluralForms.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/pomo/pluralForms.php
r41730 r42343 13 13 * @return string the expression with parentheses added 14 14 */ 15 protected static function parenthesize_plural_expression( $expression) {15 protected static function parenthesize_plural_expression( $expression ) { 16 16 $expression .= ';'; 17 $res = '';18 $depth = 0;19 for ( $i = 0; $i < strlen($expression); ++$i) {20 $char = $expression[ $i];21 switch ( $char) {17 $res = ''; 18 $depth = 0; 19 for ( $i = 0; $i < strlen( $expression ); ++$i ) { 20 $char = $expression[ $i ]; 21 switch ( $char ) { 22 22 case '?': 23 23 $res .= ' ? ('; … … 28 28 break; 29 29 case ';': 30 $res .= str_repeat(')', $depth) . ';';31 $depth = 0;30 $res .= str_repeat( ')', $depth ) . ';'; 31 $depth = 0; 32 32 break; 33 33 default: … … 35 35 } 36 36 } 37 return rtrim( $res, ';');37 return rtrim( $res, ';' ); 38 38 } 39 39 … … 54 54 return array(); 55 55 } 56 require_once $filename; 57 } 58 59 $locales = GP_Locales::locales();56 require_once $filename; 57 } 58 59 $locales = GP_Locales::locales(); 60 60 $plural_expressions = array(); 61 61 foreach ( $locales as $slug => $locale ) { … … 82 82 83 83 $parenthesized = self::parenthesize_plural_expression( $expression ); 84 $old_style = tests_make_plural_form_function( $nplurals, $parenthesized );85 $pluralForms = new Plural_Forms( $expression );84 $old_style = tests_make_plural_form_function( $nplurals, $parenthesized ); 85 $pluralForms = new Plural_Forms( $expression ); 86 86 87 87 $generated_old = array(); … … 103 103 array( 104 104 -1 => 1, 105 0 => 1,106 1 => 0,107 2 => 1,108 5 => 1,105 0 => 1, 106 1 => 0, 107 2 => 1, 108 5 => 1, 109 109 10 => 1, 110 110 ), … … 115 115 array( 116 116 -1 => 1, 117 0 => 2,118 1 => 1,119 2 => 1,117 0 => 2, 118 1 => 1, 119 2 => 1, 120 120 ), 121 121 ), … … 126 126 -2 => 2, 127 127 -1 => 2, 128 0 => 2,129 1 => 2,130 2 => 1,131 3 => 1,128 0 => 2, 129 1 => 2, 130 2 => 1, 131 3 => 1, 132 132 ), 133 133 ), … … 137 137 -2 => 3, 138 138 -1 => 3, 139 0 => 3,140 1 => 3,141 2 => 2,142 3 => 1,143 4 => 1,139 0 => 3, 140 1 => 3, 141 2 => 2, 142 3 => 1, 143 4 => 1, 144 144 ), 145 145 ), … … 153 153 public function test_simple( $expression, $expected ) { 154 154 $pluralForms = new Plural_Forms( $expression ); 155 $actual = array();155 $actual = array(); 156 156 foreach ( array_keys( $expected ) as $num ) { 157 157 $actual[ $num ] = $pluralForms->get( $num ); … … 214 214 try { 215 215 $pluralForms = new Plural_Forms( $expression ); 216 if ( $call_get ) {216 if ( $call_get ) { 217 217 $pluralForms->get( 1 ); 218 218 } … … 230 230 public function test_cache() { 231 231 $mock = $this->getMockBuilder( 'Plural_Forms' ) 232 ->setMethods( array('execute'))233 ->setConstructorArgs( array('n != 1'))232 ->setMethods( array( 'execute' ) ) 233 ->setConstructorArgs( array( 'n != 1' ) ) 234 234 ->getMock(); 235 235 236 $mock->expects( $this->once())237 ->method( 'execute')238 ->with( $this->identicalTo(2))239 ->will( $this->returnValue(1));240 241 $first = $mock->get( 2 );236 $mock->expects( $this->once() ) 237 ->method( 'execute' ) 238 ->with( $this->identicalTo( 2 ) ) 239 ->will( $this->returnValue( 1 ) ); 240 241 $first = $mock->get( 2 ); 242 242 $second = $mock->get( 2 ); 243 243 $this->assertEquals( $first, $second );
Note: See TracChangeset
for help on using the changeset viewer.