Initial commit,修正
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user