/** * Assert string is valid XML. * * @param string $XML * @param string $message */ public static function assertXMLValid($XML, $message = '') { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLValid', array('assertThat')); self::assertThat($XML, new XMLValidConstraint(), $message); }
/** * @param mixed $filename * @param string $message * @param string $method * @param \PHPUnit_Framework_Constraint $constraint */ private static function assertFileExisting($filename, $message, $method, \PHPUnit_Framework_Constraint $constraint) { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, array('assertThat')); self::assertThat($filename, $constraint, $message); }
/** * @param int|float $lowerBoundary * @param int|float $upperBoundary * @param mixed $actual * @param string $message * @param string $method name of method doing the testing * @param bool $onBoundary test on boundary or between boundary values * @param bool $negative test as negative */ private static function assertNumberRangeMatch($lowerBoundary, $upperBoundary, $actual, $message, $method, $onBoundary, $negative) { if (!is_int($lowerBoundary) && !is_float($lowerBoundary)) { throw AssertHelper::createArgumentException(__TRAIT__, $method, 'float or int', $lowerBoundary); } if (!is_int($upperBoundary) && !is_float($upperBoundary)) { throw AssertHelper::createArgumentException(__TRAIT__, $method, 'float or int', $upperBoundary, 2); } if ($lowerBoundary >= $upperBoundary) { $message = sprintf('lower boundary %s must be smaller than upper boundary %s', is_int($lowerBoundary) ? '%d' : '%.3f', is_int($upperBoundary) ? '%d' : '%.3f'); throw AssertHelper::createException(__TRAIT__, $method, sprintf($message, $lowerBoundary, $upperBoundary)); } $rangeConstraint = new NumberRangeConstraint($lowerBoundary, $upperBoundary, $onBoundary); if ($negative) { $rangeConstraint = new \PHPUnit_Framework_Constraint_Not($rangeConstraint); } AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, array('assertThat')); self::assertThat($actual, $rangeConstraint, $message); }
/** * @param int $permissionMask * @param mixed $filename * @param string $method * @param bool $positive * @param string $message */ private static function filePermissionMask($permissionMask, $filename, $method, $positive, $message = '') { if (!is_int($permissionMask)) { throw AssertHelper::createArgumentException(__TRAIT__, $method, 'int', $permissionMask); } $constraint = new FilePermissionsMaskConstraint($permissionMask); self::assertThatConstraint($filename, $message, $method, $positive ? $constraint : new \PHPUnit_Framework_Constraint_Not($constraint)); }
/** * @param mixed $actual * @param string $message * @param string $method * @param \PHPUnit_Framework_Constraint $constraint */ private static function assertTypeOfScalar($actual, $message, $method, \PHPUnit_Framework_Constraint $constraint) { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, array('assertThat')); self::assertThat($actual, $constraint, $message); }