Changeset 41725
- Timestamp:
- 10/04/2017 04:10:47 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/pomo/pluralForms.php
r41722 r41725 157 157 } 158 158 159 /** 160 * @expectedException Exception 161 * @expectedExceptionMessage Unknown symbol "#" 162 */ 163 public function test_invalid_operator() { 164 $pluralForms = new Plural_Forms( 'n # 2' ); 165 } 166 167 /** 168 * @expectedException Exception 169 * @expectedExceptionMessage Unknown operator "&" 170 */ 171 public function test_partial_operator() { 172 $pluralForms = new Plural_Forms( 'n & 1' ); 173 } 174 175 /** 176 * @expectedException Exception 177 * @expectedExceptionMessage Mismatched parentheses 178 */ 179 public function test_mismatched_open_paren() { 180 $pluralForms = new Plural_Forms( '((n)' ); 181 } 182 183 /** 184 * @expectedException Exception 185 * @expectedExceptionMessage Mismatched parentheses 186 */ 187 public function test_mismatched_close_paren() { 188 $pluralForms = new Plural_Forms( '(n))' ); 189 } 190 191 /** 192 * @expectedException Exception 193 * @expectedExceptionMessage Missing starting "?" ternary operator 194 */ 195 public function test_missing_ternary_operator() { 196 $pluralForms = new Plural_Forms( 'n : 2' ); 197 } 198 199 /** 200 * @expectedException Exception 201 * @expectedExceptionMessage Unknown operator "?" 202 */ 203 public function test_missing_ternary_else() { 204 $pluralForms = new Plural_Forms( 'n ? 1' ); 205 $pluralForms->get( 1 ); 206 } 207 208 /** 209 * @expectedException Exception 210 * @expectedExceptionMessage Too many values remaining on the stack 211 */ 212 public function test_overflow_stack() { 213 $pluralForms = new Plural_Forms( 'n n' ); 214 $pluralForms->get( 1 ); 159 public function data_exceptions() { 160 return array( 161 array( 162 'n # 2', // Invalid expression to parse 163 'Unknown symbol "#"', // Expected exception message 164 false, // Whether to call the get() method or not 165 ), 166 array( 167 'n & 1', 168 'Unknown operator "&"', 169 false, 170 ), 171 array( 172 '((n)', 173 'Mismatched parentheses', 174 false, 175 ), 176 array( 177 '(n))', 178 'Mismatched parentheses', 179 false, 180 ), 181 array( 182 'n : 2', 183 'Missing starting "?" ternary operator', 184 false, 185 ), 186 array( 187 'n ? 1', 188 'Unknown operator "?"', 189 true, 190 ), 191 array( 192 'n n', 193 'Too many values remaining on the stack', 194 true, 195 ), 196 ); 197 } 198 199 /** 200 * @dataProvider data_exceptions 201 */ 202 public function test_exceptions( $expression, $expected_exception, $call_get ) { 203 try { 204 $pluralForms = new Plural_Forms( $expression ); 205 if( $call_get ) { 206 $pluralForms->get( 1 ); 207 } 208 } catch ( Exception $e ) { 209 $this->assertEquals( $expected_exception, $e->getMessage() ); 210 } 215 211 } 216 212 … … 224 220 ->method('execute') 225 221 ->with($this->identicalTo(2)) 226 ->will Return(1);222 ->will($this->returnValue(1)); 227 223 228 224 $first = $mock->get( 2 );
Note: See TracChangeset
for help on using the changeset viewer.