类 TestCase
使用 DeleteQueryStrategy 的 Elastic-search TestCase。
属性摘要
-
$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() 的测试的辅助方法
方法详情
_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 夹具
返回值
$thisassertArrayHasKey() ¶ 公共 静态
assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
断言数组具有指定的键。
参数
-
整数|字符串$key -
数组|ArrayAccess$array -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertArrayNotHasKey() ¶ 公共 静态
assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
断言数组没有指定的键。
参数
-
整数|字符串$key -
数组|ArrayAccess$array -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertContains() ¶ 公共 静态
assertContains(mixed $needle, iterable $haystack, string $message = ''): void
断言干草堆包含针。
参数
-
混合$needle -
可迭代$haystack -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertContainsEquals() ¶ public static
assertContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
参数
-
混合$needle -
可迭代$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertContainsOnly() ¶ public static
assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
断言干草堆仅包含给定类型的值。
参数
-
string$type -
可迭代$haystack -
?bool$isNativeType optional -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertContainsOnlyInstancesOf() ¶ public static
assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void
断言干草堆仅包含给定类名的实例。
参数
-
string$className -
可迭代$haystack -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertCount() ¶ public static
assertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
断言数组、可计数或可遍历的元素数量。
参数
-
int$expectedCount -
Countable|iterable$haystack -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionGeneratorNotSupportedExceptionassertDirectoryDoesNotExist() ¶ public static
assertDirectoryDoesNotExist(string $directory, string $message = ''): void
断言目录不存在。
参数
-
string$directory -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertDirectoryExists() ¶ public static
assertDirectoryExists(string $directory, string $message = ''): void
断言目录存在。
参数
-
string$directory -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertDirectoryIsNotReadable() ¶ public static
assertDirectoryIsNotReadable(string $directory, string $message = ''): void
断言目录存在且不可读。
参数
-
string$directory -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertDirectoryIsNotWritable() ¶ public static
assertDirectoryIsNotWritable(string $directory, string $message = ''): void
断言目录存在且不可写。
参数
-
string$directory -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertDirectoryIsReadable() ¶ public static
assertDirectoryIsReadable(string $directory, string $message = ''): void
断言目录存在且可读。
参数
-
string$directory -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertDirectoryIsWritable() ¶ public static
assertDirectoryIsWritable(string $directory, string $message = ''): void
断言目录存在且可写。
参数
-
string$directory -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertDoesNotMatchRegularExpression() ¶ public static
assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void
断言字符串与给定的正则表达式不匹配。
参数
-
string$pattern -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertEmpty() ¶ public static
assertEmpty(mixed $actual, string $message = ''): void
断言变量为空。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionGeneratorNotSupportedExceptionassertEquals() ¶ public static
assertEquals(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量相等。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertEqualsCanonicalizing() ¶ public static
assertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量相等(规范化)。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertEqualsIgnoringCase() ¶ public static
assertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量相等(不区分大小写)。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertEqualsSql() ¶ 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 可选
返回值
空抛出
ExpectationFailedExceptionassertEventFired() ¶ 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 可选
返回值
空抛出
ExpectationFailedExceptionassertFileDoesNotExist() ¶ public static
assertFileDoesNotExist(string $filename, string $message = ''): void
断言文件不存在。
参数
-
string$filename -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileEquals() ¶ public static
assertFileEquals(string $expected, string $actual, string $message = ''): void
断言一个文件的内容等于另一个文件的内容。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileEqualsCanonicalizing() ¶ public static
assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
断言一个文件的内容等于另一个文件的内容(规范化)。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileEqualsIgnoringCase() ¶ public static
assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
断言一个文件的内容等于另一个文件的内容(不区分大小写)。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileExists() ¶ public static
assertFileExists(string $filename, string $message = ''): void
断言文件存在。
参数
-
string$filename -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileIsNotReadable() ¶ public static
assertFileIsNotReadable(string $file, string $message = ''): void
断言文件存在且不可读。
参数
-
string$file -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileIsNotWritable() ¶ public static
assertFileIsNotWritable(string $file, string $message = ''): void
断言文件存在且不可写。
参数
-
string$file -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileIsReadable() ¶ public static
assertFileIsReadable(string $file, string $message = ''): void
断言文件存在且可读。
参数
-
string$file -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileIsWritable() ¶ public static
assertFileIsWritable(string $file, string $message = ''): void
断言文件存在且可写。
参数
-
string$file -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileMatchesFormat() ¶ public static
assertFileMatchesFormat(string $format, string $actualFile, string $message = ''): void
断言字符串与给定的格式字符串匹配。
参数
-
string$format -
string$actualFile -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileMatchesFormatFile() ¶ public static
assertFileMatchesFormatFile(string $formatFile, string $actualFile, string $message = ''): void
断言字符串与给定的格式字符串匹配。
参数
-
string$formatFile -
string$actualFile -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileNotEquals() ¶ public static
assertFileNotEquals(string $expected, string $actual, string $message = ''): void
断言一个文件的内容不等于另一个文件的内容。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileNotEqualsCanonicalizing() ¶ public static
assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
断言一个文件的内容不等于另一个文件的内容(规范化)。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFileNotEqualsIgnoringCase() ¶ public static
assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
断言一个文件的内容不等于另一个文件的内容(不区分大小写)。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertFinite() ¶ public static
assertFinite(mixed $actual, string $message = ''): void
断言变量为有限。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertGreaterThan() ¶ public static
assertGreaterThan(mixed $expected, mixed $actual, string $message = ''): void
断言一个值大于另一个值。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertGreaterThanOrEqual() ¶ public static
assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
断言一个值大于或等于另一个值。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertHtml() ¶ 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 可选 是否应该使用更详细的输出。
返回值
boolassertInfinite() ¶ public static
assertInfinite(mixed $actual, string $message = ''): void
断言变量为无穷大。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertInstanceOf() ¶ public static
assertInstanceOf(string $expected, mixed $actual, string $message = ''): void
断言变量为给定类型。
参数
-
string$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionUnknownClassOrInterfaceExceptionassertIsArray() ¶ public static
assertIsArray(mixed $actual, string $message = ''): void
断言变量为数组类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsBool() ¶ public static
assertIsBool(mixed $actual, string $message = ''): void
断言变量为布尔类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsCallable() ¶ public static
assertIsCallable(mixed $actual, string $message = ''): void
断言变量为可调用类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsClosedResource() ¶ public static
assertIsClosedResource(mixed $actual, string $message = ''): void
断言变量为资源类型并且已关闭。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsFloat() ¶ public static
assertIsFloat(mixed $actual, string $message = ''): void
断言变量为浮点数类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsInt() ¶ public static
assertIsInt(mixed $actual, string $message = ''): void
断言变量为整型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsIterable() ¶ public static
assertIsIterable(mixed $actual, string $message = ''): void
断言变量为可迭代类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsList() ¶ public static
assertIsList(mixed $array, string $message = ''): void
参数
-
mixed$array -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertIsNotArray() ¶ public static
assertIsNotArray(mixed $actual, string $message = ''): void
断言变量不是数组类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotBool() ¶ public static
assertIsNotBool(mixed $actual, string $message = ''): void
断言变量不是布尔类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotCallable() ¶ public static
assertIsNotCallable(mixed $actual, string $message = ''): void
断言变量不是可调用类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotClosedResource() ¶ public static
assertIsNotClosedResource(mixed $actual, string $message = ''): void
断言变量不是资源类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotFloat() ¶ public static
assertIsNotFloat(mixed $actual, string $message = ''): void
断言变量不是浮点数类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotInt() ¶ public static
assertIsNotInt(mixed $actual, string $message = ''): void
断言变量不是整型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotIterable() ¶ public static
assertIsNotIterable(mixed $actual, string $message = ''): void
断言变量不是可迭代类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotNumeric() ¶ public static
assertIsNotNumeric(mixed $actual, string $message = ''): void
断言变量不是数值类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotObject() ¶ public static
assertIsNotObject(mixed $actual, string $message = ''): void
断言变量不是对象类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotReadable() ¶ public static
assertIsNotReadable(string $filename, string $message = ''): void
断言文件/目录存在且不可读。
参数
-
string$filename -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertIsNotResource() ¶ public static
assertIsNotResource(mixed $actual, string $message = ''): void
断言变量不是资源类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotScalar() ¶ public static
assertIsNotScalar(mixed $actual, string $message = ''): void
断言变量不是标量类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotString() ¶ public static
assertIsNotString(mixed $actual, string $message = ''): void
断言变量不是字符串类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsNotWritable() ¶ public static
assertIsNotWritable(string $filename, string $message = ''): void
断言文件/目录存在且不可写。
参数
-
string$filename -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertIsNumeric() ¶ public static
assertIsNumeric(mixed $actual, string $message = ''): void
断言变量为数值类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsObject() ¶ public static
assertIsObject(mixed $actual, string $message = ''): void
断言变量为对象类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsReadable() ¶ public static
assertIsReadable(string $filename, string $message = ''): void
断言文件/目录可读。
参数
-
string$filename -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertIsResource() ¶ public static
assertIsResource(mixed $actual, string $message = ''): void
断言变量为资源类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsScalar() ¶ public static
assertIsScalar(mixed $actual, string $message = ''): void
断言变量为标量类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsString() ¶ public static
assertIsString(mixed $actual, string $message = ''): void
断言变量为字符串类型。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertIsWritable() ¶ public static
assertIsWritable(string $filename, string $message = ''): void
断言文件/目录存在且可写。
参数
-
string$filename -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJson() ¶ public static
assertJson(string $actual, string $message = ''): void
断言字符串为有效的 JSON 字符串。
参数
-
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJsonFileEqualsJsonFile() ¶ public static
assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
断言两个 JSON 文件相等。
参数
-
string$expectedFile -
string$actualFile -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJsonFileNotEqualsJsonFile() ¶ public static
assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
断言两个 JSON 文件不相等。
参数
-
string$expectedFile -
string$actualFile -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJsonStringEqualsJsonFile() ¶ public static
assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
断言生成的 JSON 编码对象和给定文件的内容相等。
参数
-
string$expectedFile -
string$actualJson -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJsonStringEqualsJsonString() ¶ public static
assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
断言两个给定的 JSON 编码对象或数组相等。
参数
-
string$expectedJson -
string$actualJson -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJsonStringNotEqualsJsonFile() ¶ public static
assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
断言生成的 JSON 编码对象和给定文件的内容不相等。
参数
-
string$expectedFile -
string$actualJson -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertJsonStringNotEqualsJsonString() ¶ public static
assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
断言两个给定的 JSON 编码对象或数组不相等。
参数
-
string$expectedJson -
string$actualJson -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertLessThan() ¶ public static
assertLessThan(mixed $expected, mixed $actual, string $message = ''): void
断言一个值小于另一个值。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertLessThanOrEqual() ¶ public static
assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
断言一个值小于或等于另一个值。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertMatchesRegularExpression() ¶ public static
assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
断言字符串与给定的正则表达式匹配。
参数
-
string$pattern -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNan() ¶ public static
assertNan(mixed $actual, string $message = ''): void
断言变量为 NaN。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotContains() ¶ public static
assertNotContains(mixed $needle, iterable $haystack, string $message = ''): void
断言干草堆中不包含针。
参数
-
混合$needle -
可迭代$haystack -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertNotContainsEquals() ¶ public static
assertNotContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
参数
-
混合$needle -
可迭代$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotContainsOnly() ¶ public static
assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
断言干草堆中不只包含给定类型的值。
参数
-
string$type -
可迭代$haystack -
?bool$isNativeType optional -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertNotCount() ¶ public static
assertNotCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
断言数组、可计数或可遍历的元素数量。
参数
-
int$expectedCount -
Countable|iterable$haystack -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionGeneratorNotSupportedExceptionassertNotEmpty() ¶ public static
assertNotEmpty(mixed $actual, string $message = ''): void
断言变量不为空。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionGeneratorNotSupportedExceptionassertNotEquals() ¶ public static
assertNotEquals(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量不相等。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotEqualsCanonicalizing() ¶ public static
assertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量不相等(规范化)。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotEqualsIgnoringCase() ¶ public static
assertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量不相等(忽略大小写)。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotEqualsWithDelta() ¶ public static
assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
断言两个变量不相等(带 delta)。
参数
-
mixed$expected -
mixed$actual -
float$delta -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotFalse() ¶ public static
assertNotFalse(mixed $condition, string $message = ''): void
断言条件不为假。
参数
-
mixed$condition -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotInstanceOf() ¶ public static
assertNotInstanceOf(string $expected, mixed $actual, string $message = ''): void
断言变量不是给定类型。
参数
-
string$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionassertNotNull() ¶ public static
assertNotNull(mixed $actual, string $message = ''): void
断言变量不为空。
参数
-
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotSame() ¶ public static
assertNotSame(mixed $expected, mixed $actual, string $message = ''): void
断言两个变量类型和值不同。在对象上使用时,它断言两个变量不引用同一个对象。
参数
-
mixed$expected -
mixed$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotSameSize() ¶ public static
assertNotSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
断言两个数组(或 Countable 或 Traversable 对象)的大小不同。
参数
-
Countable|iterable$expected -
Countable|iterable$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionGeneratorNotSupportedExceptionassertNotTrue() ¶ public static
assertNotTrue(mixed $condition, string $message = ''): void
断言条件不为真。
参数
-
mixed$condition -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertNotWithinRange() ¶ 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 可选
返回值
空抛出
ExpectationFailedExceptionassertObjectEquals() ¶ public static
assertObjectEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void
参数
-
object$expected -
object$actual -
string$method optional -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertObjectHasProperty() ¶ public static
assertObjectHasProperty(string $propertyName, object $object, string $message = ''): void
断言对象具有指定的属性。
参数
-
string$propertyName -
object$object -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertObjectNotHasProperty() ¶ public static
assertObjectNotHasProperty(string $propertyName, object $object, string $message = ''): void
断言对象没有指定的属性。
参数
-
string$propertyName -
object$object -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertPathEquals() ¶ 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 可选
返回值
空抛出
ExpectationFailedExceptionassertSameSize() ¶ public static
assertSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
断言两个数组(或 Countable 或 Traversable 对象)的大小相同。
参数
-
Countable|iterable$expected -
Countable|iterable$actual -
字符串$message 可选
返回值
空抛出
异常ExpectationFailedExceptionGeneratorNotSupportedExceptionassertStringContainsString() ¶ public static
assertStringContainsString(string $needle, string $haystack, string $message = ''): void
参数
-
string$needle -
string$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringContainsStringIgnoringCase() ¶ public static
assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
参数
-
string$needle -
string$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringContainsStringIgnoringLineEndings() ¶ public static
assertStringContainsStringIgnoringLineEndings(string $needle, string $haystack, string $message = ''): void
参数
-
string$needle -
string$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringEndsNotWith() ¶ public static
assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void
断言字符串不以给定后缀结尾。
参数
-
string$suffix -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionInvalidArgumentExceptionassertStringEndsWith() ¶ public static
assertStringEndsWith(string $suffix, string $string, string $message = ''): void
断言字符串以给定后缀结尾。
参数
-
string$suffix -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionInvalidArgumentExceptionassertStringEqualsFile() ¶ public static
assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
断言字符串的内容与文件的内容相等。
参数
-
string$expectedFile -
string$actualString -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringEqualsFileCanonicalizing() ¶ public static
assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
断言字符串的内容与文件的内容相等(规范化)。
参数
-
string$expectedFile -
string$actualString -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringEqualsFileIgnoringCase() ¶ public static
assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
断言字符串的内容与文件的内容相等(忽略大小写)。
参数
-
string$expectedFile -
string$actualString -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringEqualsStringIgnoringLineEndings() ¶ public static
assertStringEqualsStringIgnoringLineEndings(string $expected, string $actual, string $message = ''): void
断言两个字符串除了行尾以外完全相同。
参数
-
string$expected -
string$actual -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringMatchesFormat() ¶ public static
assertStringMatchesFormat(string $format, string $string, string $message = ''): void
断言字符串与给定的格式字符串匹配。
参数
-
string$format -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringMatchesFormatFile() ¶ public static
assertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
断言一个字符串与给定的格式文件匹配。
参数
-
string$formatFile -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotContainsString() ¶ public static
assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
参数
-
string$needle -
string$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotContainsStringIgnoringCase() ¶ public static
assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
参数
-
string$needle -
string$haystack -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotEqualsFile() ¶ public static
assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
断言一个字符串的内容与文件的内容不一致。
参数
-
string$expectedFile -
string$actualString -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotEqualsFileCanonicalizing() ¶ public static
assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
断言一个字符串的内容与文件的内容不一致(规范化)。
参数
-
string$expectedFile -
string$actualString -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotEqualsFileIgnoringCase() ¶ public static
assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
断言一个字符串的内容与文件的内容不一致(忽略大小写)。
参数
-
string$expectedFile -
string$actualString -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotMatchesFormat() ¶ public static
assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
断言一个字符串与给定的格式字符串不匹配。
参数
-
string$format -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringNotMatchesFormatFile() ¶ public static
assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
断言一个字符串与给定的格式字符串不匹配。
参数
-
string$formatFile -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertStringStartsNotWith() ¶ public static
assertStringStartsNotWith(string $prefix, string $string, string $message = ''): void
断言一个字符串不以给定的前缀开头。
参数
-
string$prefix -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionInvalidArgumentExceptionassertStringStartsWith() ¶ public static
assertStringStartsWith(string $prefix, string $string, string $message = ''): void
断言一个字符串以给定的前缀开头。
参数
-
string$prefix -
字符串$string -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionInvalidArgumentExceptionassertTextContains() ¶ 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 可选
返回值
空抛出
ExpectationFailedExceptionassertTrue() ¶ public static
assertTrue(mixed $condition, string $message = ''): void
断言一个条件为真。
参数
-
mixed$condition -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionassertWithinRange() ¶ 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 可选
返回值
空抛出
异常ExpectationFailedExceptionXmlExceptionassertXmlFileNotEqualsXmlFile() ¶ public static
assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
断言两个 XML 文件不相等。
参数
-
string$expectedFile -
string$actualFile -
字符串$message 可选
返回值
空抛出
PHPUnit\Util\ExceptionExpectationFailedExceptionassertXmlStringEqualsXmlFile() ¶ public static
assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
断言两个 XML 文档相等。
参数
-
string$expectedFile -
string$actualXml -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionXmlExceptionassertXmlStringEqualsXmlString() ¶ public static
assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
断言两个 XML 文档相等。
参数
-
string$expectedXml -
string$actualXml -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionXmlExceptionassertXmlStringNotEqualsXmlFile() ¶ public static
assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
断言两个 XML 文档不相等。
参数
-
string$expectedFile -
string$actualXml -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionXmlExceptionassertXmlStringNotEqualsXmlString() ¶ public static
assertXmlStringNotEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
断言两个 XML 文档不相等。
参数
-
string$expectedXml -
string$actualXml -
字符串$message 可选
返回值
空抛出
ExpectationFailedExceptionXmlExceptionatLeast() ¶ public static
atLeast(int $requiredInvocations): InvokedAtLeastCountMatcher
返回一个匹配器,当方法执行至少 N 次时匹配。
参数
-
int$requiredInvocations
返回值
InvokedAtLeastCountMatcheratLeastOnce() ¶ public static
atLeastOnce(): InvokedAtLeastOnceMatcher
返回一个匹配器,当方法执行至少一次时匹配。
返回值
InvokedAtLeastOnceMatcheratMost() ¶ public static
atMost(int $allowedInvocations): InvokedAtMostCountMatcher
返回一个匹配器,当方法执行最多 N 次时匹配。
参数
-
int$allowedInvocations
返回值
InvokedAtMostCountMatchercallback() ¶ public static
callback(callable $callback): Callback
参数
-
callable$callback
返回值
CallbackcaptureError() ¶ public
captureError(int $errorLevel, Closure $callable): Cake\Error\PhpError
捕获 $callable 中的错误,以便您可以对错误进行断言。
如果未捕获错误,断言将失败。
参数
-
int$errorLevel 要使用的 error_reporting() 的值。
-
Closure$callable 用于捕获错误的闭包。
返回值
Cake\Error\PhpErrorcontainsEqual() ¶ public static
containsEqual(mixed $value): TraversableContainsEqual
参数
-
mixed$value
返回值
TraversableContainsEqualcontainsIdentical() ¶ public static
containsIdentical(mixed $value): TraversableContainsIdentical
参数
-
mixed$value
返回值
TraversableContainsIdenticalcontainsOnly() ¶ public static
containsOnly(string $type): TraversableContainsOnly
参数
-
string$type
返回值
TraversableContainsOnly抛出
异常containsOnlyInstancesOf() ¶ public static
containsOnlyInstancesOf(string $className): TraversableContainsOnly
参数
-
string$className
返回值
TraversableContainsOnly抛出
异常createConfiguredMock() ¶ protected
createConfiguredMock(string $originalClassName, array $configuration): MockObject
为指定的接口或类创建(并配置)一个模拟对象。
参数
-
string$originalClassName -
array$configuration
返回值
MockObject抛出
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateConfiguredStub() ¶ protected static
createConfiguredStub(string $originalClassName, array $configuration): Stub
为指定的接口或类创建(并配置)一个测试存根。
参数
-
string$originalClassName -
array$configuration
返回值
Stub抛出
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateMock() ¶ protected
createMock(string $originalClassName): MockObject
为指定的接口或类创建模拟对象。
参数
-
string$originalClassName
返回值
MockObject抛出
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateMockForIntersectionOfInterfaces() ¶ protected
createMockForIntersectionOfInterfaces(array $interfaces): MockObject
参数
-
array$interfaces
返回值
MockObject抛出
MockObjectExceptioncreatePartialMock() ¶ protected
createPartialMock(string $originalClassName, array $methods): MockObject
为指定的接口或类创建部分模拟对象。
参数
-
string$originalClassName -
array$methods
返回值
MockObject抛出
InvalidArgumentExceptionMockObjectExceptioncreateStub() ¶ protected static
createStub(string $originalClassName): Stub
为指定的接口或类创建测试存根。
参数
-
string$originalClassName
返回值
Stub抛出
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateStubForIntersectionOfInterfaces() ¶ protected static
createStubForIntersectionOfInterfaces(array $interfaces): Stub
参数
-
array$interfaces
返回值
Stub抛出
MockObjectExceptioncreateTestProxy() ¶ protected
createTestProxy(string $originalClassName, array $constructorArguments = []): MockObject
为指定的类创建测试代理。
参数
-
string$originalClassName -
array$constructorArguments optional
返回值
MockObject抛出
InvalidArgumentExceptionMockObjectExceptiondeprecated() ¶ public
deprecated(Closure $callable): void
检查弃用方法的辅助方法
参数
-
Closure$callable 将接收断言的可调用函数
返回值
空equalToCanonicalizing() ¶ public static
equalToCanonicalizing(mixed $value): IsEqualCanonicalizing
参数
-
mixed$value
返回值
IsEqualCanonicalizingequalToIgnoringCase() ¶ public static
equalToIgnoringCase(mixed $value): IsEqualIgnoringCase
参数
-
mixed$value
返回值
IsEqualIgnoringCaseequalToWithDelta() ¶ public static
equalToWithDelta(mixed $value, float $delta): IsEqualWithDelta
参数
-
mixed$value -
float$delta
返回值
IsEqualWithDeltaexactly() ¶ public static
exactly(int $count): InvokedCountMatcher
返回一个匹配器,当方法执行恰好 $count 次时匹配。
参数
-
整数$count
返回值
InvokedCountMatcherexpectDeprecationMessageMatches() ¶ 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 应该触发警告的可调用函数
返回值
空抛出
异常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
返回值
空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 应该触发警告的可调用函数
返回值
空抛出
异常fail() ¶ public static
fail(string $message = ''): never
使用给定的消息使测试失败。
参数
-
字符串$message 可选
返回值
never抛出
AssertionFailedErrorfetchTable() ¶ 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`。
另请参阅
getFixtureStrategy() ¶ public
getFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface
返回这些测试使用的夹具策略。
返回值
Cake\TestSuite\Fixture\FixtureStrategyInterfacegetMockBuilder() ¶ public
getMockBuilder(string $className): MockBuilder
返回一个构建器对象,使用流畅的接口创建模拟对象。
参数
-
string$className
返回值
MockBuildergetMockForAbstractClass() ¶ 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抛出
InvalidArgumentExceptionMockObjectExceptiongetMockForModel() ¶ 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\MissingTableClassExceptiongetMockForTrait() ¶ 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抛出
InvalidArgumentExceptionMockObjectExceptiongetMockFromWsdl() ¶ 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抛出
MockObjectExceptiongetObjectForTrait() ¶ 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抛出
MockObjectExceptiongetTableLocator() ¶ public
getTableLocator(): Cake\ORM\Locator\LocatorInterface
获取表格定位器。
返回值
Cake\ORM\Locator\LocatorInterfacegreaterThan() ¶ public static
greaterThan(mixed $value): GreaterThan
参数
-
mixed$value
返回值
GreaterThangreaterThanOrEqual() ¶ public static
greaterThanOrEqual(mixed $value): LogicalOr
参数
-
mixed$value
返回值
LogicalOridenticalTo() ¶ public static
identicalTo(mixed $value): IsIdentical
参数
-
mixed$value
返回值
IsIdenticaliniSet() ¶ protected
iniSet(string $varName, string $newValue): void
此方法是 ini_set() 函数的包装器,它会在测试运行后自动将修改后的 php.ini 设置重置为其原始值。
参数
-
字符串$varName -
字符串$newValue
返回值
空抛出
异常isInstanceOf() ¶ 公共 静态
isInstanceOf(string $className): IsInstanceOf
参数
-
string$className
返回值
IsInstanceOf抛出
UnknownClassOrInterfaceExceptionloadPlugins() ¶ 公共
loadPlugins(array $plugins = []): Cake\Http\BaseApplication
将插件加载到模拟应用程序中。
用于测试插件加载/未加载如何与 CakePHP 或应用程序中的其他元素交互。
参数
-
数组$plugins 可选 要加载的插件列表。
返回值
Cake\Http\BaseApplicationloadRoutes() ¶ 公共
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
返回值
LogicalNotlogicalXor() ¶ 公共 静态
logicalXor(mixed ...$constraints): LogicalXor
参数
-
混合...$constraints
返回值
LogicalXormarkTestIncomplete() ¶ 公共 静态
markTestIncomplete(string $message = ''): never
将测试标记为不完整。
参数
-
字符串$message 可选
返回值
never抛出
IncompleteTestErrormarkTestSkipped() ¶ 公共 静态
markTestSkipped(string $message = ''): never
将测试标记为跳过。
参数
-
字符串$message 可选
返回值
never抛出
SkippedWithMessageExceptionmatches() ¶ 公共 静态
matches(string $string): StringMatchesFormatDescription
参数
-
字符串$string
返回值
StringMatchesFormatDescriptionmatchesRegularExpression() ¶ 公共 静态
matchesRegularExpression(string $pattern): RegularExpression
参数
-
string$pattern
返回值
RegularExpressionobjectEquals() ¶ 公共 静态
objectEquals(object $object, string $method = 'equals'): ObjectEquals
参数
-
object$object -
string$method optional
返回值
ObjectEqualsonConsecutiveCalls() ¶ 公共 静态
onConsecutiveCalls(mixed ...$arguments): ConsecutiveCallsStub
参数
-
混合...$arguments
返回值
ConsecutiveCallsStub另请参阅
https://github.com/sebastianbergmann/phpunit/issues/5425
onNotSuccessfulTest() ¶ 受保护
onNotSuccessfulTest(Throwable $t): never
当测试方法未成功执行时调用此方法。
参数
-
Throwable$t
返回值
never抛出
ThrowableregisterComparator() ¶ 受保护
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 可选 您要删除的插件列表。
返回值
空returnArgument() ¶ 公共 静态
returnArgument(int $argumentIndex): ReturnArgumentStub
参数
-
整数$argumentIndex
返回值
ReturnArgumentStub另请参阅
returnCallback() ¶ 公共 静态
returnCallback(callable $callback): ReturnCallbackStub
参数
-
callable$callback
返回值
ReturnCallbackStub另请参阅
returnSelf() ¶ 公共 静态
returnSelf(): ReturnSelfStub
返回值
ReturnSelfStub另请参阅
returnValue() ¶ 公共 静态
returnValue(mixed $value): ReturnStub
参数
-
mixed$value
返回值
ReturnStub另请参阅
returnValueMap() ¶ 公共 静态
returnValueMap(array $valueMap): ReturnValueMapStub
参数
-
数组$valueMap
返回值
ReturnValueMapStub另请参阅
run() ¶ 公共
run(): void
返回值
空抛出
PHPUnit\Runner\ExceptionPHPUnit\Util\ExceptionSebastianBergmann\CodeCoverage\InvalidArgumentExceptionSebastianBergmann\Template\InvalidArgumentExceptionCodeCoverageException异常MoreThanOneDataSetFromDataProviderExceptionNoPreviousThrowableExceptionProcessIsolationExceptionStaticAnalysisCacheNotConfiguredExceptionUnintentionallyCoveredCodeExceptionrunTest() ¶ 受保护
runTest(): mixed
返回值
混合抛出
AssertionFailedError异常ExpectationFailedExceptionThrowablesetAppNamespace() ¶ 公共 静态
setAppNamespace(string $appNamespace = 'TestApp'): string|null
设置应用程序命名空间
参数
-
字符串$appNamespace 可选 应用程序命名空间,默认为“TestApp”。
返回值
字符串|nullsetBackupGlobalsExcludeList() ¶ 公共
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
返回值
空抛出
RuntimeExceptionsetDependencyInput() ¶ 公共
setDependencyInput(array $dependencyInput): void
参数
-
数组$dependencyInput
返回值
空setLocale() ¶ 受保护
setLocale(mixed ...$arguments): void
此方法是 setlocale() 函数的包装器,它会在测试运行后自动将区域设置重置为其原始值。
参数
-
混合...$arguments
返回值
空抛出
异常setPreserveGlobalState() ¶ 公共
setPreserveGlobalState(bool $preserveGlobalState): void
参数
-
布尔值$preserveGlobalState
返回值
空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 实例。
返回值
$thisskipIf() ¶ 公共
skipIf(bool $shouldSkip, string $message = ''): bool
覆盖 SimpleTestCase::skipIf 以提供布尔返回值
参数
-
布尔值$shouldSkip 测试是否应该跳过。
-
字符串$message 可选 要显示的消息。
返回值
boolskipUnless() ¶ 受保护
skipUnless(bool $condition, string $message = ''): bool
用于跳过的兼容性函数。
参数
-
布尔值$condition 触发跳过的条件
-
字符串$message 可选 跳过的消息
返回值
boolstringContains() ¶ public static
stringContains(string $string, bool $case = true): StringContains
参数
-
字符串$string -
bool$case 可选
返回值
字符串包含stringEndsWith() ¶ public static
stringEndsWith(string $suffix): StringEndsWith
参数
-
string$suffix
返回值
字符串以...结尾抛出
InvalidArgumentExceptionstringEqualsStringIgnoringLineEndings() ¶ public static
stringEqualsStringIgnoringLineEndings(string $string): StringEqualsStringIgnoringLineEndings
参数
-
字符串$string
返回值
忽略行尾的字符串相等stringStartsWith() ¶ public static
stringStartsWith(string $prefix): StringStartsWith
参数
-
string$prefix
返回值
字符串以...开头抛出
InvalidArgumentExceptionthrowException() ¶ public static
throwException(Throwable $exception): ExceptionStub
参数
-
Throwable$exception
返回值
异常存根transformException() ¶ protected
transformException(Throwable $t): Throwable
参数
-
Throwable$t
返回值
ThrowablevalueObjectForEvents() ¶ public
valueObjectForEvents(): Event\Code\TestMethod
返回值
事件\代码\测试方法抛出
MoreThanOneDataSetFromDataProviderExceptionwithConsecutive() ¶ 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 将接收断言的可调用函数
返回值
空