CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识 & 商标
  • 企业解决方案
  • 商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助 & 支持
    • 论坛
    • Stack Overflow
    • 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
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
    • 数据库
    • 数据源
    • 错误
    • 事件
    • 表单
    • Http
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
      • 约束
        • 电子邮件
        • 响应
        • 会话
        • 视图
      • Fixture
      • Stub
    • 实用工具
    • 验证
    • 视图

类 FlashParamEquals

FlashParamEquals

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

属性摘要

  • $at 受保护
    int|null
  • $key 受保护
    string
  • $param 受保护
    string
  • $session 受保护
    Cake\Http\Session

方法摘要

  • __construct() 公开

    构造函数

  • additionalFailureDescription() 受保护

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

  • count() 公开

    计算约束元素的数量。

  • evaluate() 公开

    评估参数 $other 的约束。

  • fail() 受保护

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

  • failureDescription() 受保护

    返回失败的描述。

  • failureDescriptionInContext() 受保护

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

  • matches() 公开

    与闪存消息进行比较。

  • reduce() 受保护

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

  • toString() 公开

    断言消息字符串

  • toStringInContext() 受保护

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

  • valueToTypeStringFragment() 受保护

方法详情

__construct() ¶ 公开

__construct(Cake\Http\Session|null $session, string $key, string $param, int|null $at = null)

构造函数

参数
Cake\Http\Session|null $session

会话

string $key

闪存键

string $param

要检查的参数

int|null $at 可选

预期索引

additionalFailureDescription() ¶ 受保护

additionalFailureDescription(mixed $other): string

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

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

参数
mixed $other
返回
string

count() ¶ 公开

count(): int

计算约束元素的数量。

返回
int

evaluate() ¶ 公开

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

评估参数 $other 的约束。

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

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

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

fail() ¶ 受保护

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

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

参数
mixed $other
string $description
?ComparisonFailure $comparisonFailure 可选
返回
永不
抛出
ExpectationFailedException

failureDescription() ¶ 受保护

failureDescription(mixed $other): string

返回失败的描述。

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

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

参数
mixed $other
返回
string

failureDescriptionInContext() ¶ 受保护

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

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

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

当该方法本身不处理定制时,该方法应返回空字符串。

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

matches() ¶ 公开

matches(mixed $other): bool

与闪存消息进行比较。

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

参数
mixed $other

要比较的值

返回
bool

reduce() ¶ 受保护

reduce(): self

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

对于终止约束和从非可减少子表达式开始的运算符返回 $this,或者返回从非可减少子表达式开始的 $this 的最近后代。

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

LogicalOr(运算符,非终止节点)

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

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

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
返回
自身

toString() ¶ 公开

toString(): string

断言消息字符串

返回
string

toStringInContext() ¶ 受保护

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

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

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

当该方法本身不处理定制时,该方法应返回空字符串。

参数
Operator $operator
mixed $role
返回
string

valueToTypeStringFragment() ¶ 受保护

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

属性详情

$at ¶ 受保护

类型
int|null

$key ¶ 受保护

类型
string

$param ¶ 受保护

类型
string

$session ¶ 受保护

类型
Cake\Http\Session
OpenHub
Pingping
Linode
  • 企业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识 & 商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助 & 支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成