CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 周边产品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • 领英
    • 优酷
    • 脸书
    • 推特
    • Mastodon
    • 帮助与支持
    • 论坛
    • 堆栈溢出
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
      • Constraint
        • Email
        • Response
        • Session
        • View
      • Fixture
      • Stub
    • Utility
    • Validation
    • View

类 MailContainsHtml

MailContainsHtml

命名空间: Cake\TestSuite\Constraint\Email

属性概要

  • $at protected
    int|null
  • $type protected
    string|null

    要检查其内容的邮件类型

方法概要

  • __construct() public

    构造函数

  • additionalFailureDescription() protected

    在需要时返回额外的失败描述。

  • count() public

    计算约束元素的数量。

  • evaluate() public

    针对参数 $other 评估约束。

  • fail() protected

    针对给定的比较值和测试描述抛出异常。

  • failureDescription() protected

    返回失败的描述。

  • failureDescriptionInContext() protected

    当此约束出现在 $operator 表达式的上下文中时,返回失败的描述。

  • getAssertedMessages() protected

    返回所有消息类型相关的字符串,尊重 $this->at

  • getMessages() public

    获取要检查的电子邮件或电子邮件

  • getTypeMethod() protected
  • matches() public

    检查约束

  • reduce() protected

    通过跳过退化子表达式,减少从 $this 开始的子表达式,并返回开始非可简化子表达式的第一个后代约束。

  • toString() public

    断言消息字符串

  • toStringInContext() protected

    当约束出现在 $operator 表达式的上下文中时,返回约束对象的自定义字符串表示。

  • valueToTypeStringFragment() protected

方法详情

__construct() ¶ public

__construct(int|null $at = null): void

构造函数

参数
int|null $at optional

At

返回
void

additionalFailureDescription() ¶ protected

additionalFailureDescription(mixed $other): string

在需要时返回额外的失败描述。

该函数可以被重写以提供额外的失败信息,例如差异

参数
mixed $other
返回
string

count() ¶ public

count(): int

计算约束元素的数量。

返回
int

evaluate() ¶ public

evaluate(mixed $other, string $description = '', bool $returnResult = false): ?bool

针对参数 $other 评估约束。

如果 $returnResult 设置为 false(默认值),则在失败的情况下会抛出异常。否则返回 null。

如果 $returnResult 为 true,则评估的结果将作为布尔值返回:成功为 true,失败为 false。

参数
mixed $other
string $description optional
bool $returnResult optional
返回
?bool
抛出
ExpectationFailedException

fail() ¶ protected

fail(mixed $other, string $description, ?ComparisonFailure $comparisonFailure = null): never

针对给定的比较值和测试描述抛出异常。

参数
mixed $other
string $description
?ComparisonFailure $comparisonFailure optional
返回
never
抛出
ExpectationFailedException

failureDescription() ¶ protected

failureDescription(mixed $other): string

返回失败的描述。

大多数情况下,失败消息的开头是“断言失败”,此方法应该返回该句子的第二部分。

要提供额外的失败信息,可以使用 additionalFailureDescription。

参数
mixed $other
返回
string

failureDescriptionInContext() ¶ protected

failureDescriptionInContext(Operator $operator, mixed $role, mixed $other): string

当此约束出现在 $operator 表达式的上下文中时,返回失败的描述。

此方法的目的是在 LogicalNot 等运算符的上下文中提供有意义的失败描述。原生 PHPUnit 约束由 LogicalNot 开箱即用地支持,但外部开发的约束无法在此上下文中提供正确的消息。

如果该方法本身不处理自定义,则应返回空字符串。

参数
Operator $operator
mixed $role
mixed $other
返回
string

getAssertedMessages() ¶ protected

getAssertedMessages(): string

返回所有消息类型相关的字符串,尊重 $this->at

返回
string

getMessages() ¶ public

getMessages(): arrayCake\Mailer\Message>

获取要检查的电子邮件或电子邮件

返回
arrayCake\Mailer\Message>

getTypeMethod() ¶ protected

getTypeMethod(): string
返回
string

matches() ¶ public

matches(mixed $other): bool

检查约束

此方法可以被重写以实现评估算法。

参数
mixed $other

约束检查

返回
bool

reduce() ¶ protected

reduce(): self

通过跳过退化子表达式,减少从 $this 开始的子表达式,并返回开始非可简化子表达式的第一个后代约束。

对于终端约束和开始非可简化子表达式的运算符,返回 $this,或 $this 的最近后代,该后代开始非可简化子表达式。

一个约束表达式可以建模为一棵树,其中包含非终端节点(运算符)和终端节点。例如

LogicalOr(运算符,非终端)

  • LogicalAnd(运算符,非终端) | + IsType('int')(终端) | + GreaterThan(10)(终端)
  • LogicalNot(运算符,非终端)
    • IsType('array')(终端)

退化子表达式是树的一部分,它实际上对它出现的表达式的评估没有贡献。退化子表达式的示例是使用单个操作数构造的 BinaryOperator 或嵌套的 BinaryOperators,每个都使用单个操作数。包含退化子表达式的表达式等效于删除了退化子表达式的简化表达式,例如

LogicalAnd(运算符)

  • LogicalOr(退化运算符) | + LogicalAnd(退化运算符) | + IsType('int')(终端)
  • GreaterThan(10)(终端)

等效于

LogicalAnd(运算符)

  • IsType('int')(终端)
  • GreaterThan(10)(终端)

因为子表达式

  • LogicalOr
    • LogicalAnd
      • -

是退化的。在上面的 LogicalOr 对象上调用 reduce(),以及在 LogicalAnd 上调用 reduce(),都将返回 IsType('int') 实例。

可以实现其他具体的简化,例如 LogicalNot 运算符的级联

  • LogicalNot
    • LogicalNot +LogicalNot
      • IsTrue

可以简化为

LogicalNot

  • IsTrue
返回
self

toString() ¶ public

toString(): string

断言消息字符串

返回
string

toStringInContext() ¶ protected

toStringInContext(Operator $operator, mixed $role): string

当约束出现在 $operator 表达式的上下文中时,返回约束对象的自定义字符串表示。

此方法的目的是在 LogicalNot 等运算符的上下文中提供有意义的描述性字符串。原生 PHPUnit 约束由 LogicalNot 开箱即用地支持,但外部开发的约束无法在此上下文中提供正确的字符串。

如果该方法本身不处理自定义,则应返回空字符串。

参数
Operator $operator
mixed $role
返回
string

valueToTypeStringFragment() ¶ protected

valueToTypeStringFragment(mixed $value): non-empty-string
参数
mixed $value
返回
非空字符串

属性详情

$at ¶ protected

类型
int|null

$type ¶ protected

要检查其内容的邮件类型

类型
string|null
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • 领英
  • 优酷
  • 脸书
  • 推特
  • Mastodon
  • 帮助与支持
  • 论坛
  • 堆栈溢出
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成