Changeset 45505 for trunk/tests/phpunit/tests/l10n.php
- Timestamp:
- 06/08/2019 06:41:08 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/l10n.php
r44516 r45505 6 6 */ 7 7 class Tests_L10n extends WP_UnitTestCase { 8 9 /** 10 * Long Dummy Text. 11 * 12 * @since 5.0.0 13 * 14 * @var string $long_text 15 */ 16 private $long_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; 8 17 9 18 /** … … 261 270 $this->assertNotEmpty( $array['X-Generator'] ); 262 271 } 272 273 /** 274 * @ticket 44541 275 */ 276 function test_length_of_excerpt_should_be_counted_by_words() { 277 global $post; 278 279 switch_to_locale( 'en_US' ); 280 281 $args = array( 282 'post_content' => $this->long_text, 283 'post_excerpt' => '', 284 ); 285 286 $post = $this->factory()->post->create_and_get( $args ); 287 setup_postdata( $post ); 288 289 $expect = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat […]</p>\n"; 290 the_excerpt(); 291 292 restore_previous_locale(); 293 294 $this->expectOutputString( $expect ); 295 } 296 297 /** 298 * @ticket 44541 299 */ 300 function test_length_of_excerpt_should_be_counted_by_chars() { 301 global $post; 302 303 switch_to_locale( 'ja_JP' ); 304 305 $args = array( 306 'post_content' => $this->long_text, 307 'post_excerpt' => '', 308 ); 309 310 $post = $this->factory()->post->create_and_get( $args ); 311 setup_postdata( $post ); 312 313 $expect = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore […]</p>\n"; 314 the_excerpt(); 315 316 restore_previous_locale(); 317 318 $this->expectOutputString( $expect ); 319 } 320 321 /** 322 * @ticket 44541 323 */ 324 function test_length_of_excerpt_should_be_counted_by_chars_in_japanese() { 325 global $post; 326 327 switch_to_locale( 'ja_JP' ); 328 329 $args = array( 330 'post_content' => str_repeat( 'あ', 200 ), 331 'post_excerpt' => '', 332 ); 333 334 $post = $this->factory()->post->create_and_get( $args ); 335 setup_postdata( $post ); 336 337 $expect = '<p>' . str_repeat( 'あ', 110 ) . " […]</p>\n"; 338 the_excerpt(); 339 340 restore_previous_locale(); 341 342 $this->expectOutputString( $expect ); 343 } 344 345 /** 346 * @ticket 44541 347 */ 348 function test_length_of_excerpt_rss_should_be_counted_by_words() { 349 global $post; 350 351 switch_to_locale( 'en_US' ); 352 353 $args = array( 354 'post_content' => $this->long_text, 355 'post_excerpt' => '', 356 ); 357 358 $post = $this->factory()->post->create_and_get( $args ); 359 setup_postdata( $post ); 360 361 $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat […]'; 362 the_excerpt_rss(); 363 364 restore_previous_locale(); 365 366 $this->expectOutputString( $expect ); 367 } 368 369 /** 370 * @ticket 44541 371 */ 372 function test_length_of_excerpt_rss_should_be_counted_by_chars() { 373 global $post; 374 375 switch_to_locale( 'ja_JP' ); 376 377 $args = array( 378 'post_content' => $this->long_text, 379 'post_excerpt' => '', 380 ); 381 382 $post = $this->factory()->post->create_and_get( $args ); 383 setup_postdata( $post ); 384 385 $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore […]'; 386 387 the_excerpt_rss(); 388 389 restore_previous_locale(); 390 391 $this->expectOutputString( $expect ); 392 } 393 394 /** 395 * @ticket 44541 396 */ 397 function test_length_of_draft_should_be_counted_by_words() { 398 require_once ABSPATH . 'wp-admin/includes/dashboard.php'; 399 400 switch_to_locale( 'en_US' ); 401 402 $args = array( 403 'post_content' => $this->long_text, 404 'post_excerpt' => '', 405 'post_status' => 'draft', 406 ); 407 408 $this->factory()->post->create( $args ); 409 410 $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do…'; 411 wp_dashboard_recent_drafts(); 412 413 restore_previous_locale(); 414 415 $this->expectOutputRegex( '/' . $expect . '/' ); 416 } 417 418 /** 419 * @ticket 44541 420 */ 421 function test_length_of_draft_should_be_counted_by_chars() { 422 require_once ABSPATH . 'wp-admin/includes/dashboard.php'; 423 424 switch_to_locale( 'ja_JP' ); 425 426 $args = array( 427 'post_content' => $this->long_text, 428 'post_excerpt' => '', 429 'post_status' => 'draft', 430 ); 431 432 $post = $this->factory()->post->create( $args ); 433 434 $expect = 'Lorem ipsum dolor sit amet, consectetur …'; 435 wp_dashboard_recent_drafts(); 436 437 restore_previous_locale(); 438 439 $this->expectOutputRegex( '/' . $expect . '/' ); 440 } 441 442 /** 443 * @ticket 44541 444 */ 445 function test_length_of_draft_should_be_counted_by_chars_in_japanese() { 446 require_once ABSPATH . 'wp-admin/includes/dashboard.php'; 447 448 switch_to_locale( 'ja_JP' ); 449 450 $args = array( 451 'post_content' => str_repeat( 'あ', 200 ), 452 'post_excerpt' => '', 453 'post_status' => 'draft', 454 ); 455 456 $this->factory()->post->create( $args ); 457 458 $expect = str_repeat( 'あ', 40 ) . '…'; 459 wp_dashboard_recent_drafts(); 460 461 restore_previous_locale(); 462 463 $this->expectOutputRegex( '/' . $expect . '/' ); 464 } 465 466 /** 467 * @ticket 44541 468 */ 469 function test_length_of_comment_excerpt_should_be_counted_by_words() { 470 switch_to_locale( 'en_US' ); 471 472 $args = array( 473 'comment_content' => $this->long_text, 474 ); 475 $comment_id = $this->factory()->comment->create( $args ); 476 $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut…'; 477 $comment_excerpt = get_comment_excerpt( $comment_id ); 478 479 restore_previous_locale(); 480 481 $this->assertSame( $expect, $comment_excerpt ); 482 } 483 484 /** 485 * @ticket 44541 486 */ 487 function test_length_of_comment_excerpt_should_be_counted_by_chars() { 488 switch_to_locale( 'ja_JP' ); 489 490 $args = array( 491 'comment_content' => $this->long_text, 492 ); 493 $comment_id = $this->factory()->comment->create( $args ); 494 $expect = 'Lorem ipsum dolor sit amet, consectetur …'; 495 $comment_excerpt = get_comment_excerpt( $comment_id ); 496 497 restore_previous_locale(); 498 499 $this->assertSame( $expect, $comment_excerpt ); 500 } 501 502 /** 503 * @ticket 44541 504 */ 505 function test_length_of_comment_excerpt_should_be_counted_by_chars_in_Japanese() { 506 switch_to_locale( 'ja_JP' ); 507 508 $args = array( 509 'comment_content' => str_repeat( 'あ', 200 ), 510 ); 511 $comment_id = $this->factory()->comment->create( $args ); 512 $expect = str_repeat( 'あ', 40 ) . '…'; 513 $comment_excerpt = get_comment_excerpt( $comment_id ); 514 515 restore_previous_locale(); 516 517 $this->assertSame( $expect, $comment_excerpt ); 518 } 263 519 }
Note: See TracChangeset
for help on using the changeset viewer.