package and depencies
This commit is contained in:
@@ -18,8 +18,8 @@ use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
final class EmailAddressContains extends Constraint
|
||||
{
|
||||
private $headerName;
|
||||
private $expectedValue;
|
||||
private string $headerName;
|
||||
private string $expectedValue;
|
||||
|
||||
public function __construct(string $headerName, string $expectedValue)
|
||||
{
|
||||
@@ -27,9 +27,6 @@ final class EmailAddressContains extends Constraint
|
||||
$this->expectedValue = $expectedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return sprintf('contains address "%s" with value "%s"', $this->headerName, $this->expectedValue);
|
||||
@@ -37,12 +34,10 @@ final class EmailAddressContains extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($message): bool
|
||||
{
|
||||
if (RawMessage::class === \get_class($message)) {
|
||||
if (RawMessage::class === $message::class) {
|
||||
throw new \LogicException('Unable to test a message address on a RawMessage instance.');
|
||||
}
|
||||
|
||||
@@ -64,8 +59,6 @@ final class EmailAddressContains extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function failureDescription($message): string
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
final class EmailAttachmentCount extends Constraint
|
||||
{
|
||||
private $expectedValue;
|
||||
private $transport;
|
||||
private int $expectedValue;
|
||||
private ?string $transport;
|
||||
|
||||
public function __construct(int $expectedValue, string $transport = null)
|
||||
{
|
||||
@@ -26,9 +26,6 @@ final class EmailAttachmentCount extends Constraint
|
||||
$this->transport = $transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return sprintf('has sent "%d" attachment(s)', $this->expectedValue);
|
||||
@@ -36,12 +33,10 @@ final class EmailAttachmentCount extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($message): bool
|
||||
{
|
||||
if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) {
|
||||
if (RawMessage::class === $message::class || Message::class === $message::class) {
|
||||
throw new \LogicException('Unable to test a message attachment on a RawMessage or Message instance.');
|
||||
}
|
||||
|
||||
@@ -50,8 +45,6 @@ final class EmailAttachmentCount extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function failureDescription($message): string
|
||||
{
|
||||
|
@@ -16,16 +16,13 @@ use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
final class EmailHasHeader extends Constraint
|
||||
{
|
||||
private $headerName;
|
||||
private string $headerName;
|
||||
|
||||
public function __construct(string $headerName)
|
||||
{
|
||||
$this->headerName = $headerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return sprintf('has header "%s"', $this->headerName);
|
||||
@@ -33,12 +30,10 @@ final class EmailHasHeader extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($message): bool
|
||||
{
|
||||
if (RawMessage::class === \get_class($message)) {
|
||||
if (RawMessage::class === $message::class) {
|
||||
throw new \LogicException('Unable to test a message header on a RawMessage instance.');
|
||||
}
|
||||
|
||||
@@ -47,8 +42,6 @@ final class EmailHasHeader extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function failureDescription($message): string
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
final class EmailHeaderSame extends Constraint
|
||||
{
|
||||
private $headerName;
|
||||
private $expectedValue;
|
||||
private string $headerName;
|
||||
private string $expectedValue;
|
||||
|
||||
public function __construct(string $headerName, string $expectedValue)
|
||||
{
|
||||
@@ -26,9 +26,6 @@ final class EmailHeaderSame extends Constraint
|
||||
$this->expectedValue = $expectedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return sprintf('has header "%s" with value "%s"', $this->headerName, $this->expectedValue);
|
||||
@@ -36,12 +33,10 @@ final class EmailHeaderSame extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($message): bool
|
||||
{
|
||||
if (RawMessage::class === \get_class($message)) {
|
||||
if (RawMessage::class === $message::class) {
|
||||
throw new \LogicException('Unable to test a message header on a RawMessage instance.');
|
||||
}
|
||||
|
||||
@@ -50,8 +45,6 @@ final class EmailHeaderSame extends Constraint
|
||||
|
||||
/**
|
||||
* @param RawMessage $message
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function failureDescription($message): string
|
||||
{
|
||||
|
@@ -17,38 +17,31 @@ use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
final class EmailHtmlBodyContains extends Constraint
|
||||
{
|
||||
private $expectedText;
|
||||
private string $expectedText;
|
||||
|
||||
public function __construct(string $expectedText)
|
||||
{
|
||||
$this->expectedText = $expectedText;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return sprintf('contains "%s"', $this->expectedText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param RawMessage $message
|
||||
*/
|
||||
protected function matches($message): bool
|
||||
{
|
||||
if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) {
|
||||
if (RawMessage::class === $message::class || Message::class === $message::class) {
|
||||
throw new \LogicException('Unable to test a message HTML body on a RawMessage or Message instance.');
|
||||
}
|
||||
|
||||
return false !== mb_strpos($message->getHtmlBody(), $this->expectedText);
|
||||
return str_contains($message->getHtmlBody(), $this->expectedText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param RawMessage $message
|
||||
*/
|
||||
protected function failureDescription($message): string
|
||||
|
@@ -17,38 +17,31 @@ use Symfony\Component\Mime\RawMessage;
|
||||
|
||||
final class EmailTextBodyContains extends Constraint
|
||||
{
|
||||
private $expectedText;
|
||||
private string $expectedText;
|
||||
|
||||
public function __construct(string $expectedText)
|
||||
{
|
||||
$this->expectedText = $expectedText;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toString(): string
|
||||
{
|
||||
return sprintf('contains "%s"', $this->expectedText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param RawMessage $message
|
||||
*/
|
||||
protected function matches($message): bool
|
||||
{
|
||||
if (RawMessage::class === \get_class($message) || Message::class === \get_class($message)) {
|
||||
if (RawMessage::class === $message::class || Message::class === $message::class) {
|
||||
throw new \LogicException('Unable to test a message text body on a RawMessage or Message instance.');
|
||||
}
|
||||
|
||||
return false !== mb_strpos($message->getTextBody(), $this->expectedText);
|
||||
return str_contains($message->getTextBody(), $this->expectedText);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param RawMessage $message
|
||||
*/
|
||||
protected function failureDescription($message): string
|
||||
|
Reference in New Issue
Block a user