Initial commit,修正
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use function gettype;
|
||||
use function sprintf;
|
||||
|
||||
final class InvalidVerifyException extends InvalidArgumentException
|
||||
{
|
||||
public function __construct($verifyName, $actual)
|
||||
{
|
||||
$message = sprintf(
|
||||
"%s type cannot be used with %s verify.",
|
||||
gettype($actual),
|
||||
$verifyName
|
||||
);
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Asserts;
|
||||
|
||||
use Exception;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use Throwable;
|
||||
|
||||
trait AssertThrows
|
||||
{
|
||||
public function assertThrows($throws = null, $message = false): self
|
||||
{
|
||||
if ($throws instanceof Exception) {
|
||||
$message = $throws->getMessage();
|
||||
$throws = get_class($throws);
|
||||
}
|
||||
|
||||
try {
|
||||
call_user_func($this->actual);
|
||||
} catch (Throwable $throwable) {
|
||||
if (!$throws) {
|
||||
return $this; // it throws
|
||||
}
|
||||
|
||||
$actualThrows = get_class($throwable);
|
||||
$actualMessage = $throwable->getMessage();
|
||||
|
||||
Assert::assertSame($throws, $actualThrows, sprintf("exception '%s' was expected, but '%s' was thrown", $throws, $actualThrows));
|
||||
|
||||
if ($message) {
|
||||
Assert::assertSame($message, $actualMessage, sprintf("exception message '%s' was expected, but '%s' was received", $message, $actualMessage));
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($throwable)) {
|
||||
throw new ExpectationFailedException(sprintf("exception '%s' was not thrown as expected", $throws));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function assertDoesNotThrow($throws = null, $message = false): self
|
||||
{
|
||||
if ($throws instanceof Exception) {
|
||||
$message = $throws->getMessage();
|
||||
$throws = get_class($throws);
|
||||
}
|
||||
|
||||
try {
|
||||
call_user_func($this->actual);
|
||||
} catch (Throwable $exception) {
|
||||
if (!$throws) {
|
||||
throw new ExpectationFailedException('exception was not expected to be thrown');
|
||||
}
|
||||
|
||||
$actualThrows = get_class($exception);
|
||||
$actualMessage = $exception->getMessage();
|
||||
|
||||
if ($throws !== $actualThrows) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$message) {
|
||||
throw new ExpectationFailedException(sprintf("exception '%s' was not expected to be thrown", $throws));
|
||||
}
|
||||
|
||||
if ($message === $actualMessage) {
|
||||
throw new ExpectationFailedException(sprintf("exception '%s' with message '%s' was not expected to be thrown", $throws, $message));
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify;
|
||||
|
||||
use ArrayAccess;
|
||||
use Codeception\Verify\Expectations\ExpectArray;
|
||||
use Codeception\Verify\Expectations\ExpectBaseObject;
|
||||
use Codeception\Verify\Expectations\ExpectCallable;
|
||||
use Codeception\Verify\Expectations\ExpectClass;
|
||||
use Codeception\Verify\Expectations\ExpectDirectory;
|
||||
use Codeception\Verify\Expectations\ExpectFile;
|
||||
use Codeception\Verify\Expectations\ExpectJsonFile;
|
||||
use Codeception\Verify\Expectations\ExpectJsonString;
|
||||
use Codeception\Verify\Expectations\ExpectString;
|
||||
use Codeception\Verify\Expectations\ExpectXmlFile;
|
||||
use Codeception\Verify\Expectations\ExpectXmlString;
|
||||
use Countable;
|
||||
|
||||
abstract class Expect
|
||||
{
|
||||
/** @var mixed */
|
||||
protected $actual = null;
|
||||
|
||||
/**
|
||||
* Expect constructor
|
||||
*
|
||||
* @param mixed $actual
|
||||
*/
|
||||
protected function __construct($actual)
|
||||
{
|
||||
$this->actual = $actual;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return self
|
||||
*/
|
||||
public function __invoke($actual): self
|
||||
{
|
||||
return $this($actual);
|
||||
}
|
||||
|
||||
public static function File(string $filename): ExpectFile
|
||||
{
|
||||
return new ExpectFile($filename);
|
||||
}
|
||||
|
||||
public static function JsonFile(string $filename): ExpectJsonFile
|
||||
{
|
||||
return new ExpectJsonFile($filename);
|
||||
}
|
||||
|
||||
public static function JsonString(string $json): ExpectJsonString
|
||||
{
|
||||
return new ExpectJsonString($json);
|
||||
}
|
||||
|
||||
public static function XmlFile(string $filename): ExpectXmlFile
|
||||
{
|
||||
return new ExpectXmlFile($filename);
|
||||
}
|
||||
|
||||
public static function XmlString(string $xml): ExpectXmlString
|
||||
{
|
||||
return new ExpectXmlString($xml);
|
||||
}
|
||||
|
||||
public static function BaseObject(object $object): ExpectBaseObject
|
||||
{
|
||||
return new ExpectBaseObject($object);
|
||||
}
|
||||
|
||||
public static function Class(string $className): ExpectClass
|
||||
{
|
||||
return new ExpectClass($className);
|
||||
}
|
||||
|
||||
public static function Directory(string $directory): ExpectDirectory
|
||||
{
|
||||
return new ExpectDirectory($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|ArrayAccess|Countable|iterable $array
|
||||
* @return ExpectArray
|
||||
*/
|
||||
public static function Array($array): ExpectArray
|
||||
{
|
||||
return new ExpectArray($array);
|
||||
}
|
||||
|
||||
public static function String(string $string): ExpectString
|
||||
{
|
||||
return new ExpectString($string);
|
||||
}
|
||||
|
||||
public static function Callable(callable $callable): ExpectCallable
|
||||
{
|
||||
return new ExpectCallable($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return ExpectCallable
|
||||
*/
|
||||
public static function Mixed($actual): ExpectCallable
|
||||
{
|
||||
return new ExpectCallable($actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
|
||||
class ExpectAny extends ExpectMixed
|
||||
{
|
||||
public function arrayToContain($needle, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toContain($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayToContainEqual($needle, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toContainEqual($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayToContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toContainOnly($type, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayToContainOnlyInstancesOf(string $className, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toContainOnlyInstancesOf($className, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayToHaveCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toHaveCount($expectedCount, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayToHaveKey($key, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toHaveKey($key, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotToHaveKey($key, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->notToHaveKey($key, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotToContain($needle, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->notToContain($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotToContainEqual($needle, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->notToContainEqual($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotToContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->notToContainOnly($type, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotToHaveCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->notToHaveCount($expectedCount, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotToHaveSameSizeAs($expected, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->notToHaveSameSizeAs($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayToHaveSameSizeAs($expected, string $message = ''): self
|
||||
{
|
||||
Expect::Array($this->actual)->toHaveSameSizeAs($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function baseObjectToHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Expect::BaseObject($this->actual)->toHaveAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function baseObjectNotToHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Expect::BaseObject($this->actual)->notToHaveAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function callableToThrow($throws = null, string $message = ''): self
|
||||
{
|
||||
Expect::Callable($this->actual)->toThrow($throws, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function callableNotToThrow($throws = null, string $message = ''): self
|
||||
{
|
||||
Expect::Callable($this->actual)->notToThrow($throws, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classToHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Expect::Class($this->actual)->toHaveAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classToHaveStaticAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Expect::Class($this->actual)->toHaveStaticAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classNotToHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Expect::Class($this->actual)->notToHaveAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classNotToHaveStaticAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Expect::Class($this->actual)->notToHaveStaticAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryNotToExist(string $message = ''): self
|
||||
{
|
||||
Expect::Directory($this->actual)->notToExist($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryToExist(string $message = ''): self
|
||||
{
|
||||
Expect::Directory($this->actual)->toExist($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryNotToBeReadable(string $message = ''): self
|
||||
{
|
||||
Expect::Directory($this->actual)->notToBeReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryNotToBeWritable(string $message = ''): self
|
||||
{
|
||||
Expect::Directory($this->actual)->notToBeWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryToBeReadable(string $message = ''): self
|
||||
{
|
||||
Expect::Directory($this->actual)->toBeReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryToBeWritable(string $message = ''): self
|
||||
{
|
||||
Expect::Directory($this->actual)->toBeWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileNotToExist(string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->notToExist($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToBeEqual(string $expected, string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toBeEqual($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToBeEqualCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toBeEqualCanonicalizing($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToBeEqualIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toBeEqualIgnoringCase($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToExist(string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toExist($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileNotToBeReadable(string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->notToBeReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileNotToBeWritable(string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->notToBeWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToBeReadable(string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toBeReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToBeWritable(string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toBeWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToNotEqual(string $expected, string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toNotEqual($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToNotEqualCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toNotEqualCanonicalizing($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileToNotEqualIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Expect::File($this->actual)->toNotEqualIgnoringCase($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonFileToEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::JsonFile($this->actual)->toEqualJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonFileNotToEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::JsonFile($this->actual)->notToEqualJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringToEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::JsonString($this->actual)->toEqualJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringToEqualJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Expect::JsonString($this->actual)->toEqualJsonString($expectedJson, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringNotToEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::JsonString($this->actual)->notToEqualJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringNotToEqualJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Expect::JsonString($this->actual)->notToEqualJsonString($expectedJson, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToContainString(string $needle, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toContainString($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToContainStringIgnoringCase($needle, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toContainStringIgnoringCase($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToMatchRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToMatchRegExp($pattern, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToEndWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toEndWith($suffix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToEqualFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toEqualFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toEqualFileCanonicalizing($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toEqualFileIgnoringCase($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToBeJson(string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toBeJson($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToMatchFormat(string $format, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toMatchFormat($format, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToMatchFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toMatchFormatFile($formatFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToMatchRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toMatchRegExp($pattern, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToContainString(string $needle, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToContainString($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToContainStringIgnoringCase(string $needle, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToContainStringIgnoringCase($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToEndWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToEndWith($suffix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToEqualFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToEqualFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToEqualFileCanonicalizing($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToEqualFileIgnoringCase($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToMatchFormat($format, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToMatchFormat($format, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToMatchFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToMatchFormatFile($formatFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotToStartWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->notToStartWith($prefix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringToStartWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Expect::String($this->actual)->toStartWith($prefix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlFileToEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::XmlFile($this->actual)->toEqualXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlFileNotToEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::XmlFile($this->actual)->notToEqualXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringToEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::XmlString($this->actual)->toEqualXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringToEqualXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Expect::XmlString($this->actual)->toEqualXmlString($expectedXml, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringNotToEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Expect::XmlString($this->actual)->notToEqualXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringNotToEqualXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Expect::XmlString($this->actual)->notToEqualXmlString($expectedXml, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use ArrayAccess;
|
||||
use Codeception\Exception\InvalidVerifyException;
|
||||
use Codeception\Verify\Expect;
|
||||
use Countable;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use function basename;
|
||||
use function is_array;
|
||||
use function is_iterable;
|
||||
|
||||
class ExpectArray extends Expect
|
||||
{
|
||||
/**
|
||||
* ExpectArray constructor
|
||||
*
|
||||
* @param array|ArrayAccess|Countable|iterable $actual
|
||||
*/
|
||||
public function __construct($actual)
|
||||
{
|
||||
if (
|
||||
is_array($actual) ||
|
||||
$actual instanceof ArrayAccess ||
|
||||
$actual instanceof Countable ||
|
||||
is_iterable($actual)
|
||||
) {
|
||||
parent::__construct($actual);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidVerifyException(basename(self::class), $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a haystack does not contain a needle.
|
||||
*
|
||||
* @param $needle
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToContain($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotContains($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notToContainEqual($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotContainsEquals($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a haystack does not contain only values of a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param bool|null $isNativeType
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotContainsOnly($type, $this->actual, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect the number of elements of an array, Countable or Traversable.
|
||||
*
|
||||
* @param int $expectedCount
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToHaveCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotCount($expectedCount, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that an array does not have a specified key.
|
||||
*
|
||||
* @param int|string $key
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToHaveKey($key, string $message = ''): self
|
||||
{
|
||||
Assert::assertArrayNotHasKey($key, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
|
||||
*
|
||||
* @param Countable|iterable $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToHaveSameSizeAs($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotSameSize($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a haystack contains a needle.
|
||||
*
|
||||
* @param $needle
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toContain($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertContains($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toContainEqual($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertContainsEquals($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a haystack contains only values of a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param bool|null $isNativeType
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toContainOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Assert::assertContainsOnly($type, $this->actual, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a haystack contains only instances of a given class name.
|
||||
*
|
||||
* @param string $className
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toContainOnlyInstancesOf(string $className, string $message = ''): self
|
||||
{
|
||||
Assert::assertContainsOnlyInstancesOf($className, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect the number of elements of an array, Countable or Traversable.
|
||||
*
|
||||
* @param int $expectedCount
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toHaveCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Assert::assertCount($expectedCount, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that an array has a specified key.
|
||||
*
|
||||
* @param int|string $key
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toHaveKey($key, string $message = ''): self
|
||||
{
|
||||
Assert::assertArrayHasKey($key, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
|
||||
*
|
||||
* @param Countable|iterable $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toHaveSameSizeAs($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertSameSize($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectBaseObject extends Expect
|
||||
{
|
||||
use ExpectDataTrait;
|
||||
|
||||
/**
|
||||
* ExpectBaseObject constructor
|
||||
*
|
||||
* @param object $object
|
||||
*/
|
||||
public function __construct(object $object)
|
||||
{
|
||||
parent::__construct($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that an object does not have a specified attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertObjectNotHasAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that an object has a specified attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertObjectHasAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Asserts\AssertThrows;
|
||||
use Codeception\Verify\Expect;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class ExpectCallable extends Expect
|
||||
{
|
||||
use AssertThrows;
|
||||
|
||||
public function __construct(callable $callable)
|
||||
{
|
||||
parent::__construct($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception|string|null $throws
|
||||
* @param string|false $message
|
||||
* @return $this
|
||||
*/
|
||||
public function notToThrow($throws = null, $message = false): self
|
||||
{
|
||||
return $this->assertDoesNotThrow($throws, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception|string|null $throws
|
||||
* @param string|false $message
|
||||
* @return ExpectCallable
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function toThrow($throws = null, $message = false): self
|
||||
{
|
||||
return $this->assertThrows($throws, $message);
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use Codeception\Verify\Verifiers\VerifyDataTrait;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectClass extends Expect
|
||||
{
|
||||
use VerifyDataTrait;
|
||||
|
||||
/**
|
||||
* ExpectClass constructor
|
||||
*
|
||||
* @param string $className
|
||||
*/
|
||||
public function __construct(string $className)
|
||||
{
|
||||
parent::__construct($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a class does not have a specified attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertClassNotHasAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a class does not have a specified static attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToHaveStaticAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertClassNotHasStaticAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a class has a specified attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toHaveAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertClassHasAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a class has a specified static attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toHaveStaticAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertClassHasStaticAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
trait ExpectDataTrait
|
||||
{
|
||||
/**
|
||||
* Expect that a file/dir is not readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file/dir is not writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file/dir is readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file/dir is writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectDirectory extends Expect
|
||||
{
|
||||
use ExpectDataTrait;
|
||||
|
||||
/**
|
||||
* ExpectDirectory constructor
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
public function __construct(string $directory)
|
||||
{
|
||||
parent::__construct($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a directory does not exist.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToExist(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryDoesNotExist($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a directory exists.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExist(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryExists($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a directory exists and is not readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndNotToBeReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsNotReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a directory exists and is not writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndNotToBeWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsNotWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a directory exists and is readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndToBeReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a directory exists and is writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndToBeWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectFile extends Expect
|
||||
{
|
||||
use ExpectDataTrait;
|
||||
|
||||
public function __construct(string $actual)
|
||||
{
|
||||
parent::__construct($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file does not exist.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToExist(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileDoesNotExist($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of one file is equal to the contents of another file.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeEqual(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of one file is equal to the contents of another file (canonicalizing).
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeEqualCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of one file is equal to the contents of another file (ignoring case).
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeEqualIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file exists.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExist(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileExists($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file exists and is not readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndNotToBeReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsNotReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file exists and is not writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndNotToBeWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsNotWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file exists and is readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndToBeReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a file exists and is writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toExistAndToBeWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of one file is not equal to the contents of another file.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toNotEqual(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileNotEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of one file is not equal to the contents of another file (canonicalizing).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toNotEqualCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileNotEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of one file is not equal to the contents of another file (ignoring case).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toNotEqualIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileNotEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectJsonFile extends Expect
|
||||
{
|
||||
public function __construct(string $actualFile)
|
||||
{
|
||||
parent::__construct($actualFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two JSON files are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonFileNotEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two JSON files are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonFileEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectJsonString extends Expect
|
||||
{
|
||||
public function __construct(string $actualJson)
|
||||
{
|
||||
parent::__construct($actualJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the generated JSON encoded object and the content of the given file are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringNotEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two given JSON encoded objects or arrays are not equal.
|
||||
*
|
||||
* @param string $expectedJson
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringNotEqualsJsonString($expectedJson, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the generated JSON encoded object and the content of the given file are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two given JSON encoded objects or arrays are equal.
|
||||
*
|
||||
* @param string $expectedJson
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringEqualsJsonString($expectedJson, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+651
@@ -0,0 +1,651 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectMixed extends Expect
|
||||
{
|
||||
/**
|
||||
* ExpectMixed constructor.
|
||||
*
|
||||
* @param mixed $actual
|
||||
*/
|
||||
public function __construct($actual)
|
||||
{
|
||||
parent::__construct($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables do not have the same type and value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBe($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotSame($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type array.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeArray(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotArray($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type bool.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeBool(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotBool($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type callable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeCallable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotCallable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeClosedResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotClosedResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not empty.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeEmpty(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEmpty($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a condition is not false.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeFalse(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotFalse($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type float.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeFloat(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotFloat($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of a given type.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeInstanceOf(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotInstanceOf($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type int.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeInt(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotInt($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type iterable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeIterable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotIterable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not null.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeNull(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotNull($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type numeric.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeNumeric(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotNumeric($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type object.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeObject(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotObject($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type scalar.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeScalar(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotScalar($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is not of type string.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeString(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotString($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a condition is not true.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToBeTrue(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotTrue($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are not equal.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqual($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are not equal (canonicalizing).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualCanonicalizing($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are not equal (ignoring case).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualIgnoringCase($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are not equal (with delta).
|
||||
*
|
||||
* @param $expected
|
||||
* @param float $delta
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualWithDelta($expected, float $delta, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEqualsWithDelta($expected, $this->actual, $delta, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables have the same type and value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBe($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertSame($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type array.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeArray(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsArray($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type bool.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeBool(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsBool($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type callable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeCallable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsCallable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type resource and is closed.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeClosedResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsClosedResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is empty.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeEmpty(string $message = ''): self
|
||||
{
|
||||
Assert::assertEmpty($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a condition is false.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeFalse(string $message = ''): self
|
||||
{
|
||||
Assert::assertFalse($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is finite.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeFinite(string $message = ''): self
|
||||
{
|
||||
Assert::assertFinite($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type float.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeFloat(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsFloat($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a value is greater than another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeGreaterThan($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertGreaterThan($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a value is greater than or equal to another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeGreaterThanOrEqualTo($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertGreaterThanOrEqual($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is infinite.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeInfinite(string $message = ''): self
|
||||
{
|
||||
Assert::assertInfinite($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of a given type.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeInstanceOf(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertInstanceOf($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type int.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeInt(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsInt($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type iterable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeIterable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsIterable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a value is smaller than another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeLessThan($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertLessThan($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a value is smaller than or equal to another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeLessThanOrEqualTo($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertLessThanOrEqual($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is nan.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeNan(string $message = ''): self
|
||||
{
|
||||
Assert::assertNan($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is null.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeNull(string $message = ''): self
|
||||
{
|
||||
Assert::assertNull($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type numeric.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeNumeric(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNumeric($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type object.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeObject(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsObject($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type scalar.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeScalar(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsScalar($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a variable is of type string.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeString(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsString($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a condition is true.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeTrue(string $message = ''): self
|
||||
{
|
||||
Assert::assertTrue($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are equal.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqual($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are equal (canonicalizing).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualCanonicalizing($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are equal (ignoring case).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualIgnoringCase($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two variables are equal (with delta).
|
||||
*
|
||||
* @param $expected
|
||||
* @param float $delta
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualWithDelta($expected, float $delta, string $message = ''): self
|
||||
{
|
||||
Assert::assertEqualsWithDelta($expected, $this->actual, $delta, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectString extends Expect
|
||||
{
|
||||
public function __construct(string $string)
|
||||
{
|
||||
parent::__construct($string);
|
||||
}
|
||||
|
||||
public function notToContainString(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotContainsString($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notToContainStringIgnoringCase(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotContainsStringIgnoringCase($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string ends not with a given suffix.
|
||||
*
|
||||
* @param string $suffix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEndWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEndsNotWith($suffix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of a string is not equal to the contents of a file.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotEqualsFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of a string is not equal to the contents of a file (canonicalizing).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of a string is not equal to the contents of a file (ignoring case).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string does not match a given format string.
|
||||
*
|
||||
* @param $format
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToMatchFormat(string $format, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotMatchesFormat($format, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string does not match a given format string.
|
||||
*
|
||||
* @param string $formatFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToMatchFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotMatchesFormatFile($formatFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string does not match a given regular expression.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToMatchRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Assert::assertDoesNotMatchRegularExpression($pattern, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string starts not with a given prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToStartWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringStartsNotWith($prefix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string is a valid JSON string.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toBeJson(string $message = ''): self
|
||||
{
|
||||
Assert::assertJson($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toContainString(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringContainsString($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toContainStringIgnoringCase(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringContainsStringIgnoringCase($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string ends with a given suffix.
|
||||
*
|
||||
* @param string $suffix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEndWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEndsWith($suffix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of a string is equal to the contents of a file.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEqualsFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of a string is equal to the contents of a file (canonicalizing).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that the contents of a string is equal to the contents of a file (ignoring case).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string matches a given format string.
|
||||
*
|
||||
* @param string $format
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toMatchFormat(string $format, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringMatchesFormat($format, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string matches a given format file.
|
||||
*
|
||||
* @param string $formatFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toMatchFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringMatchesFormatFile($formatFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string matches a given regular expression.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toMatchRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Assert::assertMatchesRegularExpression($pattern, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that a string starts with a given prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toStartWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringStartsWith($prefix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Verify\Expect;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class ExpectXmlFile extends Expect
|
||||
{
|
||||
public function __construct(string $actualFile)
|
||||
{
|
||||
parent::__construct($actualFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two XML files are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two XML files are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlFileEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Expectations;
|
||||
|
||||
use Codeception\Exception\InvalidVerifyException;
|
||||
use Codeception\Verify\Expect;
|
||||
use DOMDocument;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use function basename;
|
||||
use function is_string;
|
||||
|
||||
class ExpectXmlString extends Expect
|
||||
{
|
||||
/**
|
||||
* ExpectXmlString constructor
|
||||
*
|
||||
* @param DOMDocument|string $actualXml
|
||||
*/
|
||||
public function __construct($actualXml)
|
||||
{
|
||||
if (is_string($actualXml) || $actualXml instanceof DOMDocument) {
|
||||
parent::__construct($actualXml);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidVerifyException(basename(self::class), $actualXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two XML documents are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two XML documents are not equal.
|
||||
*
|
||||
* @param DOMDocument|string $expectedXml
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notToEqualXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringNotEqualsXmlString($expectedXml, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two XML documents are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect that two XML documents are equal.
|
||||
*
|
||||
* @param DOMDocument|string $expectedXml
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function toEqualXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringEqualsXmlString($expectedXml, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
|
||||
class VerifyAny extends VerifyMixed
|
||||
{
|
||||
public function arrayContains($needle, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->contains($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayContainsEquals($needle, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->containsEquals($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->containsOnly($type, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayContainsOnlyInstancesOf(string $className, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->containsOnlyInstancesOf($className, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->count($expectedCount, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayHasKey($key, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->hasKey($key, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayHasNotKey($key, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->hasNotKey($key, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotContains($needle, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->notContains($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotContainsEquals($needle, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->notContainsEquals($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->notContainsOnly($type, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->notCount($expectedCount, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arrayNotSameSize($expected, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->notSameSize($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function arraySameSize($expected, string $message = ''): self
|
||||
{
|
||||
Verify::Array($this->actual)->sameSize($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function baseObjectHasAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Verify::BaseObject($this->actual)->hasAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function baseObjectNotHasAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Verify::BaseObject($this->actual)->notHasAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function callableThrows($throws = null, string $message = ''): self
|
||||
{
|
||||
Verify::Callable($this->actual)->throws($throws, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function callableDoesNotThrow($throws = null, string $message = ''): self
|
||||
{
|
||||
Verify::Callable($this->actual)->doesNotThrow($throws, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classHasAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Verify::Class($this->actual)->hasAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classHasStaticAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Verify::Class($this->actual)->hasStaticAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classNotHasAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Verify::Class($this->actual)->notHasAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function classNotHasStaticAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Verify::Class($this->actual)->notHasStaticAttribute($attributeName, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryDoesNotExist(string $message = ''): self
|
||||
{
|
||||
Verify::Directory($this->actual)->doesNotExist($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryExists(string $message = ''): self
|
||||
{
|
||||
Verify::Directory($this->actual)->exists($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryIsNotReadable(string $message = ''): self
|
||||
{
|
||||
Verify::Directory($this->actual)->isNotReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryIsNotWritable(string $message = ''): self
|
||||
{
|
||||
Verify::Directory($this->actual)->isNotWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryIsReadable(string $message = ''): self
|
||||
{
|
||||
Verify::Directory($this->actual)->isReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function directoryIsWritable(string $message = ''): self
|
||||
{
|
||||
Verify::Directory($this->actual)->isWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileDoesNotExists(string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->doesNotExists($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileEquals(string $expected, string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->equals($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileEqualsCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->equalsCanonicalizing($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileEqualsIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->equalsIgnoringCase($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileExists(string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->exists($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileIsNotReadable(string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->isNotReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileIsNotWritable(string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->isNotWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileIsReadable(string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->isReadable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileIsWritable(string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->isWritable($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileNotEquals(string $expected, string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->notEquals($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileNotEqualsCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->notEqualsCanonicalizing($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fileNotEqualsIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Verify::File($this->actual)->notEqualsIgnoringCase($expected, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonFileEqualsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::JsonFile($this->actual)->equalsJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonFileNotEqualsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::JsonFile($this->actual)->notEqualsJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringEqualsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::JsonString($this->actual)->equalsJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringEqualsJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Verify::JsonString($this->actual)->equalsJsonString($expectedJson, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringNotEqualsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::JsonString($this->actual)->notEqualsJsonFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonStringNotEqualsJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Verify::JsonString($this->actual)->notEqualsJsonString($expectedJson, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringContainsString(string $needle, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->containsString($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringContainsStringIgnoringCase($needle, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->containsStringIgnoringCase($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringDoesNotMatchRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->doesNotMatchRegExp($pattern, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringEndsWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->endsWith($suffix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringEqualsFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->equalsFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->equalsFileCanonicalizing($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->equalsFileIgnoringCase($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringJson(string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->json($message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringMatchesFormat(string $format, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->matchesFormat($format, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringMatchesFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->matchesFormatFile($formatFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringMatchesRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->matchesRegExp($pattern, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotContainsString(string $needle, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notContainsString($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotContainsStringIgnoringCase(string $needle, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notContainsStringIgnoringCase($needle, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotEndsWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notEndsWith($suffix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotEqualsFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notEqualsFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notEqualsFileCanonicalizing($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notEqualsFileIgnoringCase($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotMatchesFormat($format, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notMatchesFormat($format, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringNotMatchesFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->notMatchesFormatFile($formatFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringStartsNotWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->startsNotWith($prefix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringStartsWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Verify::String($this->actual)->startsWith($prefix, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlFileEqualsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::XmlFile($this->actual)->equalsXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlFileNotEqualsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::XmlFile($this->actual)->notEqualsXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringEqualsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::XmlString($this->actual)->equalsXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringEqualsXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Verify::XmlString($this->actual)->equalsXmlString($expectedXml, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringNotEqualsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Verify::XmlString($this->actual)->notEqualsXmlFile($expectedFile, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function xmlStringNotEqualsXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Verify::XmlString($this->actual)->notEqualsXmlString($expectedXml, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use ArrayAccess;
|
||||
use Codeception\Exception\InvalidVerifyException;
|
||||
use Codeception\Verify\Verify;
|
||||
use Countable;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use function basename;
|
||||
use function is_array;
|
||||
use function is_iterable;
|
||||
|
||||
class VerifyArray extends Verify
|
||||
{
|
||||
/**
|
||||
* VerifyArray constructor
|
||||
*
|
||||
* @param array|ArrayAccess|Countable|iterable $actual
|
||||
*/
|
||||
public function __construct($actual)
|
||||
{
|
||||
if (
|
||||
is_array($actual) ||
|
||||
$actual instanceof ArrayAccess ||
|
||||
$actual instanceof Countable ||
|
||||
is_iterable($actual)
|
||||
) {
|
||||
parent::__construct($actual);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidVerifyException(basename(self::class), $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a haystack contains a needle.
|
||||
*
|
||||
* @param $needle
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function contains($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertContains($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function containsEquals($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertContainsEquals($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a haystack contains only values of a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param bool|null $isNativeType
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function containsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Assert::assertContainsOnly($type, $this->actual, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a haystack contains only instances of a given class name.
|
||||
*
|
||||
* @param string $className
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function containsOnlyInstancesOf(string $className, string $message = ''): self
|
||||
{
|
||||
Assert::assertContainsOnlyInstancesOf($className, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the number of elements of an array, Countable or Traversable.
|
||||
*
|
||||
* @param int $expectedCount
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function count(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Assert::assertCount($expectedCount, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that an array has a specified key.
|
||||
*
|
||||
* @param int|string $key
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function hasKey($key, string $message = ''): self
|
||||
{
|
||||
Assert::assertArrayHasKey($key, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that an array does not have a specified key.
|
||||
*
|
||||
* @param int|string $key
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function hasNotKey($key, string $message = ''): self
|
||||
{
|
||||
Assert::assertArrayNotHasKey($key, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a haystack does not contain a needle.
|
||||
*
|
||||
* @param $needle
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notContains($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotContains($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notContainsEquals($needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotContainsEquals($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a haystack does not contain only values of a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param bool|null $isNativeType
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notContainsOnly(string $type, ?bool $isNativeType = null, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotContainsOnly($type, $this->actual, $isNativeType, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the number of elements of an array, Countable or Traversable.
|
||||
*
|
||||
* @param int $expectedCount
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notCount(int $expectedCount, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotCount($expectedCount, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
|
||||
*
|
||||
* @param Countable|iterable $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notSameSize($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotSameSize($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
|
||||
*
|
||||
* @param Countable|iterable $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function sameSize($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertSameSize($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyBaseObject extends Verify
|
||||
{
|
||||
use VerifyDataTrait;
|
||||
|
||||
/**
|
||||
* VerifyBaseObject constructor
|
||||
*
|
||||
* @param object $object
|
||||
*/
|
||||
public function __construct(object $object)
|
||||
{
|
||||
parent::__construct($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that an object has a specified attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function hasAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertObjectHasAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that an object does not have a specified attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notHasAttribute(string $attributeName, string $message = ''): self
|
||||
{
|
||||
Assert::assertObjectNotHasAttribute($attributeName, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Asserts\AssertThrows;
|
||||
use Codeception\Verify\Verify;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class VerifyCallable extends Verify
|
||||
{
|
||||
use AssertThrows;
|
||||
|
||||
public function __construct(callable $callable)
|
||||
{
|
||||
parent::__construct($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception|string|null $throws
|
||||
* @param string|false $message
|
||||
* @return VerifyCallable
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function throws($throws = null, $message = false): self
|
||||
{
|
||||
return $this->assertThrows($throws, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception|string|null $throws
|
||||
* @param string|false $message
|
||||
* @return $this
|
||||
*/
|
||||
public function doesNotThrow($throws = null, $message = false): self
|
||||
{
|
||||
return $this->assertDoesNotThrow($throws, $message);
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
trait VerifyDataTrait
|
||||
{
|
||||
/**
|
||||
* Verifies that a file/dir is not readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file/dir is not writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file/dir is readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file/dir is writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyDirectory extends Verify
|
||||
{
|
||||
use VerifyDataTrait;
|
||||
|
||||
/**
|
||||
* VerifyDirectory constructor
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
public function __construct(string $directory)
|
||||
{
|
||||
parent::__construct($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a directory does not exist.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function doesNotExist(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryDoesNotExist($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a directory exists.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function exists(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryExists($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a directory exists and is not readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsNotReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsNotReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a directory exists and is not writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsNotWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsNotWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a directory exists and is readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a directory exists and is writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertDirectoryIsWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyFile extends Verify
|
||||
{
|
||||
use VerifyDataTrait;
|
||||
|
||||
public function __construct(string $actual)
|
||||
{
|
||||
parent::__construct($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file does not exist.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function doesNotExists(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileDoesNotExist($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of one file is equal to the contents of another file.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equals(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of one file is equal to the contents of another file (canonicalizing).
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of one file is equal to the contents of another file (ignoring case).
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file exists.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function exists(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileExists($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file exists and is not readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsNotReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsNotReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file exists and is not writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsNotWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsNotWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file exists and is readable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsReadable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsReadable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a file exists and is writable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function existsAndIsWritable(string $message = ''): self
|
||||
{
|
||||
Assert::assertFileIsWritable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of one file is not equal to the contents of another file.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEquals(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileNotEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of one file is not equal to the contents of another file (canonicalizing).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsCanonicalizing(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileNotEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of one file is not equal to the contents of another file (ignoring case).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsIgnoringCase(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertFileNotEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyJsonFile extends Verify
|
||||
{
|
||||
public function __construct(string $actualFile)
|
||||
{
|
||||
parent::__construct($actualFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two JSON files are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonFileEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two JSON files are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonFileNotEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyJsonString extends Verify
|
||||
{
|
||||
public function __construct(string $actualJson)
|
||||
{
|
||||
parent::__construct($actualJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the generated JSON encoded object and the content of the given file are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two given JSON encoded objects or arrays are equal.
|
||||
*
|
||||
* @param string $expectedJson
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringEqualsJsonString($expectedJson, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the generated JSON encoded object and the content of the given file are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsJsonFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringNotEqualsJsonFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two given JSON encoded objects or arrays are not equal.
|
||||
*
|
||||
* @param string $expectedJson
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsJsonString(string $expectedJson, string $message = ''): self
|
||||
{
|
||||
Assert::assertJsonStringNotEqualsJsonString($expectedJson, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,651 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyMixed extends Verify
|
||||
{
|
||||
/**
|
||||
* VerifyMixed constructor.
|
||||
*
|
||||
* @param mixed $actual
|
||||
*/
|
||||
public function __construct($actual)
|
||||
{
|
||||
parent::__construct($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is empty.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function empty(string $message = ''): self
|
||||
{
|
||||
Assert::assertEmpty($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are equal.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equals($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are equal (canonicalizing).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsCanonicalizing($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are equal (ignoring case).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsIgnoringCase($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are equal (with delta).
|
||||
*
|
||||
* @param $expected
|
||||
* @param float $delta
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsWithDelta($expected, float $delta, string $message = ''): self
|
||||
{
|
||||
Assert::assertEqualsWithDelta($expected, $this->actual, $delta, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a condition is false.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function false(string $message = ''): self
|
||||
{
|
||||
Assert::assertFalse($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is finite.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function finite(string $message = ''): self
|
||||
{
|
||||
Assert::assertFinite($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a value is greater than another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function greaterThan($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertGreaterThan($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a value is greater than or equal to another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function greaterThanOrEqual($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertGreaterThanOrEqual($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is infinite.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function infinite(string $message = ''): self
|
||||
{
|
||||
Assert::assertInfinite($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of a given type.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function instanceOf(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertInstanceOf($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type array.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isArray(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsArray($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type bool.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isBool(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsBool($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type callable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isCallable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsCallable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type resource and is closed.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isClosedResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsClosedResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type float.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isFloat(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsFloat($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type int.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isInt(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsInt($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type iterable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isIterable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsIterable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type array.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotArray(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotArray($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type bool.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotBool(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotBool($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type callable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotCallable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotCallable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotClosedResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotClosedResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type float.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotFloat(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotFloat($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type int.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotInt(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotInt($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type iterable.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotIterable(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotIterable($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type numeric.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotNumeric(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotNumeric($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type object.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotObject(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotObject($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type scalar.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotScalar(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotScalar($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of type string.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNotString(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNotString($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type numeric.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isNumeric(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsNumeric($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type object.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isObject(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsObject($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type resource.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isResource(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsResource($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type scalar.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isScalar(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsScalar($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is of type string.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function isString(string $message = ''): self
|
||||
{
|
||||
Assert::assertIsString($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a value is smaller than another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function lessThan($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertLessThan($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a value is smaller than or equal to another value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function lessThanOrEqual($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertLessThanOrEqual($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is nan.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function nan(string $message = ''): self
|
||||
{
|
||||
Assert::assertNan($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not empty.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEmpty(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEmpty($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are not equal.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEquals($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEquals($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are not equal (canonicalizing).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsCanonicalizing($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEqualsCanonicalizing($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are not equal (ignoring case).
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsIgnoringCase($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEqualsIgnoringCase($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables are not equal (with delta).
|
||||
*
|
||||
* @param $expected
|
||||
* @param float $delta
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsWithDelta($expected, float $delta, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotEqualsWithDelta($expected, $this->actual, $delta, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a condition is not false.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notFalse(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotFalse($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not of a given type.
|
||||
*
|
||||
* @param string $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notInstanceOf(string $expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotInstanceOf($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is not null.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notNull(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotNull($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables do not have the same type and value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notSame($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertNotSame($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a condition is not true.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notTrue(string $message = ''): self
|
||||
{
|
||||
Assert::assertNotTrue($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a variable is null.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function null(string $message = ''): self
|
||||
{
|
||||
Assert::assertNull($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two variables have the same type and value.
|
||||
*
|
||||
* @param $expected
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function same($expected, string $message = ''): self
|
||||
{
|
||||
Assert::assertSame($expected, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a condition is true.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function true(string $message = ''): self
|
||||
{
|
||||
Assert::assertTrue($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyString extends Verify
|
||||
{
|
||||
public function __construct(string $string)
|
||||
{
|
||||
parent::__construct($string);
|
||||
}
|
||||
|
||||
public function containsString(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringContainsString($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function containsStringIgnoringCase(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringContainsStringIgnoringCase($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string does not match a given regular expression.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function doesNotMatchRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Assert::assertDoesNotMatchRegularExpression($pattern, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string ends with a given suffix.
|
||||
*
|
||||
* @param string $suffix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function endsWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEndsWith($suffix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of a string is equal to the contents of a file.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEqualsFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of a string is equal to the contents of a file (canonicalizing).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of a string is equal to the contents of a file (ignoring case).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string is a valid JSON string.
|
||||
*
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function json(string $message = ''): self
|
||||
{
|
||||
Assert::assertJson($this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string matches a given format string.
|
||||
*
|
||||
* @param string $format
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function matchesFormat(string $format, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringMatchesFormat($format, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string matches a given format file.
|
||||
*
|
||||
* @param string $formatFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function matchesFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringMatchesFormatFile($formatFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string matches a given regular expression.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function matchesRegExp(string $pattern, string $message = ''): self
|
||||
{
|
||||
Assert::assertMatchesRegularExpression($pattern, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notContainsString(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotContainsString($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notContainsStringIgnoringCase(string $needle, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotContainsStringIgnoringCase($needle, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string ends not with a given suffix.
|
||||
*
|
||||
* @param string $suffix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEndsWith(string $suffix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringEndsNotWith($suffix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of a string is not equal to the contents of a file.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotEqualsFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of a string is not equal to the contents of a file (canonicalizing).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsFileCanonicalizing(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotEqualsFileCanonicalizing($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the contents of a string is not equal to the contents of a file (ignoring case).
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsFileIgnoringCase(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotEqualsFileIgnoringCase($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string does not match a given format string.
|
||||
*
|
||||
* @param $format
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notMatchesFormat(string $format, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotMatchesFormat($format, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string does not match a given format string.
|
||||
*
|
||||
* @param string $formatFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notMatchesFormatFile(string $formatFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringNotMatchesFormatFile($formatFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string starts not with a given prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function startsNotWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringStartsNotWith($prefix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a string starts with a given prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function startsWith(string $prefix, string $message = ''): self
|
||||
{
|
||||
Assert::assertStringStartsWith($prefix, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Verify\Verify;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
class VerifyXmlFile extends Verify
|
||||
{
|
||||
public function __construct(string $actualFile)
|
||||
{
|
||||
parent::__construct($actualFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two XML files are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlFileEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two XML files are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify\Verifiers;
|
||||
|
||||
use Codeception\Exception\InvalidVerifyException;
|
||||
use Codeception\Verify\Verify;
|
||||
use DOMDocument;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use function basename;
|
||||
use function is_string;
|
||||
|
||||
class VerifyXmlString extends Verify
|
||||
{
|
||||
/**
|
||||
* VerifyXmlString constructor
|
||||
*
|
||||
* @param DOMDocument|string $actualXml
|
||||
*/
|
||||
public function __construct($actualXml)
|
||||
{
|
||||
if (is_string($actualXml) || $actualXml instanceof DOMDocument) {
|
||||
parent::__construct($actualXml);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidVerifyException(basename(self::class), $actualXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two XML documents are equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two XML documents are equal.
|
||||
*
|
||||
* @param DOMDocument|string $expectedXml
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function equalsXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringEqualsXmlString($expectedXml, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two XML documents are not equal.
|
||||
*
|
||||
* @param string $expectedFile
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsXmlFile(string $expectedFile, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringNotEqualsXmlFile($expectedFile, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that two XML documents are not equal.
|
||||
*
|
||||
* @param DOMDocument|string $expectedXml
|
||||
* @param string $message
|
||||
* @return self
|
||||
*/
|
||||
public function notEqualsXmlString($expectedXml, string $message = ''): self
|
||||
{
|
||||
Assert::assertXmlStringNotEqualsXmlString($expectedXml, $this->actual, $message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Codeception\Verify;
|
||||
|
||||
use ArrayAccess;
|
||||
use Codeception\Verify\Verifiers\VerifyArray;
|
||||
use Codeception\Verify\Verifiers\VerifyCallable;
|
||||
use Codeception\Verify\Verifiers\VerifyDirectory;
|
||||
use Codeception\Verify\Verifiers\VerifyFile;
|
||||
use Codeception\Verify\Verifiers\VerifyJsonFile;
|
||||
use Codeception\Verify\Verifiers\VerifyJsonString;
|
||||
use Codeception\Verify\Verifiers\VerifyMixed;
|
||||
use Codeception\Verify\Verifiers\VerifyBaseObject;
|
||||
use Codeception\Verify\Verifiers\VerifyString;
|
||||
use Codeception\Verify\Verifiers\VerifyXmlFile;
|
||||
use Codeception\Verify\Verifiers\VerifyXmlString;
|
||||
use Countable;
|
||||
|
||||
abstract class Verify
|
||||
{
|
||||
/** @var mixed */
|
||||
protected $actual = null;
|
||||
|
||||
/**
|
||||
* Verify constructor
|
||||
*
|
||||
* @param mixed $actual
|
||||
*/
|
||||
protected function __construct($actual)
|
||||
{
|
||||
$this->actual = $actual;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return self
|
||||
*/
|
||||
public function __invoke($actual): self
|
||||
{
|
||||
return $this($actual);
|
||||
}
|
||||
|
||||
public static function File(string $filename): VerifyFile
|
||||
{
|
||||
return new VerifyFile($filename);
|
||||
}
|
||||
|
||||
public static function JsonFile(string $filename): VerifyJsonFile
|
||||
{
|
||||
return new VerifyJsonFile($filename);
|
||||
}
|
||||
|
||||
public static function JsonString(string $json): VerifyJsonString
|
||||
{
|
||||
return new VerifyJsonString($json);
|
||||
}
|
||||
|
||||
public static function XmlFile(string $filename): VerifyXmlFile
|
||||
{
|
||||
return new VerifyXmlFile($filename);
|
||||
}
|
||||
|
||||
public static function XmlString(string $xml): VerifyXmlString
|
||||
{
|
||||
return new VerifyXmlString($xml);
|
||||
}
|
||||
|
||||
public static function BaseObject(object $object): VerifyBaseObject
|
||||
{
|
||||
return new VerifyBaseObject($object);
|
||||
}
|
||||
|
||||
public static function Directory(string $directory): VerifyDirectory
|
||||
{
|
||||
return new VerifyDirectory($directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|ArrayAccess|Countable|iterable $array
|
||||
* @return VerifyArray
|
||||
*/
|
||||
public static function Array($array): VerifyArray
|
||||
{
|
||||
return new VerifyArray($array);
|
||||
}
|
||||
|
||||
public static function String(string $string): VerifyString
|
||||
{
|
||||
return new VerifyString($string);
|
||||
}
|
||||
|
||||
public static function Callable(callable $callable): VerifyCallable
|
||||
{
|
||||
return new VerifyCallable($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return VerifyMixed
|
||||
*/
|
||||
public static function Mixed($actual): VerifyMixed
|
||||
{
|
||||
return new VerifyMixed($actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Codeception\Verify\Expectations\ExpectAny;
|
||||
use Codeception\Verify\Verifiers\VerifyAny;
|
||||
|
||||
if (!function_exists('verify'))
|
||||
{
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return VerifyAny
|
||||
*/
|
||||
function verify($actual): VerifyAny
|
||||
{
|
||||
return new VerifyAny($actual);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('verify_that'))
|
||||
{
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return VerifyAny
|
||||
*/
|
||||
function verify_that($actual): VerifyAny
|
||||
{
|
||||
return new VerifyAny($actual);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('expect'))
|
||||
{
|
||||
/**
|
||||
* @param mixed $actual
|
||||
* @return ExpectAny
|
||||
*/
|
||||
function expect($actual): ExpectAny {
|
||||
return new ExpectAny($actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user