CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 加入我们
    • 问题 (Github)
    • 面包店
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻通讯
    • 领英
    • 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
      • 存根
    • 工具
    • 验证
    • 视图

CookieEncryptedEquals 类

CookieEncryptedEquals

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

属性摘要

  • $_validCiphers protected
    list<string>

    加密 Cookie 的有效密码名称。

  • $cookieName protected
    string
  • $key protected
    string
  • $mode protected
    string
  • $response protected
    Cake\Http\Response

方法摘要

  • __construct() public

    构造函数。

  • _checkCipher() protected

    验证加密密码名称的辅助方法。

  • _decode() protected

    解码和解密单个值。

  • _decrypt() protected

    使用 Security 类中的公共 $type 方法解密 $value。

  • _encrypt() protected

    使用 Security 类中的公共 $type 方法加密 $value。

  • _explode() protected

    explode 方法用于从 CookieComponent::_implode() 中设置的字符串返回数组。保持与 1.x CookieComponent::_implode() 向后兼容。

  • _getBodyAsString() protected

    获取响应主体作为字符串。

  • _getCookieEncryptionKey() protected

    返回加密密钥。

  • _implode() protected

    implode 方法用于保留多维数组的键。

  • additionalFailureDescription() protected

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

  • count() public

    计算约束元素的数量。

  • evaluate() public

    针对参数 $other 评估约束。

  • fail() protected

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

  • failureDescription() protected

    返回失败的描述。

  • failureDescriptionInContext() protected

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

  • matches() public

    检查断言。

  • readCookie() protected

    从响应 cookie 集合或标头读取 cookie。

  • reduce() protected

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

  • toString() public

    断言消息。

  • toStringInContext() protected

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

  • valueToTypeStringFragment() protected

方法详情

__construct() ¶ public

__construct(Cake\Http\Response|null $response, string $cookieName, string $mode, string $key)

构造函数。

参数
Cake\Http\Response|null $response

响应实例。

string $cookieName

Cookie 名称。

string $mode

模式。

string $key

密钥。

_checkCipher() ¶ protected

_checkCipher(string $encrypt): void

验证加密密码名称的辅助方法。

参数
string $encrypt

密码名称。

返回值
void
抛出
RuntimeException
当提供无效密码时。

_decode() ¶ protected

_decode(string $value, string|false $encrypt, string|null $key): array|string

解码和解密单个值。

参数
string $value

要解码和解密的值。

string|false $encrypt

要使用的加密密码。

string|null $key

如果指定,用作安全盐。

返回值
array|string

_decrypt() ¶ protected

_decrypt(list<string>|string $values, string|false $mode, string|null $key = null): array|string

使用 Security 类中的公共 $type 方法解密 $value。

参数
list<string>|string $values

要解密的值。

string|false $mode

加密模式。

string|null $key optional

如果指定,用作安全盐。

返回值
array|string

_encrypt() ¶ protected

_encrypt(array|string $value, string|false $encrypt, string|null $key = null): string

使用 Security 类中的公共 $type 方法加密 $value。

参数
array|string $value

要加密的值。

string|false $encrypt

要使用的加密模式。False 禁用加密。

string|null $key optional

如果指定,用作安全盐。

返回值
string

_explode() ¶ protected

_explode(string $string): array|string

explode 方法用于从 CookieComponent::_implode() 中设置的字符串返回数组。保持与 1.x CookieComponent::_implode() 向后兼容。

参数
string $string

包含 JSON 编码数据的字符串,或一个裸字符串。

返回值
array|string

_getBodyAsString() ¶ protected

_getBodyAsString(): string

获取响应主体作为字符串。

返回值
string

_getCookieEncryptionKey() ¶ protected

_getCookieEncryptionKey(): string

返回加密密钥。

返回值
string

_implode() ¶ protected

_implode(array $array): string

implode 方法用于保留多维数组的键。

参数
array $array

键值映射。

返回值
string

additionalFailureDescription() ¶ protected

additionalFailureDescription(mixed $other): string

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

该函数可以被重写以提供额外的失败信息,如 diff。

参数
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

返回失败的描述。

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

要提供额外的失败信息,可以使用 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

matches() ¶ public

matches(mixed $other): bool

检查断言。

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

参数
mixed $other

预期内容

返回值
bool

readCookie() ¶ protected

readCookie(string $name): array|null

从响应 cookie 集合或标头读取 cookie。

参数
string $name

要读取的 Cookie 的名称。

返回值
array|null

reduce() ¶ protected

reduce(): self

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

对于终端约束和从非可简化子表达式开始的操作符,返回 $this;或者返回 $this 的最近子代,该子代从非可简化子表达式开始。

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

LogicalOr(操作符,非终端)

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

退化子表达式是树的一部分,它实际上不会对它所出现的表达式的求值做出贡献。退化子表达式的示例是使用单个操作数或嵌套的二元操作符(每个操作符都具有单个操作数)构造的 BinaryOperator。包含退化子表达式的表达式等同于删除退化子表达式后的简化表达式,例如

LogicalAnd(操作符)

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

等同于

LogicalAnd(操作符)

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

因为子表达式

  • LogicalOr
    • LogicalAnd
      • -

是退化的。在上面的 LogicalOr 对象以及 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
返回值
非空字符串

属性详情

$_validCiphers ¶ protected

加密 Cookie 的有效密码名称。

类型
list<string>

$cookieName ¶ protected

类型
string

$key ¶ protected

类型
string

$mode ¶ protected

类型
string

$response ¶ protected

类型
Cake\Http\Response
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 加入我们
  • 问题 (Github)
  • 面包店
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻通讯
  • 领英
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成