Index: trunk/phase3/tests/phpunit/languages/LanguageTest.php |
— | — | @@ -654,4 +654,88 @@ |
655 | 655 | ), |
656 | 656 | ); |
657 | 657 | } |
| 658 | + |
| 659 | + /** |
| 660 | + * @dataProvider provideFormatDuration |
| 661 | + */ |
| 662 | + function testFormatDuration( $duration, $expected ) { |
| 663 | + $this->assertEquals( |
| 664 | + $expected, |
| 665 | + $this->lang->formatDuration( $duration ), |
| 666 | + "formatDuration('$duration'): $expected" |
| 667 | + ); |
| 668 | + } |
| 669 | + |
| 670 | + function provideFormatDuration() { |
| 671 | + return array( |
| 672 | + array( |
| 673 | + 0, |
| 674 | + "0 seconds", |
| 675 | + ), |
| 676 | + array( |
| 677 | + 1, |
| 678 | + "1 second", |
| 679 | + ), |
| 680 | + array( |
| 681 | + 2, |
| 682 | + "2 seconds", |
| 683 | + ), |
| 684 | + array( |
| 685 | + 60, |
| 686 | + "1 minute", |
| 687 | + ), |
| 688 | + array( |
| 689 | + 2 * 60, |
| 690 | + "2 minutes", |
| 691 | + ), |
| 692 | + array( |
| 693 | + 3600, |
| 694 | + "1 hour", |
| 695 | + ), |
| 696 | + array( |
| 697 | + 2 * 3600, |
| 698 | + "2 hours", |
| 699 | + ), |
| 700 | + array( |
| 701 | + 24 * 3600, |
| 702 | + "1 day", |
| 703 | + ), |
| 704 | + array( |
| 705 | + 2 * 86400, |
| 706 | + "2 days", |
| 707 | + ), |
| 708 | + array( |
| 709 | + 365.25 * 86400, |
| 710 | + "1 year", |
| 711 | + ), |
| 712 | + array( |
| 713 | + 2 * 31557600, |
| 714 | + "2 years", |
| 715 | + ), |
| 716 | + array( |
| 717 | + 10 * 31557600, |
| 718 | + "1 decade", |
| 719 | + ), |
| 720 | + array( |
| 721 | + 2 * 10 * 31557600, |
| 722 | + "2 decades", |
| 723 | + ), |
| 724 | + array( |
| 725 | + 100 * 31557600, |
| 726 | + "1 century", |
| 727 | + ), |
| 728 | + array( |
| 729 | + 200 * 31557600, |
| 730 | + "2 centuries", |
| 731 | + ), |
| 732 | + array( |
| 733 | + 1000 * 31557600, |
| 734 | + "1 millennium", |
| 735 | + ), |
| 736 | + array( |
| 737 | + 2 * 1000 * 31557600, |
| 738 | + "2 millennia", |
| 739 | + ), |
| 740 | + ); |
| 741 | + } |
658 | 742 | } |