CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识 & 商标
  • 商业解决方案
  • 周边产品
  • 路演
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • Bakery
    • 精选资源
    • 培训
    • 聚会
    • 我的 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
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
      • Constraint
      • Fixture
        • Extension
      • Stub
    • Utility
    • Validation
    • View

类 TestFixture

Cake TestFixture 负责构建和销毁测试期间使用的表。

命名空间: Cake\TestSuite\Fixture

属性概览

  • $_schema protected
    Cake\Database\Schema\TableSchemaInterfaceCake\Database\Schema\SqlGeneratorInterface

    此 fixture 的模式。

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

    表定位器实例

  • $connection public
    string

    Fixture 数据源

  • $defaultTable protected
    string|null

    此对象的默认表别名。

  • $records public
    array

    要插入的 Fixture 记录。

  • $table public
    string

    完整表名

方法概览

  • __construct() public

    实例化 fixture。

  • _getRecords() protected

    将内部记录转换为用于生成查询的数据。

  • _schemaFromReflection() protected

    直接从数据源构建 fixture 模式

  • _tableFromClass() protected

    使用 fixture 类返回表名

  • connection() public

    获取此 fixture 应该插入的连接名称。

  • fetchTable() public

    获取表实例的便捷方法。

  • getTableLocator() public

    获取表定位器。

  • getTableSchema() public

    返回此 fixture 的表模式。

  • init() public

    初始化 fixture。

  • insert() public

    在每个测试执行之前运行。

  • setTableLocator() public

    设置表定位器。

  • sourceName() public

    获取此 fixture 的表/集合名称。

  • truncate() public

    截断当前 fixture。

方法详细说明

__construct() ¶ public

__construct()

实例化 fixture。

抛出
Cake\Core\Exception\CakeException
在使用无效数据源时。

_getRecords() ¶ protected

_getRecords(): array

将内部记录转换为用于生成查询的数据。

返回
array

_schemaFromReflection() ¶ protected

_schemaFromReflection(): void

直接从数据源构建 fixture 模式

返回
void
抛出
Cake\Core\Exception\CakeException
当尝试反射一个不存在的表时

_tableFromClass() ¶ protected

_tableFromClass(): string

使用 fixture 类返回表名

返回
string

connection() ¶ public

connection(): string

获取此 fixture 应该插入的连接名称。

返回
string

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()

getTableLocator() ¶ public

getTableLocator(): Cake\ORM\Locator\LocatorInterface

获取表定位器。

返回
Cake\ORM\Locator\LocatorInterface

getTableSchema() ¶ public

getTableSchema(): Cake\Database\Schema\TableSchemaInterfaceCake\Database\Schema\SqlGeneratorInterface

返回此 fixture 的表模式。

返回
Cake\Database\Schema\TableSchemaInterfaceCake\Database\Schema\SqlGeneratorInterface

init() ¶ public

init(): void

初始化 fixture。

返回
void
抛出
Cake\ORM\Exception\MissingTableClassException
从不存在的表导入时。

insert() ¶ public

insert(Cake\Datasource\ConnectionInterface $connection): bool

在每个测试执行之前运行。

应该将所有记录插入测试数据库。

参数
Cake\Datasource\ConnectionInterface $connection
返回
bool

setTableLocator() ¶ public

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

设置表定位器。

参数
Cake\ORM\Locator\LocatorInterface $tableLocator

定位器接口实例。

返回
$this

sourceName() ¶ public

sourceName(): string

获取此 fixture 的表/集合名称。

返回
string

truncate() ¶ public

truncate(Cake\Datasource\ConnectionInterface $connection): bool

截断当前 fixture。

参数
Cake\Datasource\ConnectionInterface $connection
返回
bool

属性详细说明

$_schema ¶ protected

此 fixture 的模式。

类型
Cake\Database\Schema\TableSchemaInterfaceCake\Database\Schema\SqlGeneratorInterface

$_tableLocator ¶ protected

表定位器实例

类型
Cake\ORM\Locator\LocatorInterface|null

$connection ¶ public

Fixture 数据源

类型
string

$defaultTable ¶ protected

此对象的默认表别名。

类型
string|null

$records ¶ public

要插入的 Fixture 记录。

类型
array

$table ¶ public

完整表名

类型
string
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识 & 商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • Bakery
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助 & 支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成