|
@@ 63-82 (lines=20) @@
|
| 60 |
|
* |
| 61 |
|
* @since Method available since Release 4.4.0 |
| 62 |
|
*/ |
| 63 |
|
public static function assertArraySubset($subset, $array, $strict = false, $message = '') |
| 64 |
|
{ |
| 65 |
|
if (!is_array($subset)) { |
| 66 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory( |
| 67 |
|
1, |
| 68 |
|
'array or ArrayAccess' |
| 69 |
|
); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
if (!is_array($array)) { |
| 73 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory( |
| 74 |
|
2, |
| 75 |
|
'array or ArrayAccess' |
| 76 |
|
); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
$constraint = new PHPUnit_Framework_Constraint_ArraySubset($subset, $strict); |
| 80 |
|
|
| 81 |
|
self::assertThat($array, $constraint, $message); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
/** |
| 85 |
|
* Asserts that an array does not have a specified key. |
|
@@ 1449-1462 (lines=14) @@
|
| 1446 |
|
* @param string $string |
| 1447 |
|
* @param string $message |
| 1448 |
|
*/ |
| 1449 |
|
public static function assertRegExp($pattern, $string, $message = '') |
| 1450 |
|
{ |
| 1451 |
|
if (!is_string($pattern)) { |
| 1452 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1453 |
|
} |
| 1454 |
|
|
| 1455 |
|
if (!is_string($string)) { |
| 1456 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1457 |
|
} |
| 1458 |
|
|
| 1459 |
|
$constraint = new PHPUnit_Framework_Constraint_PCREMatch($pattern); |
| 1460 |
|
|
| 1461 |
|
self::assertThat($string, $constraint, $message); |
| 1462 |
|
} |
| 1463 |
|
|
| 1464 |
|
/** |
| 1465 |
|
* Asserts that a string does not match a given regular expression. |
|
@@ 1473-1488 (lines=16) @@
|
| 1470 |
|
* |
| 1471 |
|
* @since Method available since Release 2.1.0 |
| 1472 |
|
*/ |
| 1473 |
|
public static function assertNotRegExp($pattern, $string, $message = '') |
| 1474 |
|
{ |
| 1475 |
|
if (!is_string($pattern)) { |
| 1476 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1477 |
|
} |
| 1478 |
|
|
| 1479 |
|
if (!is_string($string)) { |
| 1480 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1481 |
|
} |
| 1482 |
|
|
| 1483 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1484 |
|
new PHPUnit_Framework_Constraint_PCREMatch($pattern) |
| 1485 |
|
); |
| 1486 |
|
|
| 1487 |
|
self::assertThat($string, $constraint, $message); |
| 1488 |
|
} |
| 1489 |
|
|
| 1490 |
|
/** |
| 1491 |
|
* Assert that the size of two arrays (or `Countable` or `Traversable` objects) |
|
@@ 1557-1570 (lines=14) @@
|
| 1554 |
|
* |
| 1555 |
|
* @since Method available since Release 3.5.0 |
| 1556 |
|
*/ |
| 1557 |
|
public static function assertStringMatchesFormat($format, $string, $message = '') |
| 1558 |
|
{ |
| 1559 |
|
if (!is_string($format)) { |
| 1560 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1561 |
|
} |
| 1562 |
|
|
| 1563 |
|
if (!is_string($string)) { |
| 1564 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1565 |
|
} |
| 1566 |
|
|
| 1567 |
|
$constraint = new PHPUnit_Framework_Constraint_StringMatches($format); |
| 1568 |
|
|
| 1569 |
|
self::assertThat($string, $constraint, $message); |
| 1570 |
|
} |
| 1571 |
|
|
| 1572 |
|
/** |
| 1573 |
|
* Asserts that a string does not match a given format string. |
|
@@ 1581-1596 (lines=16) @@
|
| 1578 |
|
* |
| 1579 |
|
* @since Method available since Release 3.5.0 |
| 1580 |
|
*/ |
| 1581 |
|
public static function assertStringNotMatchesFormat($format, $string, $message = '') |
| 1582 |
|
{ |
| 1583 |
|
if (!is_string($format)) { |
| 1584 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1585 |
|
} |
| 1586 |
|
|
| 1587 |
|
if (!is_string($string)) { |
| 1588 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1589 |
|
} |
| 1590 |
|
|
| 1591 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1592 |
|
new PHPUnit_Framework_Constraint_StringMatches($format) |
| 1593 |
|
); |
| 1594 |
|
|
| 1595 |
|
self::assertThat($string, $constraint, $message); |
| 1596 |
|
} |
| 1597 |
|
|
| 1598 |
|
/** |
| 1599 |
|
* Asserts that a string matches a given format file. |
|
@@ 1657-1672 (lines=16) @@
|
| 1654 |
|
* |
| 1655 |
|
* @since Method available since Release 3.4.0 |
| 1656 |
|
*/ |
| 1657 |
|
public static function assertStringStartsWith($prefix, $string, $message = '') |
| 1658 |
|
{ |
| 1659 |
|
if (!is_string($prefix)) { |
| 1660 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1661 |
|
} |
| 1662 |
|
|
| 1663 |
|
if (!is_string($string)) { |
| 1664 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1665 |
|
} |
| 1666 |
|
|
| 1667 |
|
$constraint = new PHPUnit_Framework_Constraint_StringStartsWith( |
| 1668 |
|
$prefix |
| 1669 |
|
); |
| 1670 |
|
|
| 1671 |
|
self::assertThat($string, $constraint, $message); |
| 1672 |
|
} |
| 1673 |
|
|
| 1674 |
|
/** |
| 1675 |
|
* Asserts that a string starts not with a given prefix. |
|
@@ 1683-1698 (lines=16) @@
|
| 1680 |
|
* |
| 1681 |
|
* @since Method available since Release 3.4.0 |
| 1682 |
|
*/ |
| 1683 |
|
public static function assertStringStartsNotWith($prefix, $string, $message = '') |
| 1684 |
|
{ |
| 1685 |
|
if (!is_string($prefix)) { |
| 1686 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1687 |
|
} |
| 1688 |
|
|
| 1689 |
|
if (!is_string($string)) { |
| 1690 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1691 |
|
} |
| 1692 |
|
|
| 1693 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1694 |
|
new PHPUnit_Framework_Constraint_StringStartsWith($prefix) |
| 1695 |
|
); |
| 1696 |
|
|
| 1697 |
|
self::assertThat($string, $constraint, $message); |
| 1698 |
|
} |
| 1699 |
|
|
| 1700 |
|
/** |
| 1701 |
|
* Asserts that a string ends with a given suffix. |
|
@@ 1709-1722 (lines=14) @@
|
| 1706 |
|
* |
| 1707 |
|
* @since Method available since Release 3.4.0 |
| 1708 |
|
*/ |
| 1709 |
|
public static function assertStringEndsWith($suffix, $string, $message = '') |
| 1710 |
|
{ |
| 1711 |
|
if (!is_string($suffix)) { |
| 1712 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1713 |
|
} |
| 1714 |
|
|
| 1715 |
|
if (!is_string($string)) { |
| 1716 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1717 |
|
} |
| 1718 |
|
|
| 1719 |
|
$constraint = new PHPUnit_Framework_Constraint_StringEndsWith($suffix); |
| 1720 |
|
|
| 1721 |
|
self::assertThat($string, $constraint, $message); |
| 1722 |
|
} |
| 1723 |
|
|
| 1724 |
|
/** |
| 1725 |
|
* Asserts that a string ends not with a given suffix. |
|
@@ 1733-1748 (lines=16) @@
|
| 1730 |
|
* |
| 1731 |
|
* @since Method available since Release 3.4.0 |
| 1732 |
|
*/ |
| 1733 |
|
public static function assertStringEndsNotWith($suffix, $string, $message = '') |
| 1734 |
|
{ |
| 1735 |
|
if (!is_string($suffix)) { |
| 1736 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1737 |
|
} |
| 1738 |
|
|
| 1739 |
|
if (!is_string($string)) { |
| 1740 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string'); |
| 1741 |
|
} |
| 1742 |
|
|
| 1743 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1744 |
|
new PHPUnit_Framework_Constraint_StringEndsWith($suffix) |
| 1745 |
|
); |
| 1746 |
|
|
| 1747 |
|
self::assertThat($string, $constraint, $message); |
| 1748 |
|
} |
| 1749 |
|
|
| 1750 |
|
/** |
| 1751 |
|
* Asserts that two XML files are equal. |