承接 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

统计信息

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

GitHub 信息

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

其他信息

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