trait HasPregCapturesTrait

Methods

static void
assertThat(mixed $value, Constraint $constraint, string $message = '')

Evaluates a \PHPUnit\Framework\Constraint\Constraint matcher object.

static void
assertHasPregCaptures(array $expected, array $matches, string $message = '')

Asserts that an array of $matches returned from preg_match() has capture groups as specified in $expected.

static void
assertNotHasPregCaptures(array $expected, array $matches, string $message = '')

Negated assertHasPregCaptures().

static HasPregCaptures
hasPregCaptures(array $expected)

Accepts arrays of matches returned from preg_match() having capture groups as specified in $excpected.

Details

at line 31
abstract static void assertThat(mixed $value, Constraint $constraint, string $message = '')

Evaluates a \PHPUnit\Framework\Constraint\Constraint matcher object.

Parameters

mixed $value
Constraint $constraint
string $message

Return Value

void

Exceptions

ExpectationFailedException
InvalidArgumentException

at line 59
static void assertHasPregCaptures(array $expected, array $matches, string $message = '')

Asserts that an array of $matches returned from preg_match() has capture groups as specified in $expected.

Checks only entries present in $expected, so $expected = [] accepts any array. Special values may be used in the expectations:

  • ['foo' => false] asserts that group 'foo' was not captured,
  • ['foo' => true] asserts that group 'foo' was captured,
  • ['foo' => 'FOO'] asserts that group 'foo' was captured and it's value equals 'FOO'.

Boolean expectations (['foo' => true] or ['foo' => false]) work properly only with arrays obtained from preg_match() invoked with PREG_UNMATCHED_AS_NULL flag.

Parameters

array $expected

An array of expectations

array $matches

An array of preg matches to be examined

string $message

Additional message

Return Value

void

Exceptions

ExpectationFailedException
InvalidArgumentException
InvalidArgumentException

at line 78
static void assertNotHasPregCaptures(array $expected, array $matches, string $message = '')

Negated assertHasPregCaptures().

Parameters

array $expected

An array of expectations

array $matches

An array of preg matches to be examined

string $message

Additional message

Return Value

void

Exceptions

ExpectationFailedException
InvalidArgumentException
InvalidArgumentException

at line 100
static HasPregCaptures hasPregCaptures(array $expected)

Accepts arrays of matches returned from preg_match() having capture groups as specified in $excpected.

Checks only entries present in $expected, so $expected = [] accepts any array. Special values may be used in the expectations:

  • ['foo' => false] asserts that group 'foo' was not captured,
  • ['foo' => true] asserts that group 'foo' was captured,
  • ['foo' => 'FOO'] asserts that group 'foo' was captured and its value equals 'FOO'.

Boolean expectations (['foo' => true] or ['foo' => false]) work properly only with arrays obtained from preg_match() invoked with PREG_UNMATCHED_AS_NULL flag.

Parameters

array $expected

Return Value

HasPregCaptures

Exceptions

InvalidArgumentException