Changeset 44481 for trunk/tests/phpunit/tests/functions.php
 Timestamp:
 01/08/2019 07:55:31 PM (7 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/tests/phpunit/tests/functions.php
r44478 r44481 1580 1580 1581 1581 /** 1582 * Test the human_readable_duration function.1582 * Test human_readable_duration(). 1583 1583 * 1584 1584 * @ticket 39667 1585 * @dataProvider _datahuman_readable_duration()1585 * @dataProvider data_test_human_readable_duration 1586 1586 * 1587 * @param $input1588 * @param $expected1589 */ 1590 public function test_ duration_format( $input, $expected ) {1587 * @param string $input Duration. 1588 * @param string $expected Expected human readable duration. 1589 */ 1590 public function test_human_readable_duration( $input, $expected ) { 1591 1591 $this>assertSame( $expected, human_readable_duration( $input ) ); 1592 1592 } 1593 1593 1594 public function _datahuman_readable_duration() { 1594 /** 1595 * Dataprovider for test_duration_format(). 1596 * 1597 * @return array { 1598 * @type array { 1599 * @type string $input Duration. 1600 * @type string $expect Expected human readable duration. 1601 * } 1602 * } 1603 */ 1604 public function data_test_human_readable_duration() { 1595 1605 return array( 1606 // Valid ii:ss cases. 1607 array( '0:0', '0 minutes, 0 seconds' ), 1608 array( '00:00', '0 minutes, 0 seconds' ), 1609 array( '0:5', '0 minutes, 5 seconds' ), 1610 array( '0:05', '0 minutes, 5 seconds' ), 1611 array( '01:01', '1 minute, 1 second' ), 1612 array( '30:00', '30 minutes, 0 seconds' ), 1613 array( ' 30:00 ', '30 minutes, 0 seconds' ), 1614 // Valid HH:ii:ss cases. 1615 array( '0:0:0', '0 hours, 0 minutes, 0 seconds' ), 1616 array( '00:00:00', '0 hours, 0 minutes, 0 seconds' ), 1617 array( '00:30:34', '0 hours, 30 minutes, 34 seconds' ), 1618 array( '01:01:01', '1 hour, 1 minute, 1 second' ), 1619 array( '1:02:00', '1 hour, 2 minutes, 0 seconds' ), 1620 array( '10:30:34', '10 hours, 30 minutes, 34 seconds' ), 1621 array( '1234567890:59:59', '1234567890 hours, 59 minutes, 59 seconds' ), 1622 // Valid ii:ss cases with negative sign. 1623 array( '00:00', '0 minutes, 0 seconds' ), 1624 array( '3:00', '3 minutes, 0 seconds' ), 1625 array( '03:00', '3 minutes, 0 seconds' ), 1626 array( '30:00', '30 minutes, 0 seconds' ), 1627 // Valid HH:ii:ss cases with negative sign. 1628 array( '00:00:00', '0 hours, 0 minutes, 0 seconds' ), 1629 array( '1:02:00', '1 hour, 2 minutes, 0 seconds' ), 1630 // Invalid cases. 1631 array( null, false ), 1632 array( '', false ), 1633 array( ':', false ), 1634 array( '::', false ), 1596 1635 array( array(), false ), 1597 array( '30:00', '30 minutes, 0 seconds' ),1598 1636 array( 'Batman Begins !', false ), 1599 1637 array( '', false ), … … 1603 1641 array( 1, false ), 1604 1642 array( '00', false ), 1605 array( '00:00', '0 minutes, 0 seconds' ), 1606 array( '00:00:00', '0 hours, 0 minutes, 0 seconds' ), 1607 array( '10:30:34', '10 hours, 30 minutes, 34 seconds' ), 1608 array( '00:30:34', '0 hours, 30 minutes, 34 seconds' ), 1609 array( 'MM:30:00', false ), 1610 array( '30:MM', false ), 1611 array( 'MM:00', false ), 1612 array( 'MM:MM', false ), 1613 array( '01:01', '1 minute, 1 second' ), 1614 array( '01:01:01', '1 hour, 1 minute, 1 second' ), 1615 array( '0:05', '5 seconds' ), 1616 array( '1:02:00', '1 hour, 2 minutes, 0 seconds' ), 1643 array( '30:10', false ), 1644 array( ':30:00', false ), // Missing HH. 1645 array( 'MM:30:00', false ), // Invalid HH. 1646 array( '30:MM:00', false ), // Invalid ii. 1647 array( '30:30:MM', false ), // Invalid ss. 1648 array( '30:MM', false ), // Invalid ss. 1649 array( 'MM:00', false ), // Invalid ii. 1650 array( 'MM:MM', false ), // Invalid ii and ss. 1651 array( '10 :30', false ), // Containing a space. 1652 array( '59:61', false ), // Out of bound. 1653 array( '61:59', false ), // Out of bound. 1654 array( '3:59:61', false ), // Out of bound. 1655 array( '03:61:59', false ), // Out of bound. 1617 1656 ); 1618 1657 }
Note: See TracChangeset
for help on using the changeset viewer.