CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 周边产品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

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

命名空间

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

特性 ConsoleIntegrationTestTrait

一组简化测试命令和 shell 类的方法。

使您能够在完整应用程序上下文中调用命令/shell。

命名空间: Cake\Console\TestSuite

属性摘要

  • $_appArgs protected
    array|null

    自定义的应用程序构造函数参数。

  • $_appClass protected
    string|null

    自定义的应用程序类名。

  • $_err protected
    Cake\Console\TestSuite\StubConsoleOutput|null

    控制台错误输出存根

  • $_exitCode protected
    int|null

    最后一个退出代码

  • $_in protected
    Cake\Console\TestSuite\StubConsoleInput|null

    控制台输入模拟

  • $_out protected
    Cake\Console\TestSuite\StubConsoleOutput|null

    控制台输出存根

方法摘要

  • assertErrorContains() public

    断言 stderr 包含预期输出

  • assertErrorEmpty() public

    断言 stderr 为空

  • assertErrorRegExp() public

    断言 stderr 包含预期正则表达式

  • assertExitCode() public

    断言 shell 以预期代码退出

  • assertExitError() public

    断言 shell 以 Command::CODE_ERROR 退出

  • assertExitSuccess() public

    断言 shell 以 Command::CODE_SUCCESS 退出

  • assertOutputContains() public

    断言 stdout 包含预期输出

  • assertOutputContainsRow() protected

    检查输出中是否存在一行单元格。

  • assertOutputEmpty() public

    断言 stdout 为空

  • assertOutputNotContains() public

    断言 stdout 不包含预期输出

  • assertOutputRegExp() public

    断言 stdout 包含预期正则表达式

  • cleanupConsoleTrait() public

    清理状态以准备下一个测试

  • cleanupContainer() public

    清除任何已定义的模拟并清理应用程序类配置。

  • commandStringToArgs() protected

    从命令字符串创建 $argv 数组

  • configApplication() public

    配置在集成测试中使用的应用程序类。

  • createApp() protected

    创建应用程序实例。

  • exec() public

    运行 CLI 集成测试

  • makeRunner() protected

    构建适当的命令调度器

  • mockService() public

    向容器添加模拟服务。

  • modifyContainer() public

    用包含模拟的容器包装应用程序的容器。

  • removeMockService() public

    从容器中删除模拟服务。

方法详情

assertErrorContains() ¶ public

assertErrorContains(string $expected, string $message = ''): void

断言 stderr 包含预期输出

参数
string $expected

预期输出

string $message optional

失败消息

返回值
void

assertErrorEmpty() ¶ public

assertErrorEmpty(string $message = ''): void

断言 stderr 为空

参数
string $message optional

断言失败时输出的消息。

返回值
void

assertErrorRegExp() ¶ public

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

断言 stderr 包含预期正则表达式

参数
string $pattern

预期模式

string $message optional

失败消息

返回值
void

assertExitCode() ¶ public

assertExitCode(int $expected, string $message = ''): void

断言 shell 以预期代码退出

参数
int $expected

预期退出代码

string $message optional

失败消息

返回值
void

assertExitError() ¶ public

assertExitError(string $message = ''): void

断言 shell 以 Command::CODE_ERROR 退出

参数
string $message optional

失败消息

返回值
void

assertExitSuccess() ¶ public

assertExitSuccess(string $message = ''): void

断言 shell 以 Command::CODE_SUCCESS 退出

参数
string $message optional

失败消息

返回值
void

assertOutputContains() ¶ public

assertOutputContains(string $expected, string $message = ''): void

断言 stdout 包含预期输出

参数
string $expected

预期输出

string $message optional

失败消息

返回值
void

assertOutputContainsRow() ¶ protected

assertOutputContainsRow(array $row, string $message = ''): void

检查输出中是否存在一行单元格。

参数
array $row

确保在输出中存在的单元格行。

string $message optional

失败消息。

返回值
void

assertOutputEmpty() ¶ public

assertOutputEmpty(string $message = ''): void

断言 stdout 为空

参数
string $message optional

断言失败时输出的消息。

返回值
void

assertOutputNotContains() ¶ public

assertOutputNotContains(string $expected, string $message = ''): void

断言 stdout 不包含预期输出

参数
string $expected

预期输出

string $message optional

失败消息

返回值
void

assertOutputRegExp() ¶ public

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

断言 stdout 包含预期正则表达式

参数
string $pattern

预期模式

string $message optional

失败消息

返回值
void

cleanupConsoleTrait() ¶ public

cleanupConsoleTrait(): void

清理状态以准备下一个测试

返回值
void

cleanupContainer() ¶ public

cleanupContainer(): void

清除任何已定义的模拟并清理应用程序类配置。

返回值
void

commandStringToArgs() ¶ protected

commandStringToArgs(string $command): list<string>

从命令字符串创建 $argv 数组

参数
string $command

命令字符串

返回值
list<string>

configApplication() ¶ public

configApplication(string $class, array|null $constructorArgs): void

配置在集成测试中使用的应用程序类。

参数
string $class

应用程序类名。

array|null $constructorArgs

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

返回值
void

createApp() ¶ protected

createApp(): Cake\Core\HttpApplicationInterfaceCake\Core\ConsoleApplicationInterface

创建应用程序实例。

使用 configApplication() 中设置的配置。

返回值
Cake\Core\HttpApplicationInterfaceCake\Core\ConsoleApplicationInterface

exec() ¶ public

exec(string $command, array $input = []): void

运行 CLI 集成测试

参数
string $command

要运行的命令

array $input optional

传递给交互式 shell 的输入值

返回值
void
抛出异常
Cake\Console\TestSuite\MissingConsoleInputException

InvalidArgumentException

makeRunner() ¶ protected

makeRunner(): Cake\Console\CommandRunner

构建适当的命令调度器

返回值
Cake\Console\CommandRunner

mockService() ¶ public

mockService(string $class, Closure $factory): $this

向容器添加模拟服务。

当容器创建时,提供的类名将映射到工厂函数。工厂函数将用于创建模拟服务。

参数
string $class

要定义的类或接口。

Closure $factory

模拟服务的工厂函数。

返回值
$this

modifyContainer() ¶ public

modifyContainer(Cake\Event\EventInterface $event, Cake\Core\ContainerInterface $container): void

用包含模拟的容器包装应用程序的容器。

如果定义了任何模拟服务,应用程序的容器将被替换为包含模拟的容器。原始容器将被设置为模拟容器的委托。

参数
Cake\Event\EventInterface $event

事件

Cake\Core\ContainerInterface $container

要包装的容器。

返回值
void

removeMockService() ¶ public

removeMockService(string $class): $this

从容器中删除模拟服务。

参数
string $class

要删除的类或接口。

返回值
$this

属性详情

$_appArgs ¶ protected

自定义的应用程序构造函数参数。

类型
array|null

$_appClass ¶ protected

自定义的应用程序类名。

类型
string|null

$_err ¶ protected

控制台错误输出存根

类型
Cake\Console\TestSuite\StubConsoleOutput|null

$_exitCode ¶ protected

最后一个退出代码

类型
int|null

$_in ¶ protected

控制台输入模拟

类型
Cake\Console\TestSuite\StubConsoleInput|null

$_out ¶ protected

控制台输出存根

类型
Cake\Console\TestSuite\StubConsoleOutput|null
OpenHub
Pingping
Linode
  • 商务解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成