CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 礼品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻
    • 领英
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C Elastic Search 4.x API

  • 项目
    • Elastic Search
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 4.x
      • 4.x
      • 3.x
      • 2.x

命名空间

  • Cake\ElasticSearch
    • 关联
    • 数据源
    • 异常
    • 规则
    • 测试套件
      • 夹具
    • 视图

类 TestCase

使用 DeleteQueryStrategy 的 Elastic-search TestCase。

命名空间: Cake\ElasticSearch\TestSuite

属性摘要

  • $ElasticLocator protected
    LocatorInterface
  • $_configure protected
    数组

    在测试结束时要恢复的配置值。

  • $_tableLocator protected
    Cake\ORM\Locator\LocatorInterface|null

    表定位器实例

  • $appPluginsToLoad protected
    数组

    在创建应用程序实例后加载的插件 ContainerStubTrait::creatApp()

  • $defaultTable protected
    字符串|null

    此对象的默认表别名。

  • $fixtureStrategy protected
    Cake\TestSuite\Fixture\FixtureStrategyInterface|null
  • $fixtures protected
    列表

    此测试用例使用的夹具。

方法摘要

  • __construct() public
  • _assertAttributes() protected

    检查作为 assertTags() 检查的一部分的属性。

  • _getTableClassName() protected

    获取表的类名。

  • _normalizePath() protected

    规范化用于比较的路径。

  • addFixture() protected

    向此测试用例添加夹具。

  • addToAssertionCount() public
  • any() public static

    返回一个匹配器,当方法执行零次或多次时匹配。

  • anything() public static
  • arrayHasKey() public static
  • assertArrayHasKey() public static

    断言数组具有指定的键。

  • assertArrayNotHasKey() public static

    断言数组没有指定的键。

  • assertContains() public static

    断言干草堆包含针。

  • assertContainsEquals() public static
  • assertContainsOnly() public static

    断言干草堆仅包含给定类型的值。

  • assertContainsOnlyInstancesOf() public static

    断言干草堆仅包含给定类名的实例。

  • assertCount() public static

    断言数组、可计数或可遍历的元素数量。

  • assertDirectoryDoesNotExist() public static

    断言目录不存在。

  • assertDirectoryExists() public static

    断言目录存在。

  • assertDirectoryIsNotReadable() public static

    断言目录存在且不可读。

  • assertDirectoryIsNotWritable() public static

    断言目录存在且不可写。

  • assertDirectoryIsReadable() public static

    断言目录存在且可读。

  • assertDirectoryIsWritable() public static

    断言目录存在且可写。

  • assertDoesNotMatchRegularExpression() public static

    断言字符串与给定的正则表达式不匹配。

  • assertEmpty() public static

    断言变量为空。

  • assertEquals() public static

    断言两个变量相等。

  • assertEqualsCanonicalizing() public static

    断言两个变量相等(规范化)。

  • assertEqualsIgnoringCase() public static

    断言两个变量相等(不区分大小写)。

  • assertEqualsSql() public

    断言字符串与 SQL 匹配,其中删除了特定于数据库的字符(如引号)。

  • assertEqualsWithDelta() public static

    断言两个变量相等(带 delta)。

  • assertEventFired() public

    断言全局事件已触发。您必须在事件管理器中跟踪事件才能使此断言起作用

  • assertEventFiredWith() public

    断言事件已触发并带数据

  • assertFalse() public static

    断言条件为假。

  • assertFileDoesNotExist() public static

    断言文件不存在。

  • assertFileEquals() public static

    断言一个文件的内容等于另一个文件的内容。

  • assertFileEqualsCanonicalizing() public static

    断言一个文件的内容等于另一个文件的内容(规范化)。

  • assertFileEqualsIgnoringCase() public static

    断言一个文件的内容等于另一个文件的内容(不区分大小写)。

  • assertFileExists() public static

    断言文件存在。

  • assertFileIsNotReadable() public static

    断言文件存在且不可读。

  • assertFileIsNotWritable() public static

    断言文件存在且不可写。

  • assertFileIsReadable() public static

    断言文件存在且可读。

  • assertFileIsWritable() public static

    断言文件存在且可写。

  • assertFileMatchesFormat() public static

    断言字符串与给定的格式字符串匹配。

  • assertFileMatchesFormatFile() public static

    断言字符串与给定的格式字符串匹配。

  • assertFileNotEquals() public static

    断言一个文件的内容不等于另一个文件的内容。

  • assertFileNotEqualsCanonicalizing() public static

    断言一个文件的内容不等于另一个文件的内容(规范化)。

  • assertFileNotEqualsIgnoringCase() public static

    断言一个文件的内容不等于另一个文件的内容(不区分大小写)。

  • assertFinite() public static

    断言变量为有限。

  • assertGreaterThan() public static

    断言一个值大于另一个值。

  • assertGreaterThanOrEqual() public static

    断言一个值大于或等于另一个值。

  • assertHtml() public

    断言 HTML 标签。

  • assertInfinite() public static

    断言变量为无穷大。

  • assertInstanceOf() public static

    断言变量为给定类型。

  • assertIsArray() public static

    断言变量为数组类型。

  • assertIsBool() public static

    断言变量为布尔类型。

  • assertIsCallable() public static

    断言变量为可调用类型。

  • assertIsClosedResource() public static

    断言变量为资源类型并且已关闭。

  • assertIsFloat() public static

    断言变量为浮点数类型。

  • assertIsInt() public static

    断言变量为整型。

  • assertIsIterable() public static

    断言变量为可迭代类型。

  • assertIsList() public static
  • assertIsNotArray() public static

    断言变量不是数组类型。

  • assertIsNotBool() public static

    断言变量不是布尔类型。

  • assertIsNotCallable() public static

    断言变量不是可调用类型。

  • assertIsNotClosedResource() public static

    断言变量不是资源类型。

  • assertIsNotFloat() public static

    断言变量不是浮点数类型。

  • assertIsNotInt() public static

    断言变量不是整型。

  • assertIsNotIterable() public static

    断言变量不是可迭代类型。

  • assertIsNotNumeric() public static

    断言变量不是数值类型。

  • assertIsNotObject() public static

    断言变量不是对象类型。

  • assertIsNotReadable() public static

    断言文件/目录存在且不可读。

  • assertIsNotResource() public static

    断言变量不是资源类型。

  • assertIsNotScalar() public static

    断言变量不是标量类型。

  • assertIsNotString() public static

    断言变量不是字符串类型。

  • assertIsNotWritable() public static

    断言文件/目录存在且不可写。

  • assertIsNumeric() public static

    断言变量为数值类型。

  • assertIsObject() public static

    断言变量为对象类型。

  • assertIsReadable() public static

    断言文件/目录可读。

  • assertIsResource() public static

    断言变量为资源类型。

  • assertIsScalar() public static

    断言变量为标量类型。

  • assertIsString() public static

    断言变量为字符串类型。

  • assertIsWritable() public static

    断言文件/目录存在且可写。

  • assertJson() public static

    断言字符串为有效的 JSON 字符串。

  • assertJsonFileEqualsJsonFile() public static

    断言两个 JSON 文件相等。

  • assertJsonFileNotEqualsJsonFile() public static

    断言两个 JSON 文件不相等。

  • assertJsonStringEqualsJsonFile() public static

    断言生成的 JSON 编码对象和给定文件的内容相等。

  • assertJsonStringEqualsJsonString() public static

    断言两个给定的 JSON 编码对象或数组相等。

  • assertJsonStringNotEqualsJsonFile() public static

    断言生成的 JSON 编码对象和给定文件的内容不相等。

  • assertJsonStringNotEqualsJsonString() public static

    断言两个给定的 JSON 编码对象或数组不相等。

  • assertLessThan() public static

    断言一个值小于另一个值。

  • assertLessThanOrEqual() public static

    断言一个值小于或等于另一个值。

  • assertMatchesRegularExpression() public static

    断言字符串与给定的正则表达式匹配。

  • assertNan() public static

    断言变量为 NaN。

  • assertNotContains() public static

    断言干草堆中不包含针。

  • assertNotContainsEquals() public static
  • assertNotContainsOnly() public static

    断言干草堆中不只包含给定类型的值。

  • assertNotCount() public static

    断言数组、可计数或可遍历的元素数量。

  • assertNotEmpty() public static

    断言变量不为空。

  • assertNotEquals() public static

    断言两个变量不相等。

  • assertNotEqualsCanonicalizing() public static

    断言两个变量不相等(规范化)。

  • assertNotEqualsIgnoringCase() public static

    断言两个变量不相等(忽略大小写)。

  • assertNotEqualsWithDelta() public static

    断言两个变量不相等(带 delta)。

  • assertNotFalse() public static

    断言条件不为假。

  • assertNotInstanceOf() public static

    断言变量不是给定类型。

  • assertNotNull() public static

    断言变量不为空。

  • assertNotSame() public static

    断言两个变量类型和值不同。在对象上使用时,它断言两个变量不引用同一个对象。

  • assertNotSameSize() public static

    断言两个数组(或 Countable 或 Traversable 对象)的大小不同。

  • assertNotTrue() public static

    断言条件不为真。

  • assertNotWithinRange() protected static

    兼容性函数,用于测试值是否不在可接受的范围内。

  • assertNull() public static

    断言变量为空。

  • assertObjectEquals() public static
  • assertObjectHasProperty() public static

    断言对象具有指定的属性。

  • assertObjectNotHasProperty() public static

    断言对象没有指定的属性。

  • assertPathEquals() protected static

    兼容性函数,用于测试路径。

  • assertPostConditions() protected

    执行所有测试用例测试共享的断言。

  • assertPreConditions() protected

    执行所有测试用例测试共享的断言。

  • assertRegExpSql() public

    用于将正则表达式模式与具有其标识符引号的查询进行比较的断言。它接受用字符 < 和 > 引号的查询。如果第三个参数设置为 true,它将更改模式以接受带引号和不带引号的查询

  • assertSame() public static

    断言两个变量具有相同的类型和值。在对象上使用时,它断言两个变量引用同一个对象。

  • assertSameSize() public static

    断言两个数组(或 Countable 或 Traversable 对象)的大小相同。

  • assertStringContainsString() public static
  • assertStringContainsStringIgnoringCase() public static
  • assertStringContainsStringIgnoringLineEndings() public static
  • assertStringEndsNotWith() public static

    断言字符串不以给定后缀结尾。

  • assertStringEndsWith() public static

    断言字符串以给定后缀结尾。

  • assertStringEqualsFile() public static

    断言字符串的内容与文件的内容相等。

  • assertStringEqualsFileCanonicalizing() public static

    断言字符串的内容与文件的内容相等(规范化)。

  • assertStringEqualsFileIgnoringCase() public static

    断言字符串的内容与文件的内容相等(忽略大小写)。

  • assertStringEqualsStringIgnoringLineEndings() public static

    断言两个字符串除了行尾以外完全相同。

  • assertStringMatchesFormat() public static

    断言字符串与给定的格式字符串匹配。

  • assertStringMatchesFormatFile() public static

    断言一个字符串与给定的格式文件匹配。

  • assertStringNotContainsString() public static
  • assertStringNotContainsStringIgnoringCase() public static
  • assertStringNotEqualsFile() public static

    断言一个字符串的内容与文件的内容不一致。

  • assertStringNotEqualsFileCanonicalizing() public static

    断言一个字符串的内容与文件的内容不一致(规范化)。

  • assertStringNotEqualsFileIgnoringCase() public static

    断言一个字符串的内容与文件的内容不一致(忽略大小写)。

  • assertStringNotMatchesFormat() public static deprecated

    断言一个字符串与给定的格式字符串不匹配。

  • assertStringNotMatchesFormatFile() public static deprecated

    断言一个字符串与给定的格式字符串不匹配。

  • assertStringStartsNotWith() public static

    断言一个字符串不以给定的前缀开头。

  • assertStringStartsWith() public static

    断言一个字符串以给定的前缀开头。

  • assertTextContains() public

    断言一个字符串包含另一个字符串,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextEndsNotWith() public

    断言一个字符串不以给定的前缀结尾,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextEndsWith() public

    断言一个字符串以给定的前缀结尾,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextEquals() public

    断言文本相等,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextNotContains() public

    断言文本不包含另一个文本,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextNotEquals() public

    断言文本相等,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextStartsNotWith() public

    断言一个字符串不以给定的前缀开头,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertTextStartsWith() public

    断言一个字符串以给定的前缀开头,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

  • assertThat() public static

    评估 PHPUnit\Framework\Constraint 匹配器对象。

  • assertTrue() public static

    断言一个条件为真。

  • assertWithinRange() protected static

    兼容性函数,用于测试一个值是否在可接受的范围内。

  • assertXmlFileEqualsXmlFile() public static

    断言两个 XML 文件相等。

  • assertXmlFileNotEqualsXmlFile() public static

    断言两个 XML 文件不相等。

  • assertXmlStringEqualsXmlFile() public static

    断言两个 XML 文档相等。

  • assertXmlStringEqualsXmlString() public static

    断言两个 XML 文档相等。

  • assertXmlStringNotEqualsXmlFile() public static

    断言两个 XML 文档不相等。

  • assertXmlStringNotEqualsXmlString() public static

    断言两个 XML 文档不相等。

  • atLeast() public static

    返回一个匹配器,当方法执行至少 N 次时匹配。

  • atLeastOnce() public static

    返回一个匹配器,当方法执行至少一次时匹配。

  • atMost() public static

    返回一个匹配器,当方法执行最多 N 次时匹配。

  • callback() public static
  • captureError() public

    捕获 $callable 中的错误,以便您可以对错误进行断言。

  • clearPlugins() public

    从全局插件集合中清除所有插件。

  • containsEqual() public static
  • containsIdentical() public static
  • containsOnly() public static
  • containsOnlyInstancesOf() public static
  • count() public
  • countOf() public static
  • createConfiguredMock() protected

    为指定的接口或类创建(并配置)一个模拟对象。

  • createConfiguredStub() protected static

    为指定的接口或类创建(并配置)一个测试存根。

  • createMock() protected

    为指定的接口或类创建模拟对象。

  • createMockForIntersectionOfInterfaces() protected
  • createPartialMock() protected

    为指定的接口或类创建部分模拟对象。

  • createStub() protected static

    为指定的接口或类创建测试存根。

  • createStubForIntersectionOfInterfaces() protected static
  • createTestProxy() protected deprecated

    为指定的类创建测试代理。

  • dataName() public
  • dataSetAsString() public
  • dataSetAsStringWithData() public
  • dependencyInput() public
  • deprecated() public

    检查弃用方法的辅助方法

  • directoryExists() public static
  • doesNotPerformAssertions() public
  • equalTo() public static
  • equalToCanonicalizing() public static
  • equalToIgnoringCase() public static
  • equalToWithDelta() public static
  • exactly() public static

    返回一个匹配器,当方法执行恰好 $count 次时匹配。

  • expectDeprecationMessageMatches() public
  • expectErrorHandlerMessageMatches() protected
  • expectErrorMessageMatches() public
  • expectException() public
  • expectExceptionCode() public
  • expectExceptionMessage() public
  • expectExceptionMessageMatches() public
  • expectExceptionObject() public

    为测试代码中要引发的异常设置预期。有关预期异常类、预期异常消息和预期异常代码的信息,请从给定的异常对象中检索。

  • expectNotToPerformAssertions() public
  • expectNoticeMessageMatches() public
  • expectOutputRegex() public
  • expectOutputString() public
  • expectWarningMessageMatches() public
  • expectsOutput() public
  • fail() public static

    使用给定的消息使测试失败。

  • fetchTable() public

    获取表实例的便捷方法。

  • fileExists() public static
  • getActualOutputForAssertion() public
  • getCount() public static

    返回当前断言计数。

  • getFixtureStrategy() public

    返回这些测试使用的夹具策略。

  • getFixtures() public

    获取此测试应使用的夹具。

  • getMockBuilder() public

    返回一个构建器对象,使用流畅的接口创建模拟对象。

  • getMockForAbstractClass() protected deprecated

    为指定的抽象类创建一个模拟对象,其中该类所有抽象方法都被模拟。默认情况下,具体方法不会被模拟。要模拟具体方法,请使用第七个参数($mockedMethods)。

  • getMockForModel() public

    模拟模型,维护夹具和表格关联

  • getMockForTrait() protected deprecated

    为指定的特性创建一个模拟对象,其中该特性的所有抽象方法都被模拟。可以使用 `$mockedMethods` 参数指定要模拟的具体方法。

  • getMockFromWsdl() protected deprecated

    根据给定的 WSDL 文件创建一个模拟对象。

  • getObjectForTrait() 受保护 已弃用

    创建一个使用指定特性的对象。

  • getTableLocator() 公共

    获取表格定位器。

  • greaterThan() 公共 静态
  • greaterThanOrEqual() 公共 静态
  • groups() 公共
  • hasDependencyInput() 公共
  • hasUnexpectedOutput() 公共
  • identicalTo() 公共 静态
  • iniSet() 受保护 已弃用

    此方法是 ini_set() 函数的包装器,它会在测试运行后自动将修改后的 php.ini 设置重置为其原始值。

  • isEmpty() 公共 静态
  • isFalse() 公共 静态
  • isFinite() 公共 静态
  • isInfinite() 公共 静态
  • isInstanceOf() 公共 静态
  • isJson() 公共 静态
  • isList() 公共 静态
  • isNan() 公共 静态
  • isNull() 公共 静态
  • isReadable() 公共 静态
  • isTrue() 公共 静态
  • isType() 公共 静态
  • isWritable() 公共 静态
  • lessThan() 公共 静态
  • lessThanOrEqual() 公共 静态
  • loadPlugins() 公共

    将插件加载到模拟应用程序中。

  • loadRoutes() 公共

    为应用程序加载路由。

  • logicalAnd() 公共 静态
  • logicalNot() 公共 静态
  • logicalOr() 公共 静态
  • logicalXor() 公共 静态
  • markTestIncomplete() 公共 静态

    将测试标记为不完整。

  • markTestSkipped() 公共 静态

    将测试标记为跳过。

  • matches() 公共 静态
  • matchesRegularExpression() 公共 静态
  • name() 公共
  • nameWithDataSet() 公共
  • never() 公共 静态

    返回一个匹配器,当方法从未执行时匹配。

  • numberOfAssertionsPerformed() 公共
  • objectEquals() 公共 静态
  • onConsecutiveCalls() 公共 静态 已弃用
  • onNotSuccessfulTest() 受保护

    当测试方法未成功执行时调用此方法。

  • once() 公共 静态

    返回一个匹配器,当方法被执行恰好一次时匹配。

  • output() 公共
  • providedData() 公共
  • provides() 公共
  • registerComparator() 受保护
  • registerFailureType() 受保护
  • registerMockObject() 公共
  • registerMockObjectsFromTestArgumentsRecursively() 公共 已弃用
  • removePlugins() 公共

    从全局插件集合中删除插件。

  • requires() 公共
  • resetCount() 公共 静态

    重置断言计数器。

  • result() 公共
  • returnArgument() 公共 静态 已弃用
  • returnCallback() 公共 静态 已弃用
  • returnSelf() 公共 静态 已弃用
  • returnValue() 公共 静态 已弃用
  • returnValueMap() 公共 静态 已弃用
  • run() 公共
  • runBare() 公共
  • runTest() 受保护
  • setAppNamespace() 公共 静态

    设置应用程序命名空间

  • setBackupGlobals() 公共
  • setBackupGlobalsExcludeList() 公共
  • setBackupStaticProperties() 公共
  • setBackupStaticPropertiesExcludeList() 公共
  • setData() 公共
  • setDependencies() 公共
  • setDependencyInput() 公共
  • setGroups() 公共
  • setInIsolation() 公共
  • setLocale() 受保护 已弃用

    此方法是 setlocale() 函数的包装器,它会在测试运行后自动将区域设置重置为其原始值。

  • setName() 公共
  • setPreserveGlobalState() 公共
  • setResult() 公共
  • setRunClassInSeparateProcess() 公共
  • setRunTestInSeparateProcess() 公共
  • setTableLocator() 公共

    设置表格定位器。

  • setUp() 受保护

    设置测试用例,备份静态对象值以便可以恢复。特别备份 Configure 的内容和 App 中的路径,如果它们尚未备份。

  • setUpBeforeClass() 公共 静态

    此方法在运行此测试类的第一个测试之前被调用。

  • setupFixtures() 受保护

    初始化并加载任何使用的夹具。

  • size() 公共
  • skipIf() 公共

    覆盖 SimpleTestCase::skipIf 以提供布尔返回值

  • skipUnless() 受保护

    用于跳过的兼容性函数。

  • sortId() 公共
  • status() 公共
  • stringContains() 公共 静态
  • stringEndsWith() 公共 静态
  • stringEqualsStringIgnoringLineEndings() 公共 静态
  • stringStartsWith() 公共 静态
  • tearDown() 受保护

    拆卸任何静态对象更改并恢复它们。

  • tearDownAfterClass() 公共 静态

    此方法在运行此测试类的最后一个测试后被调用。

  • teardownFixtures() 受保护

    卸载任何使用的夹具。

  • throwException() 公共 静态
  • toString() 公共

    返回测试用例的字符串表示形式。

  • transformException() 受保护
  • usesDataProvider() 公共
  • valueObjectForEvents() 公共
  • wasPrepared() 公共
  • withConsecutive() 公共 静态
  • withErrorReporting() 公共

    需要使用 error_reporting() 的测试的辅助方法

方法详情

__construct() ¶ 公共

__construct(string $name)
参数
字符串 $name

_assertAttributes() ¶ 受保护

_assertAttributes(array<string, mixed> $assertions, string $string, bool $fullDebug = false, array|string $regex = ''): string|false

检查作为 assertTags() 检查的一部分的属性。

参数
数组<字符串, 混合> $assertions

要运行的断言。

字符串 $string

要检查的 HTML 字符串。

布尔 $fullDebug 可选

是否应该使用更详细的输出。

数组|字符串 $regex 可选

来自 assertHtml 的完整正则表达式

返回值
字符串|false

_getTableClassName() ¶ 受保护

_getTableClassName(string $alias, array<string, mixed> $options): class-stringCake\ORM\Table>

获取表的类名。

参数
字符串 $alias

要获取模拟的模型。

数组<字符串, 混合> $options

模拟构造函数的配置数据。

返回值
class-stringCake\ORM\Table>
抛出
Cake\ORM\Exception\MissingTableClassException

_normalizePath() ¶ 受保护

_normalizePath(string $path): string

规范化用于比较的路径。

参数
字符串 $path

由“/”斜杠分隔的路径。

返回值
字符串

addFixture() ¶ 受保护

addFixture(string $fixture): $this

向此测试用例添加夹具。

示例

  • core.Tags
  • app.MyRecords
  • plugin.MyPluginName.MyModelName

在您的测试用例的 {@link getFixtures()} 方法中使用此方法来构建夹具列表。

参数
字符串 $fixture

夹具

返回值
$this

addToAssertionCount() ¶ 公共

addToAssertionCount(int $count): void
参数
整数 $count
返回值
空

any() ¶ 公共 静态

any(): AnyInvokedCountMatcher

返回一个匹配器,当方法执行零次或多次时匹配。

返回值
AnyInvokedCountMatcher

anything() ¶ 公共 静态

anything(): IsAnything
返回值
IsAnything

arrayHasKey() ¶ 公共 静态

arrayHasKey(int|string $key): ArrayHasKey
参数
整数|字符串 $key
返回值
ArrayHasKey

assertArrayHasKey() ¶ 公共 静态

assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void

断言数组具有指定的键。

参数
整数|字符串 $key
数组|ArrayAccess $array
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertArrayNotHasKey() ¶ 公共 静态

assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void

断言数组没有指定的键。

参数
整数|字符串 $key
数组|ArrayAccess $array
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertContains() ¶ 公共 静态

assertContains(mixed $needle, iterable $haystack, string $message = ''): void

断言干草堆包含针。

参数
混合 $needle
可迭代 $haystack
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertContainsEquals() ¶ public static

assertContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
参数
混合 $needle
可迭代 $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertContainsOnly() ¶ public static

assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void

断言干草堆仅包含给定类型的值。

参数
string $type
可迭代 $haystack
?bool $isNativeType optional
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertContainsOnlyInstancesOf() ¶ public static

assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void

断言干草堆仅包含给定类名的实例。

参数
string $className
可迭代 $haystack
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertCount() ¶ public static

assertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void

断言数组、可计数或可遍历的元素数量。

参数
int $expectedCount
Countable|iterable $haystack
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

GeneratorNotSupportedException

assertDirectoryDoesNotExist() ¶ public static

assertDirectoryDoesNotExist(string $directory, string $message = ''): void

断言目录不存在。

参数
string $directory
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertDirectoryExists() ¶ public static

assertDirectoryExists(string $directory, string $message = ''): void

断言目录存在。

参数
string $directory
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertDirectoryIsNotReadable() ¶ public static

assertDirectoryIsNotReadable(string $directory, string $message = ''): void

断言目录存在且不可读。

参数
string $directory
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertDirectoryIsNotWritable() ¶ public static

assertDirectoryIsNotWritable(string $directory, string $message = ''): void

断言目录存在且不可写。

参数
string $directory
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertDirectoryIsReadable() ¶ public static

assertDirectoryIsReadable(string $directory, string $message = ''): void

断言目录存在且可读。

参数
string $directory
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertDirectoryIsWritable() ¶ public static

assertDirectoryIsWritable(string $directory, string $message = ''): void

断言目录存在且可写。

参数
string $directory
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertDoesNotMatchRegularExpression() ¶ public static

assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void

断言字符串与给定的正则表达式不匹配。

参数
string $pattern
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertEmpty() ¶ public static

assertEmpty(mixed $actual, string $message = ''): void

断言变量为空。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

GeneratorNotSupportedException

assertEquals() ¶ public static

assertEquals(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量相等。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertEqualsCanonicalizing() ¶ public static

assertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量相等(规范化)。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertEqualsIgnoringCase() ¶ public static

assertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量相等(不区分大小写)。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertEqualsSql() ¶ public

assertEqualsSql(string $expected, string $actual, string $message = ''): void

断言字符串与 SQL 匹配,其中删除了特定于数据库的字符(如引号)。

参数
string $expected

预期的 SQL 语句

string $actual

要比较的 SQL 语句

字符串 $message 可选

失败时显示的消息

返回值
空

assertEqualsWithDelta() ¶ public static

assertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void

断言两个变量相等(带 delta)。

参数
mixed $expected
mixed $actual
float $delta
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertEventFired() ¶ public

assertEventFired(string $name, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void

断言全局事件已触发。您必须在事件管理器中跟踪事件才能使此断言起作用

参数
字符串 $name

事件名称

Cake\Event\EventManager|null $eventManager optional

要检查的事件管理器,默认为全局事件管理器

字符串 $message 可选

断言失败消息

返回值
空

assertEventFiredWith() ¶ public

assertEventFiredWith(string $name, string $dataKey, mixed $dataValue, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void

断言事件已触发并带数据

如果传递了第三个参数,则该值用于与 $dataKey 中的值进行比较

参数
字符串 $name

事件名称

string $dataKey

数据键

mixed $dataValue

数据值

Cake\Event\EventManager|null $eventManager optional

要检查的事件管理器,默认为全局事件管理器

字符串 $message 可选

断言失败消息

返回值
空

assertFalse() ¶ public static

assertFalse(mixed $condition, string $message = ''): void

断言条件为假。

参数
mixed $condition
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileDoesNotExist() ¶ public static

assertFileDoesNotExist(string $filename, string $message = ''): void

断言文件不存在。

参数
string $filename
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileEquals() ¶ public static

assertFileEquals(string $expected, string $actual, string $message = ''): void

断言一个文件的内容等于另一个文件的内容。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileEqualsCanonicalizing() ¶ public static

assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void

断言一个文件的内容等于另一个文件的内容(规范化)。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileEqualsIgnoringCase() ¶ public static

assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void

断言一个文件的内容等于另一个文件的内容(不区分大小写)。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileExists() ¶ public static

assertFileExists(string $filename, string $message = ''): void

断言文件存在。

参数
string $filename
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileIsNotReadable() ¶ public static

assertFileIsNotReadable(string $file, string $message = ''): void

断言文件存在且不可读。

参数
string $file
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileIsNotWritable() ¶ public static

assertFileIsNotWritable(string $file, string $message = ''): void

断言文件存在且不可写。

参数
string $file
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileIsReadable() ¶ public static

assertFileIsReadable(string $file, string $message = ''): void

断言文件存在且可读。

参数
string $file
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileIsWritable() ¶ public static

assertFileIsWritable(string $file, string $message = ''): void

断言文件存在且可写。

参数
string $file
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileMatchesFormat() ¶ public static

assertFileMatchesFormat(string $format, string $actualFile, string $message = ''): void

断言字符串与给定的格式字符串匹配。

参数
string $format
string $actualFile
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileMatchesFormatFile() ¶ public static

assertFileMatchesFormatFile(string $formatFile, string $actualFile, string $message = ''): void

断言字符串与给定的格式字符串匹配。

参数
string $formatFile
string $actualFile
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileNotEquals() ¶ public static

assertFileNotEquals(string $expected, string $actual, string $message = ''): void

断言一个文件的内容不等于另一个文件的内容。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileNotEqualsCanonicalizing() ¶ public static

assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void

断言一个文件的内容不等于另一个文件的内容(规范化)。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFileNotEqualsIgnoringCase() ¶ public static

assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void

断言一个文件的内容不等于另一个文件的内容(不区分大小写)。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertFinite() ¶ public static

assertFinite(mixed $actual, string $message = ''): void

断言变量为有限。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertGreaterThan() ¶ public static

assertGreaterThan(mixed $expected, mixed $actual, string $message = ''): void

断言一个值大于另一个值。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertGreaterThanOrEqual() ¶ public static

assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void

断言一个值大于或等于另一个值。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertHtml() ¶ public

assertHtml(array $expected, string $string, bool $fullDebug = false): bool

断言 HTML 标签。

接收一个数组 $expected 并从中生成一个正则表达式以匹配提供的 $string。 $expected 的示例

检查一个名为 input 的标签,其 name 属性(包含任何非空值)和 id 属性包含 'my-input'

['input' => ['name', 'id' => 'my-input']]

检查两个包含一些文本的 p 元素

[
  ['p' => true],
  'textA',
  '/p',
  ['p' => true],
  'textB',
  '/p'
]

您也可以在属性值或定义的标签中指定模式表达式,如果在值前面加上 preg: 并用斜线括起来,例如

[
  ['input' => ['name', 'id' => 'preg:/FieldName\d+/']],
  'preg:/My\s+field/'
]

重要:此函数对空格非常宽容,并且接受任何属性顺序排列。 它还允许指定标签之间的空格。

参数
array $expected

一个数组,见上文

字符串 $string

一个 HTML/XHTML/XML 字符串

布尔 $fullDebug 可选

是否应该使用更详细的输出。

返回值
bool

assertInfinite() ¶ public static

assertInfinite(mixed $actual, string $message = ''): void

断言变量为无穷大。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertInstanceOf() ¶ public static

assertInstanceOf(string $expected, mixed $actual, string $message = ''): void

断言变量为给定类型。

参数
string $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

UnknownClassOrInterfaceException

assertIsArray() ¶ public static

assertIsArray(mixed $actual, string $message = ''): void

断言变量为数组类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsBool() ¶ public static

assertIsBool(mixed $actual, string $message = ''): void

断言变量为布尔类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsCallable() ¶ public static

assertIsCallable(mixed $actual, string $message = ''): void

断言变量为可调用类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsClosedResource() ¶ public static

assertIsClosedResource(mixed $actual, string $message = ''): void

断言变量为资源类型并且已关闭。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsFloat() ¶ public static

assertIsFloat(mixed $actual, string $message = ''): void

断言变量为浮点数类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsInt() ¶ public static

assertIsInt(mixed $actual, string $message = ''): void

断言变量为整型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsIterable() ¶ public static

assertIsIterable(mixed $actual, string $message = ''): void

断言变量为可迭代类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsList() ¶ public static

assertIsList(mixed $array, string $message = ''): void
参数
mixed $array
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertIsNotArray() ¶ public static

assertIsNotArray(mixed $actual, string $message = ''): void

断言变量不是数组类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotBool() ¶ public static

assertIsNotBool(mixed $actual, string $message = ''): void

断言变量不是布尔类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotCallable() ¶ public static

assertIsNotCallable(mixed $actual, string $message = ''): void

断言变量不是可调用类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotClosedResource() ¶ public static

assertIsNotClosedResource(mixed $actual, string $message = ''): void

断言变量不是资源类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotFloat() ¶ public static

assertIsNotFloat(mixed $actual, string $message = ''): void

断言变量不是浮点数类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotInt() ¶ public static

assertIsNotInt(mixed $actual, string $message = ''): void

断言变量不是整型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotIterable() ¶ public static

assertIsNotIterable(mixed $actual, string $message = ''): void

断言变量不是可迭代类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotNumeric() ¶ public static

assertIsNotNumeric(mixed $actual, string $message = ''): void

断言变量不是数值类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotObject() ¶ public static

assertIsNotObject(mixed $actual, string $message = ''): void

断言变量不是对象类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotReadable() ¶ public static

assertIsNotReadable(string $filename, string $message = ''): void

断言文件/目录存在且不可读。

参数
string $filename
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertIsNotResource() ¶ public static

assertIsNotResource(mixed $actual, string $message = ''): void

断言变量不是资源类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotScalar() ¶ public static

assertIsNotScalar(mixed $actual, string $message = ''): void

断言变量不是标量类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotString() ¶ public static

assertIsNotString(mixed $actual, string $message = ''): void

断言变量不是字符串类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsNotWritable() ¶ public static

assertIsNotWritable(string $filename, string $message = ''): void

断言文件/目录存在且不可写。

参数
string $filename
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertIsNumeric() ¶ public static

assertIsNumeric(mixed $actual, string $message = ''): void

断言变量为数值类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsObject() ¶ public static

assertIsObject(mixed $actual, string $message = ''): void

断言变量为对象类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsReadable() ¶ public static

assertIsReadable(string $filename, string $message = ''): void

断言文件/目录可读。

参数
string $filename
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertIsResource() ¶ public static

assertIsResource(mixed $actual, string $message = ''): void

断言变量为资源类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsScalar() ¶ public static

assertIsScalar(mixed $actual, string $message = ''): void

断言变量为标量类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsString() ¶ public static

assertIsString(mixed $actual, string $message = ''): void

断言变量为字符串类型。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertIsWritable() ¶ public static

assertIsWritable(string $filename, string $message = ''): void

断言文件/目录存在且可写。

参数
string $filename
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJson() ¶ public static

assertJson(string $actual, string $message = ''): void

断言字符串为有效的 JSON 字符串。

参数
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJsonFileEqualsJsonFile() ¶ public static

assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void

断言两个 JSON 文件相等。

参数
string $expectedFile
string $actualFile
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJsonFileNotEqualsJsonFile() ¶ public static

assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void

断言两个 JSON 文件不相等。

参数
string $expectedFile
string $actualFile
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJsonStringEqualsJsonFile() ¶ public static

assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void

断言生成的 JSON 编码对象和给定文件的内容相等。

参数
string $expectedFile
string $actualJson
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJsonStringEqualsJsonString() ¶ public static

assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void

断言两个给定的 JSON 编码对象或数组相等。

参数
string $expectedJson
string $actualJson
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJsonStringNotEqualsJsonFile() ¶ public static

assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void

断言生成的 JSON 编码对象和给定文件的内容不相等。

参数
string $expectedFile
string $actualJson
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertJsonStringNotEqualsJsonString() ¶ public static

assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void

断言两个给定的 JSON 编码对象或数组不相等。

参数
string $expectedJson
string $actualJson
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertLessThan() ¶ public static

assertLessThan(mixed $expected, mixed $actual, string $message = ''): void

断言一个值小于另一个值。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertLessThanOrEqual() ¶ public static

assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void

断言一个值小于或等于另一个值。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertMatchesRegularExpression() ¶ public static

assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void

断言字符串与给定的正则表达式匹配。

参数
string $pattern
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNan() ¶ public static

assertNan(mixed $actual, string $message = ''): void

断言变量为 NaN。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotContains() ¶ public static

assertNotContains(mixed $needle, iterable $haystack, string $message = ''): void

断言干草堆中不包含针。

参数
混合 $needle
可迭代 $haystack
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertNotContainsEquals() ¶ public static

assertNotContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
参数
混合 $needle
可迭代 $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotContainsOnly() ¶ public static

assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void

断言干草堆中不只包含给定类型的值。

参数
string $type
可迭代 $haystack
?bool $isNativeType optional
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertNotCount() ¶ public static

assertNotCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void

断言数组、可计数或可遍历的元素数量。

参数
int $expectedCount
Countable|iterable $haystack
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

GeneratorNotSupportedException

assertNotEmpty() ¶ public static

assertNotEmpty(mixed $actual, string $message = ''): void

断言变量不为空。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

GeneratorNotSupportedException

assertNotEquals() ¶ public static

assertNotEquals(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量不相等。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotEqualsCanonicalizing() ¶ public static

assertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量不相等(规范化)。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotEqualsIgnoringCase() ¶ public static

assertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量不相等(忽略大小写)。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotEqualsWithDelta() ¶ public static

assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void

断言两个变量不相等(带 delta)。

参数
mixed $expected
mixed $actual
float $delta
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotFalse() ¶ public static

assertNotFalse(mixed $condition, string $message = ''): void

断言条件不为假。

参数
mixed $condition
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotInstanceOf() ¶ public static

assertNotInstanceOf(string $expected, mixed $actual, string $message = ''): void

断言变量不是给定类型。

参数
string $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

assertNotNull() ¶ public static

assertNotNull(mixed $actual, string $message = ''): void

断言变量不为空。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotSame() ¶ public static

assertNotSame(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量类型和值不同。在对象上使用时,它断言两个变量不引用同一个对象。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotSameSize() ¶ public static

assertNotSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void

断言两个数组(或 Countable 或 Traversable 对象)的大小不同。

参数
Countable|iterable $expected
Countable|iterable $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

GeneratorNotSupportedException

assertNotTrue() ¶ public static

assertNotTrue(mixed $condition, string $message = ''): void

断言条件不为真。

参数
mixed $condition
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertNotWithinRange() ¶ protected static

assertNotWithinRange(float $expected, float $result, float $margin, string $message = ''): void

兼容性函数,用于测试值是否不在可接受的范围内。

参数
float $expected
float $result
float $margin

the rage of acceptation

字符串 $message 可选

the text to display if the assertion is not correct

返回值
空

assertNull() ¶ public static

assertNull(mixed $actual, string $message = ''): void

断言变量为空。

参数
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertObjectEquals() ¶ public static

assertObjectEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void
参数
object $expected
object $actual
string $method optional
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertObjectHasProperty() ¶ public static

assertObjectHasProperty(string $propertyName, object $object, string $message = ''): void

断言对象具有指定的属性。

参数
string $propertyName
object $object
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertObjectNotHasProperty() ¶ public static

assertObjectNotHasProperty(string $propertyName, object $object, string $message = ''): void

断言对象没有指定的属性。

参数
string $propertyName
object $object
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertPathEquals() ¶ protected static

assertPathEquals(string $expected, string $result, string $message = ''): void

兼容性函数,用于测试路径。

参数
string $expected
string $result
字符串 $message 可选

the text to display if the assertion is not correct

返回值
空

assertPostConditions() ¶ protected

assertPostConditions(): void

执行所有测试用例测试共享的断言。

此方法在测试和 tearDown() 之间调用。

返回值
空

assertPreConditions() ¶ protected

assertPreConditions(): void

执行所有测试用例测试共享的断言。

此方法在 setUp() 和测试之间调用。

返回值
空

assertRegExpSql() ¶ public

assertRegExpSql(string $pattern, string $actual, bool $optional = false): void

用于将正则表达式模式与具有其标识符引号的查询进行比较的断言。它接受用字符 < 和 > 引号的查询。如果第三个参数设置为 true,它将更改模式以接受带引号和不带引号的查询

参数
string $pattern

预期的 SQL 模式

string $actual

要比较的 SQL 语句

bool $optional optional

引号字符(用 <> 标记)是否可选

返回值
空

assertSame() ¶ public static

assertSame(mixed $expected, mixed $actual, string $message = ''): void

断言两个变量具有相同的类型和值。在对象上使用时,它断言两个变量引用同一个对象。

参数
mixed $expected
mixed $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertSameSize() ¶ public static

assertSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void

断言两个数组(或 Countable 或 Traversable 对象)的大小相同。

参数
Countable|iterable $expected
Countable|iterable $actual
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

GeneratorNotSupportedException

assertStringContainsString() ¶ public static

assertStringContainsString(string $needle, string $haystack, string $message = ''): void
参数
string $needle
string $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringContainsStringIgnoringCase() ¶ public static

assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
参数
string $needle
string $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringContainsStringIgnoringLineEndings() ¶ public static

assertStringContainsStringIgnoringLineEndings(string $needle, string $haystack, string $message = ''): void
参数
string $needle
string $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringEndsNotWith() ¶ public static

assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void

断言字符串不以给定后缀结尾。

参数
string $suffix
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

InvalidArgumentException

assertStringEndsWith() ¶ public static

assertStringEndsWith(string $suffix, string $string, string $message = ''): void

断言字符串以给定后缀结尾。

参数
string $suffix
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

InvalidArgumentException

assertStringEqualsFile() ¶ public static

assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void

断言字符串的内容与文件的内容相等。

参数
string $expectedFile
string $actualString
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringEqualsFileCanonicalizing() ¶ public static

assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void

断言字符串的内容与文件的内容相等(规范化)。

参数
string $expectedFile
string $actualString
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringEqualsFileIgnoringCase() ¶ public static

assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void

断言字符串的内容与文件的内容相等(忽略大小写)。

参数
string $expectedFile
string $actualString
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringEqualsStringIgnoringLineEndings() ¶ public static

assertStringEqualsStringIgnoringLineEndings(string $expected, string $actual, string $message = ''): void

断言两个字符串除了行尾以外完全相同。

参数
string $expected
string $actual
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringMatchesFormat() ¶ public static

assertStringMatchesFormat(string $format, string $string, string $message = ''): void

断言字符串与给定的格式字符串匹配。

参数
string $format
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringMatchesFormatFile() ¶ public static

assertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void

断言一个字符串与给定的格式文件匹配。

参数
string $formatFile
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotContainsString() ¶ public static

assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
参数
string $needle
string $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotContainsStringIgnoringCase() ¶ public static

assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
参数
string $needle
string $haystack
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotEqualsFile() ¶ public static

assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void

断言一个字符串的内容与文件的内容不一致。

参数
string $expectedFile
string $actualString
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotEqualsFileCanonicalizing() ¶ public static

assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void

断言一个字符串的内容与文件的内容不一致(规范化)。

参数
string $expectedFile
string $actualString
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotEqualsFileIgnoringCase() ¶ public static

assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void

断言一个字符串的内容与文件的内容不一致(忽略大小写)。

参数
string $expectedFile
string $actualString
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotMatchesFormat() ¶ public static

assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void

断言一个字符串与给定的格式字符串不匹配。

参数
string $format
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringNotMatchesFormatFile() ¶ public static

assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void

断言一个字符串与给定的格式字符串不匹配。

参数
string $formatFile
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertStringStartsNotWith() ¶ public static

assertStringStartsNotWith(string $prefix, string $string, string $message = ''): void

断言一个字符串不以给定的前缀开头。

参数
string $prefix
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

InvalidArgumentException

assertStringStartsWith() ¶ public static

assertStringStartsWith(string $prefix, string $string, string $message = ''): void

断言一个字符串以给定的前缀开头。

参数
string $prefix
字符串 $string
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

InvalidArgumentException

assertTextContains() ¶ public

assertTextContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void

断言一个字符串包含另一个字符串,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $needle

要搜索的字符串。

string $haystack

要搜索的字符串。

字符串 $message 可选

断言失败时显示的消息。

bool $ignoreCase optional

搜索是否区分大小写。

返回值
空

assertTextEndsNotWith() ¶ public

assertTextEndsNotWith(string $suffix, string $string, string $message = ''): void

断言一个字符串不以给定的前缀结尾,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $suffix

不应找到的后缀。

字符串 $string

要搜索的字符串。

字符串 $message 可选

失败时使用的消息。

返回值
空

assertTextEndsWith() ¶ public

assertTextEndsWith(string $suffix, string $string, string $message = ''): void

断言一个字符串以给定的前缀结尾,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $suffix

要找到的后缀。

字符串 $string

要搜索的字符串。

字符串 $message 可选

失败时使用的消息。

返回值
空

assertTextEquals() ¶ public

assertTextEquals(string $expected, string $result, string $message = ''): void

断言文本相等,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $expected

预期值。

string $result

实际值。

字符串 $message 可选

失败时使用的消息。

返回值
空

assertTextNotContains() ¶ public

assertTextNotContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void

断言文本不包含另一个文本,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $needle

要搜索的字符串。

string $haystack

要搜索的字符串。

字符串 $message 可选

断言失败时显示的消息。

bool $ignoreCase optional

搜索是否区分大小写。

返回值
空

assertTextNotEquals() ¶ public

assertTextNotEquals(string $expected, string $result, string $message = ''): void

断言文本相等,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $expected

预期值。

string $result

实际值。

字符串 $message 可选

失败时使用的消息。

返回值
空

assertTextStartsNotWith() ¶ public

assertTextStartsNotWith(string $prefix, string $string, string $message = ''): void

断言一个字符串不以给定的前缀开头,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $prefix

不应找到的前缀。

字符串 $string

要搜索的字符串。

字符串 $message 可选

失败时使用的消息。

返回值
空

assertTextStartsWith() ¶ public

assertTextStartsWith(string $prefix, string $string, string $message = ''): void

断言一个字符串以给定的前缀开头,忽略换行符的差异。这对进行跨平台文本块测试很有帮助。

参数
string $prefix

要检查的前缀。

字符串 $string

要搜索的字符串。

字符串 $message 可选

失败时使用的消息。

返回值
空

assertThat() ¶ public static

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

评估 PHPUnit\Framework\Constraint 匹配器对象。

参数
mixed $value
Constraint $constraint
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertTrue() ¶ public static

assertTrue(mixed $condition, string $message = ''): void

断言一个条件为真。

参数
mixed $condition
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

assertWithinRange() ¶ protected static

assertWithinRange(float $expected, float $result, float $margin, string $message = ''): void

兼容性函数,用于测试一个值是否在可接受的范围内。

参数
float $expected
float $result
float $margin

the rage of acceptation

字符串 $message 可选

the text to display if the assertion is not correct

返回值
空

assertXmlFileEqualsXmlFile() ¶ public static

assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void

断言两个 XML 文件相等。

参数
string $expectedFile
string $actualFile
字符串 $message 可选
返回值
空
抛出
异常

ExpectationFailedException

XmlException

assertXmlFileNotEqualsXmlFile() ¶ public static

assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void

断言两个 XML 文件不相等。

参数
string $expectedFile
string $actualFile
字符串 $message 可选
返回值
空
抛出
PHPUnit\Util\Exception

ExpectationFailedException

assertXmlStringEqualsXmlFile() ¶ public static

assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void

断言两个 XML 文档相等。

参数
string $expectedFile
string $actualXml
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

XmlException

assertXmlStringEqualsXmlString() ¶ public static

assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void

断言两个 XML 文档相等。

参数
string $expectedXml
string $actualXml
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

XmlException

assertXmlStringNotEqualsXmlFile() ¶ public static

assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void

断言两个 XML 文档不相等。

参数
string $expectedFile
string $actualXml
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

XmlException

assertXmlStringNotEqualsXmlString() ¶ public static

assertXmlStringNotEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void

断言两个 XML 文档不相等。

参数
string $expectedXml
string $actualXml
字符串 $message 可选
返回值
空
抛出
ExpectationFailedException

XmlException

atLeast() ¶ public static

atLeast(int $requiredInvocations): InvokedAtLeastCountMatcher

返回一个匹配器,当方法执行至少 N 次时匹配。

参数
int $requiredInvocations
返回值
InvokedAtLeastCountMatcher

atLeastOnce() ¶ public static

atLeastOnce(): InvokedAtLeastOnceMatcher

返回一个匹配器,当方法执行至少一次时匹配。

返回值
InvokedAtLeastOnceMatcher

atMost() ¶ public static

atMost(int $allowedInvocations): InvokedAtMostCountMatcher

返回一个匹配器,当方法执行最多 N 次时匹配。

参数
int $allowedInvocations
返回值
InvokedAtMostCountMatcher

callback() ¶ public static

callback(callable $callback): Callback
参数
callable $callback
返回值
Callback

captureError() ¶ public

captureError(int $errorLevel, Closure $callable): Cake\Error\PhpError

捕获 $callable 中的错误,以便您可以对错误进行断言。

如果未捕获错误,断言将失败。

参数
int $errorLevel

要使用的 error_reporting() 的值。

Closure $callable

用于捕获错误的闭包。

返回值
Cake\Error\PhpError

clearPlugins() ¶ public

clearPlugins(): void

从全局插件集合中清除所有插件。

在测试用例拆卸方法中很有用。

返回值
空

containsEqual() ¶ public static

containsEqual(mixed $value): TraversableContainsEqual
参数
mixed $value
返回值
TraversableContainsEqual

containsIdentical() ¶ public static

containsIdentical(mixed $value): TraversableContainsIdentical
参数
mixed $value
返回值
TraversableContainsIdentical

containsOnly() ¶ public static

containsOnly(string $type): TraversableContainsOnly
参数
string $type
返回值
TraversableContainsOnly
抛出
异常

containsOnlyInstancesOf() ¶ public static

containsOnlyInstancesOf(string $className): TraversableContainsOnly
参数
string $className
返回值
TraversableContainsOnly
抛出
异常

count() ¶ public

count(): int
返回值
int

countOf() ¶ public static

countOf(int $count): Count
参数
整数 $count
返回值
Count

createConfiguredMock() ¶ protected

createConfiguredMock(string $originalClassName, array $configuration): MockObject

为指定的接口或类创建(并配置)一个模拟对象。

参数
string $originalClassName
array $configuration
返回值
MockObject
抛出
InvalidArgumentException

MockObjectException

NoPreviousThrowableException

createConfiguredStub() ¶ protected static

createConfiguredStub(string $originalClassName, array $configuration): Stub

为指定的接口或类创建(并配置)一个测试存根。

参数
string $originalClassName
array $configuration
返回值
Stub
抛出
InvalidArgumentException

MockObjectException

NoPreviousThrowableException

createMock() ¶ protected

createMock(string $originalClassName): MockObject

为指定的接口或类创建模拟对象。

参数
string $originalClassName
返回值
MockObject
抛出
InvalidArgumentException

MockObjectException

NoPreviousThrowableException

createMockForIntersectionOfInterfaces() ¶ protected

createMockForIntersectionOfInterfaces(array $interfaces): MockObject
参数
array $interfaces
返回值
MockObject
抛出
MockObjectException

createPartialMock() ¶ protected

createPartialMock(string $originalClassName, array $methods): MockObject

为指定的接口或类创建部分模拟对象。

参数
string $originalClassName
array $methods
返回值
MockObject
抛出
InvalidArgumentException

MockObjectException

createStub() ¶ protected static

createStub(string $originalClassName): Stub

为指定的接口或类创建测试存根。

参数
string $originalClassName
返回值
Stub
抛出
InvalidArgumentException

MockObjectException

NoPreviousThrowableException

createStubForIntersectionOfInterfaces() ¶ protected static

createStubForIntersectionOfInterfaces(array $interfaces): Stub
参数
array $interfaces
返回值
Stub
抛出
MockObjectException

createTestProxy() ¶ protected

createTestProxy(string $originalClassName, array $constructorArguments = []): MockObject

为指定的类创建测试代理。

参数
string $originalClassName
array $constructorArguments optional
返回值
MockObject
抛出
InvalidArgumentException

MockObjectException

dataName() ¶ public

dataName(): int|string
返回值
int|string

dataSetAsString() ¶ public

dataSetAsString(): string
返回值
字符串

dataSetAsStringWithData() ¶ public

dataSetAsStringWithData(): string
返回值
字符串

dependencyInput() ¶ public

dependencyInput(): array
返回值
数组

deprecated() ¶ public

deprecated(Closure $callable): void

检查弃用方法的辅助方法

参数
Closure $callable

将接收断言的可调用函数

返回值
空

directoryExists() ¶ public static

directoryExists(): DirectoryExists
返回值
DirectoryExists

doesNotPerformAssertions() ¶ public

doesNotPerformAssertions(): bool
返回值
bool

equalTo() ¶ public static

equalTo(mixed $value): IsEqual
参数
mixed $value
返回值
IsEqual

equalToCanonicalizing() ¶ public static

equalToCanonicalizing(mixed $value): IsEqualCanonicalizing
参数
mixed $value
返回值
IsEqualCanonicalizing

equalToIgnoringCase() ¶ public static

equalToIgnoringCase(mixed $value): IsEqualIgnoringCase
参数
mixed $value
返回值
IsEqualIgnoringCase

equalToWithDelta() ¶ public static

equalToWithDelta(mixed $value, float $delta): IsEqualWithDelta
参数
mixed $value
float $delta
返回值
IsEqualWithDelta

exactly() ¶ public static

exactly(int $count): InvokedCountMatcher

返回一个匹配器,当方法执行恰好 $count 次时匹配。

参数
整数 $count
返回值
InvokedCountMatcher

expectDeprecationMessageMatches() ¶ public

expectDeprecationMessageMatches(string $regex, Closure $callable): void
参数
string $regex

与弃用消息匹配的正则表达式

Closure $callable

应该触发警告的可调用函数

返回值
空
抛出
异常

expectErrorHandlerMessageMatches() ¶ protected

expectErrorHandlerMessageMatches(string $regex, Closure $callable, int $errorLevel): void
参数
string $regex

与警告消息匹配的正则表达式

Closure $callable

应该触发警告的可调用函数

int $errorLevel

要监听的错误级别

返回值
空
抛出
异常

expectErrorMessageMatches() ¶ public

expectErrorMessageMatches(string $regex, Closure $callable): void
参数
string $regex

与错误消息匹配的正则表达式

Closure $callable

应该触发警告的可调用函数

返回值
空
抛出
异常

expectException() ¶ public

expectException(string $exception): void
参数
string $exception
返回值
空

expectExceptionCode() ¶ public

expectExceptionCode(int|string $code): void
参数
int|string $code
返回值
空

expectExceptionMessage() ¶ public

expectExceptionMessage(string $message): void
参数
string $message
返回值
空

expectExceptionMessageMatches() ¶ public

expectExceptionMessageMatches(string $regularExpression): void
参数
string $regularExpression
返回值
空

expectExceptionObject() ¶ public

expectExceptionObject(Exception $exception): void

为测试代码中要引发的异常设置预期。有关预期异常类、预期异常消息和预期异常代码的信息,请从给定的异常对象中检索。

参数
Exception $exception
返回值
空

expectNotToPerformAssertions() ¶ public

expectNotToPerformAssertions(): void
返回值
空

expectNoticeMessageMatches() ¶ public

expectNoticeMessageMatches(string $regex, Closure $callable): void
参数
string $regex

与警告消息匹配的正则表达式

Closure $callable

应该触发警告的可调用函数

返回值
空
抛出
异常

expectOutputRegex() ¶ public

expectOutputRegex(string $expectedRegex): void
参数
string $expectedRegex
返回值
空

expectOutputString() ¶ public

expectOutputString(string $expectedString): void
参数
string $expectedString
返回值
空

expectWarningMessageMatches() ¶ public

expectWarningMessageMatches(string $regex, Closure $callable): void
参数
string $regex

与警告消息匹配的正则表达式

Closure $callable

应该触发警告的可调用函数

返回值
空
抛出
异常

expectsOutput() ¶ public

expectsOutput(): bool
返回值
bool

fail() ¶ public static

fail(string $message = ''): never

使用给定的消息使测试失败。

参数
字符串 $message 可选
返回值
never
抛出
AssertionFailedError

fetchTable() ¶ public

fetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table

获取表实例的便捷方法。

参数
string|null $alias optional

您要获取的别名。应使用驼峰式命名法。如果为 null,则使用 $defaultTable 属性的值。

array<string, mixed> $options optional

您要使用这些选项来构建表格。如果表格已加载,则注册表选项将被忽略。

返回值
Cake\ORM\Table
抛出
Cake\Core\Exception\CakeException
如果 `$alias` 参数和 `$defaultTable` 属性均为 `null`。
另请参阅
\Cake\ORM\TableLocator::get()

fileExists() ¶ public static

fileExists(): FileExists
返回值
FileExists

getActualOutputForAssertion() ¶ public

getActualOutputForAssertion(): string
返回值
字符串

getCount() ¶ public static

getCount(): int

返回当前断言计数。

返回值
int

getFixtureStrategy() ¶ public

getFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface

返回这些测试使用的夹具策略。

返回值
Cake\TestSuite\Fixture\FixtureStrategyInterface

getFixtures() ¶ public

getFixtures(): list<string>

获取此测试应使用的夹具。

返回值
列表

getMockBuilder() ¶ public

getMockBuilder(string $className): MockBuilder

返回一个构建器对象,使用流畅的接口创建模拟对象。

参数
string $className
返回值
MockBuilder

getMockForAbstractClass() ¶ protected

getMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject

为指定的抽象类创建一个模拟对象,其中该类所有抽象方法都被模拟。默认情况下,具体方法不会被模拟。要模拟具体方法,请使用第七个参数($mockedMethods)。

参数
string $originalClassName
array $arguments optional
string $mockClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional
array $mockedMethods optional
bool $cloneArguments optional
返回值
MockObject
抛出
InvalidArgumentException

MockObjectException

getMockForModel() ¶ public

getMockForModel(string $alias, list<string> $methods = [], array<string, mixed> $options = []): Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject

模拟模型,维护夹具和表格关联

参数
字符串 $alias

要获取模拟的模型。

list<string> $methods optional

要模拟的方法列表

array<string, mixed> $options optional

模拟构造函数的配置数据。

返回值
Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject
抛出
Cake\ORM\Exception\MissingTableClassException

getMockForTrait() ¶ protected

getMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject

为指定的特性创建一个模拟对象,其中该特性的所有抽象方法都被模拟。可以使用 `$mockedMethods` 参数指定要模拟的具体方法。

参数
string $traitName
array $arguments optional
string $mockClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional
array $mockedMethods optional
bool $cloneArguments optional
返回值
MockObject
抛出
InvalidArgumentException

MockObjectException

getMockFromWsdl() ¶ protected

getMockFromWsdl(string $wsdlFile, string $originalClassName = '', string $mockClassName = '', array $methods = [], bool $callOriginalConstructor = true, array $options = []): MockObject

根据给定的 WSDL 文件创建一个模拟对象。

参数
string $wsdlFile
string $originalClassName optional
string $mockClassName optional
array $methods optional
bool $callOriginalConstructor optional
array $options optional
返回值
MockObject
抛出
MockObjectException

getObjectForTrait() ¶ protected

getObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true): object

创建一个使用指定特性的对象。

参数
string $traitName
array $arguments optional
string $traitClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional
返回值
object
抛出
MockObjectException

getTableLocator() ¶ public

getTableLocator(): Cake\ORM\Locator\LocatorInterface

获取表格定位器。

返回值
Cake\ORM\Locator\LocatorInterface

greaterThan() ¶ public static

greaterThan(mixed $value): GreaterThan
参数
mixed $value
返回值
GreaterThan

greaterThanOrEqual() ¶ public static

greaterThanOrEqual(mixed $value): LogicalOr
参数
mixed $value
返回值
LogicalOr

groups() ¶ public

groups(): array
返回值
数组

hasDependencyInput() ¶ public

hasDependencyInput(): bool
返回值
bool

hasUnexpectedOutput() ¶ public

hasUnexpectedOutput(): bool
返回值
bool

identicalTo() ¶ public static

identicalTo(mixed $value): IsIdentical
参数
mixed $value
返回值
IsIdentical

iniSet() ¶ protected

iniSet(string $varName, string $newValue): void

此方法是 ini_set() 函数的包装器,它会在测试运行后自动将修改后的 php.ini 设置重置为其原始值。

参数
字符串 $varName
字符串 $newValue
返回值
空
抛出
异常

isEmpty() ¶ 公共 静态

isEmpty(): IsEmpty
返回值
IsEmpty

isFalse() ¶ 公共 静态

isFalse(): IsFalse
返回值
IsFalse

isFinite() ¶ 公共 静态

isFinite(): IsFinite
返回值
IsFinite

isInfinite() ¶ 公共 静态

isInfinite(): IsInfinite
返回值
IsInfinite

isInstanceOf() ¶ 公共 静态

isInstanceOf(string $className): IsInstanceOf
参数
string $className
返回值
IsInstanceOf
抛出
UnknownClassOrInterfaceException

isJson() ¶ 公共 静态

isJson(): IsJson
返回值
IsJson

isList() ¶ 公共 静态

isList(): IsList
返回值
IsList

isNan() ¶ 公共 静态

isNan(): IsNan
返回值
IsNan

isNull() ¶ 公共 静态

isNull(): IsNull
返回值
IsNull

isReadable() ¶ 公共 静态

isReadable(): IsReadable
返回值
IsReadable

isTrue() ¶ 公共 静态

isTrue(): IsTrue
返回值
IsTrue

isType() ¶ 公共 静态

isType(string $type): IsType
参数
string $type
返回值
IsType
抛出
异常

isWritable() ¶ 公共 静态

isWritable(): IsWritable
返回值
IsWritable

lessThan() ¶ 公共 静态

lessThan(mixed $value): LessThan
参数
mixed $value
返回值
LessThan

lessThanOrEqual() ¶ 公共 静态

lessThanOrEqual(mixed $value): LogicalOr
参数
mixed $value
返回值
LogicalOr

loadPlugins() ¶ 公共

loadPlugins(array $plugins = []): Cake\Http\BaseApplication

将插件加载到模拟应用程序中。

用于测试插件加载/未加载如何与 CakePHP 或应用程序中的其他元素交互。

参数
数组 $plugins 可选

要加载的插件列表。

返回值
Cake\Http\BaseApplication

loadRoutes() ¶ 公共

loadRoutes(array|null $appArgs = null): void

为应用程序加载路由。

如果找不到应用程序类,将引发异常。插件的路由 *不会* 被加载。使用 loadPlugins() 或使用 Cake\TestSuite\IntegrationTestCaseTrait 来更好地模拟所有路由和插件被加载。

参数
数组|null $appArgs 可选

应用程序类的构造函数参数。

返回值
空

logicalAnd() ¶ 公共 静态

logicalAnd(mixed ...$constraints): LogicalAnd
参数
混合 ...$constraints
返回值
LogicalAnd
抛出
异常

logicalNot() ¶ 公共 静态

logicalNot(Constraint $constraint): LogicalNot
参数
Constraint $constraint
返回值
LogicalNot

logicalOr() ¶ 公共 静态

logicalOr(mixed ...$constraints): LogicalOr
参数
混合 ...$constraints
返回值
LogicalOr

logicalXor() ¶ 公共 静态

logicalXor(mixed ...$constraints): LogicalXor
参数
混合 ...$constraints
返回值
LogicalXor

markTestIncomplete() ¶ 公共 静态

markTestIncomplete(string $message = ''): never

将测试标记为不完整。

参数
字符串 $message 可选
返回值
never
抛出
IncompleteTestError

markTestSkipped() ¶ 公共 静态

markTestSkipped(string $message = ''): never

将测试标记为跳过。

参数
字符串 $message 可选
返回值
never
抛出
SkippedWithMessageException

matches() ¶ 公共 静态

matches(string $string): StringMatchesFormatDescription
参数
字符串 $string
返回值
StringMatchesFormatDescription

matchesRegularExpression() ¶ 公共 静态

matchesRegularExpression(string $pattern): RegularExpression
参数
string $pattern
返回值
RegularExpression

name() ¶ 公共

name(): string
返回值
字符串

nameWithDataSet() ¶ 公共

nameWithDataSet(): string
返回值
字符串

never() ¶ 公共 静态

never(): InvokedCountMatcher

返回一个匹配器,当方法从未执行时匹配。

返回值
InvokedCountMatcher

numberOfAssertionsPerformed() ¶ 公共

numberOfAssertionsPerformed(): int
返回值
int

objectEquals() ¶ 公共 静态

objectEquals(object $object, string $method = 'equals'): ObjectEquals
参数
object $object
string $method optional
返回值
ObjectEquals

onConsecutiveCalls() ¶ 公共 静态

onConsecutiveCalls(mixed ...$arguments): ConsecutiveCallsStub
参数
混合 ...$arguments
返回值
ConsecutiveCallsStub
另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5423
https://github.com/sebastianbergmann/phpunit/issues/5425

onNotSuccessfulTest() ¶ 受保护

onNotSuccessfulTest(Throwable $t): never

当测试方法未成功执行时调用此方法。

参数
Throwable $t
返回值
never
抛出
Throwable

once() ¶ 公共 静态

once(): InvokedCountMatcher

返回一个匹配器,当方法被执行恰好一次时匹配。

返回值
InvokedCountMatcher

output() ¶ 公共

output(): string
返回值
字符串

providedData() ¶ 公共

providedData(): array
返回值
数组

provides() ¶ 公共

provides(): array
返回值
数组

registerComparator() ¶ 受保护

registerComparator(Comparator $comparator): void
参数
Comparator $comparator
返回值
空

registerFailureType() ¶ 受保护

registerFailureType(string $classOrInterface): void
参数
字符串 $classOrInterface
返回值
空

registerMockObject() ¶ 公共

registerMockObject(MockObject $mockObject): void
参数
MockObject $mockObject
返回值
空

registerMockObjectsFromTestArgumentsRecursively() ¶ 公共

registerMockObjectsFromTestArgumentsRecursively(): void
返回值
空

removePlugins() ¶ 公共

removePlugins(list<string> $names = []): void

从全局插件集合中删除插件。

在测试用例拆卸方法中很有用。

参数
列表<字符串> $names 可选

您要删除的插件列表。

返回值
空

requires() ¶ 公共

requires(): array
返回值
数组

resetCount() ¶ 公共 静态

resetCount(): void

重置断言计数器。

返回值
空

result() ¶ 公共

result(): mixed
返回值
混合

returnArgument() ¶ 公共 静态

returnArgument(int $argumentIndex): ReturnArgumentStub
参数
整数 $argumentIndex
返回值
ReturnArgumentStub
另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5423

returnCallback() ¶ 公共 静态

returnCallback(callable $callback): ReturnCallbackStub
参数
callable $callback
返回值
ReturnCallbackStub
另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5423

returnSelf() ¶ 公共 静态

returnSelf(): ReturnSelfStub
返回值
ReturnSelfStub
另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5423

returnValue() ¶ 公共 静态

returnValue(mixed $value): ReturnStub
参数
mixed $value
返回值
ReturnStub
另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5423

returnValueMap() ¶ 公共 静态

returnValueMap(array $valueMap): ReturnValueMapStub
参数
数组 $valueMap
返回值
ReturnValueMapStub
另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5423

run() ¶ 公共

run(): void
返回值
空
抛出
PHPUnit\Runner\Exception

PHPUnit\Util\Exception

SebastianBergmann\CodeCoverage\InvalidArgumentException

SebastianBergmann\Template\InvalidArgumentException

CodeCoverageException

异常

MoreThanOneDataSetFromDataProviderException

NoPreviousThrowableException

ProcessIsolationException

StaticAnalysisCacheNotConfiguredException

UnintentionallyCoveredCodeException

runBare() ¶ 公共

runBare(): void
返回值
空
抛出
Throwable

runTest() ¶ 受保护

runTest(): mixed
返回值
混合
抛出
AssertionFailedError

异常

ExpectationFailedException

Throwable

setAppNamespace() ¶ 公共 静态

setAppNamespace(string $appNamespace = 'TestApp'): string|null

设置应用程序命名空间

参数
字符串 $appNamespace 可选

应用程序命名空间,默认为“TestApp”。

返回值
字符串|null

setBackupGlobals() ¶ 公共

setBackupGlobals(bool $backupGlobals): void
参数
布尔值 $backupGlobals
返回值
空

setBackupGlobalsExcludeList() ¶ 公共

setBackupGlobalsExcludeList(array $backupGlobalsExcludeList): void
参数
数组 $backupGlobalsExcludeList
返回值
空

setBackupStaticProperties() ¶ 公共

setBackupStaticProperties(bool $backupStaticProperties): void
参数
布尔值 $backupStaticProperties
返回值
空

setBackupStaticPropertiesExcludeList() ¶ 公共

setBackupStaticPropertiesExcludeList(array $backupStaticPropertiesExcludeList): void
参数
数组 $backupStaticPropertiesExcludeList
返回值
空

setData() ¶ 公共

setData(int|string $dataName, array $data): void
参数
整数|字符串 $dataName
数组 $data
返回值
空
抛出
RuntimeException

setDependencies() ¶ 公共

setDependencies(array $dependencies): void
参数
数组 $dependencies
返回值
空

setDependencyInput() ¶ 公共

setDependencyInput(array $dependencyInput): void
参数
数组 $dependencyInput
返回值
空

setGroups() ¶ 公共

setGroups(array $groups): void
参数
数组 $groups
返回值
空

setInIsolation() ¶ 公共

setInIsolation(bool $inIsolation): void
参数
布尔值 $inIsolation
返回值
空

setLocale() ¶ 受保护

setLocale(mixed ...$arguments): void

此方法是 setlocale() 函数的包装器,它会在测试运行后自动将区域设置重置为其原始值。

参数
混合 ...$arguments
返回值
空
抛出
异常

setName() ¶ 公共

setName(string $name): void
参数
字符串 $name
返回值
空

setPreserveGlobalState() ¶ 公共

setPreserveGlobalState(bool $preserveGlobalState): void
参数
布尔值 $preserveGlobalState
返回值
空

setResult() ¶ 公共

setResult(mixed $result): void
参数
混合 $result
返回值
空

setRunClassInSeparateProcess() ¶ 公共

setRunClassInSeparateProcess(bool $runClassInSeparateProcess): void
参数
布尔值 $runClassInSeparateProcess
返回值
空

setRunTestInSeparateProcess() ¶ 公共

setRunTestInSeparateProcess(bool $runTestInSeparateProcess): void
参数
布尔值 $runTestInSeparateProcess
返回值
空

setTableLocator() ¶ 公共

setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this

设置表格定位器。

参数
Cake\ORM\Locator\LocatorInterface $tableLocator

LocatorInterface 实例。

返回值
$this

setUp() ¶ 受保护

setUp(): void

设置测试用例,备份静态对象值以便可以恢复。特别备份 Configure 的内容和 App 中的路径,如果它们尚未备份。

返回值
空

setUpBeforeClass() ¶ 公共 静态

setUpBeforeClass(): void

此方法在运行此测试类的第一个测试之前被调用。

返回值
空

setupFixtures() ¶ 受保护

setupFixtures(): void

初始化并加载任何使用的夹具。

返回值
空

size() ¶ 公共

size(): TestSize
返回值
TestSize

skipIf() ¶ 公共

skipIf(bool $shouldSkip, string $message = ''): bool

覆盖 SimpleTestCase::skipIf 以提供布尔返回值

参数
布尔值 $shouldSkip

测试是否应该跳过。

字符串 $message 可选

要显示的消息。

返回值
bool

skipUnless() ¶ 受保护

skipUnless(bool $condition, string $message = ''): bool

用于跳过的兼容性函数。

参数
布尔值 $condition

触发跳过的条件

字符串 $message 可选

跳过的消息

返回值
bool

sortId() ¶ public

sortId(): string
返回值
字符串

status() ¶ public

status(): TestStatus
返回值
测试状态

stringContains() ¶ public static

stringContains(string $string, bool $case = true): StringContains
参数
字符串 $string
bool $case 可选
返回值
字符串包含

stringEndsWith() ¶ public static

stringEndsWith(string $suffix): StringEndsWith
参数
string $suffix
返回值
字符串以...结尾
抛出
InvalidArgumentException

stringEqualsStringIgnoringLineEndings() ¶ public static

stringEqualsStringIgnoringLineEndings(string $string): StringEqualsStringIgnoringLineEndings
参数
字符串 $string
返回值
忽略行尾的字符串相等

stringStartsWith() ¶ public static

stringStartsWith(string $prefix): StringStartsWith
参数
string $prefix
返回值
字符串以...开头
抛出
InvalidArgumentException

tearDown() ¶ protected

tearDown(): void

拆卸任何静态对象更改并恢复它们。

返回值
空

tearDownAfterClass() ¶ public static

tearDownAfterClass(): void

此方法在运行此测试类的最后一个测试后被调用。

返回值
空

teardownFixtures() ¶ protected

teardownFixtures(): void

卸载任何使用的夹具。

返回值
空

throwException() ¶ public static

throwException(Throwable $exception): ExceptionStub
参数
Throwable $exception
返回值
异常存根

toString() ¶ public

toString(): string

返回测试用例的字符串表示形式。

返回值
字符串
抛出
异常

transformException() ¶ protected

transformException(Throwable $t): Throwable
参数
Throwable $t
返回值
Throwable

usesDataProvider() ¶ public

usesDataProvider(): bool
返回值
bool

valueObjectForEvents() ¶ public

valueObjectForEvents(): Event\Code\TestMethod
返回值
事件\代码\测试方法
抛出
MoreThanOneDataSetFromDataProviderException

wasPrepared() ¶ public

wasPrepared(): bool
返回值
bool

withConsecutive() ¶ public static

withConsecutive(array $firstCallArguments, array ...$consecutiveCallsArguments): iterable
参数
array $firstCallArguments

调用参数

array ...$consecutiveCallsArguments

其他参数

返回值
可迭代

withErrorReporting() ¶ public

withErrorReporting(int $errorLevel, callable $callable): void

需要使用 error_reporting() 的测试的辅助方法

参数
int $errorLevel

需要使用的 error_reporting() 的值

callable $callable

将接收断言的可调用函数

返回值
空

属性详情

$ElasticLocator ¶ protected

类型
LocatorInterface

$_configure ¶ protected

在测试结束时要恢复的配置值。

类型
数组

$_tableLocator ¶ protected

表定位器实例

类型
Cake\ORM\Locator\LocatorInterface|null

$appPluginsToLoad ¶ protected

在创建应用程序实例后加载的插件 ContainerStubTrait::creatApp()

类型
数组

$defaultTable ¶ protected

此对象的默认表别名。

类型
字符串|null

$fixtureStrategy ¶ protected

类型
Cake\TestSuite\Fixture\FixtureStrategyInterface|null

$fixtures ¶ protected

此测试用例使用的夹具。

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

使用 CakePHP API 文档 生成