定制 tyler36/cypress-cake 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tyler36/cypress-cake

最新稳定版本:v2.1

Composer 安装命令:

composer require tyler36/cypress-cake

包简介

Cypress plugin for CakePHP

README 文档

README

Overview

This add-on adds some helper files for working with Cypress and CakePHP.

  • This plugin injects a CSRF token into POST requests made to cypress-cake endpoints.
  • This plugin bypasses Authentication on cypress-cake endpoints.

Important

This plugin exposes an API to work with the database. It is recommend for local development only. Do not use in production!

Installation

  1. Install plugin

    ddev composer require tyler36/cypress-cake
    ddev cake plugin load Tyler36/CypressCake
  2. Install Cypress if not available. Eg.

  3. Update cypress/support/commands.js to import the helpers

    import '../../vendor/tyler36/cypress-cake/src/support/cypress-commands'

Helpers

API Description
/cypress/clear-database Clear all data from database.
/cypress/import-database Import a database file.
/cypress/csrf-token Get a CSRF token. This is required POST forms.
/cypress/create Run a factory to generate a entity.
/cypress/cake Run arbitrary cake commands.

Clear Database

Use the Cypress command cy.clearDatabase() to clear all data from database.

cy.clearDatabase()

Import Database

Use cy.importDatabase() to import a SQL file. By default, this it will import a file located at env('SQL_TESTING_BASE_DUMP'), relative to the root. However, you can provide a path as the first parameter.

// Import `env('SQL_TESTING_BASE_DUMP')` database file.
cy.importDatabase()

// Import '/tmp/test.sql'.
cy.importDatabase('/tmp/test.sql')

Create An Entity

Use cy.create('User') to generate an entity from a configured factory. This packages expects to find vierge-noire/cakephp-fixture-factories factories. Please see their documentation for creating factories.

cy.create('User')

It is possible to pass additional attributes to the factory allowing to to set default data.

For example, the following creates a User entity with the email set to foobar@example.com.

cy.create('User', { email: 'example@example.com' })

Run Arbitrary Cake Command

Post a request to /cypress/cake to run CakePHP commands.

# To get CakePHP version
cy.cake('version')

# To clear all caches
cy.cake('cache clear_all')

Contributing

PRs, especially with tests, will be considered.

Contributed and maintained by tyler36

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固