silverstripe/testsession
Composer 安装命令:
composer require --dev silverstripe/testsession
包简介
Support module for browser-based test sessions, e.g. for Behat behaviour testing
关键字:
README 文档
README
Overview
IMPORTANT: This module is intended for development and testing, it poses a security risk if used on production servers. It's completely possible to allow any user to become an admin, or do other nefarious things, if this is installed on a live site.
This module starts a testing session in a browser, in order to test a Silverstripe application in a clean state. Usually the session is started on a fresh database with only default records loaded. Further data can be loaded from YAML fixtures or database dumps.
The session is persisted in a file which is generated upon starting the session.
As long as this file exists, the test session is considered in progress,
both in web browsers and command-line execution. By default, the file
is stored in the webroot under assets/TESTS_RUNNING-<id>.json. The <id> value
is a random token stored in the browser session, in order to make the
test session specific to the executing browser, and allow multiple
people using their own test session in the same webroot.
The module also keeps some metadata about the session state in the database, so that it may be available for the clients as well. E.g. the silverstripe-behat-extension may use it through this module APIs, allowing us to introduce some grey-box testing techniques.
The module also serves as an initializer for the Silverstripe Behat Extension. It is required for Behat because the Behat CLI test runner needs to persist test configuration just for the tested browser connection, available on arbitary URL endpoints. For example, we're setting up a test mailer which writes every email into a temporary database table for inspection by the CLI-based process.
Setup
Simply require the module in a Silverstripe webroot (3.0 or newer):
composer require --dev silverstripe/behat-extension
Usage
You start a test session by manually requesting a certain URL, and interact with it through other URL endpoints.
Commands:
dev/testsession: Shows options for starting a test sessiondev/testsession/start: Sets up test state, most commonly a test database will be constructed, and your browser session will be amended to use this database. See "Parameters" documentation below.dev/testsession/end: Removes the test state, and resets to the original database.dev/testsession/loadfixture?fixture=<path>: Loads a fixture into an existing test state.dev/testsession/clear: Empties the test state.dev/testsession/browsersessionstate: Set or unset browser session state (different from test session state). Use query parameters to define states.
While you can use the interface to set the test session state, it can be useful to set them programmatically through query parameters on "dev/testsession/start":
fixture: Loads a YAML fixture in the format generally accepted bySapphireTest(see fixture format docs). The path should be relative to the webroot.createDatabase: Create a temporary database.importDatabasePath: Absolute path to a database dump to load into a newly created temporary database.importDatabaseFilename: File name for a database dump to load, relative toTestSessionController.database_templates_pathrequireDefaultRecords: Include default records as defined on the model classes (in PHP)database: Set an alternative database name in the current browser session as a cookie. Does not actually create the database, that's usually handled bySapphireTest::create_temp_db(). Note: The database names are limited to a specific naming convention as a security measure: The "ss_tmpdb" prefix and a random sequence of seven digits. This avoids the user gaining access to other production databases available on the same connection.mailer: Subclass ofMailer, typically used to record emails instead of actually sending them.datetime: Sets a simulated date used for all framework operations. Format as "yyyy-MM-dd HH:mm:ss" (Example: "2012-12-31 18:40:59").globalTestSession: Activate test session independently of the current browser session, effectively setting the site into test session mode for all users across different browsers. Only available in "dev" mode. For example, create a global test session in Chrome, then you can share the session data in Firefox. But if you have started a non-global session in a browser before starting a global session somewhere else, that non-global session will take priority in that browser.
Example usage with parameters:
dev/testsession/start?database=ss_tmpdb_1234567&fixture=cms/tests/controller/CMSMainTest.yml
silverstripe/testsession 适用场景与选型建议
silverstripe/testsession 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 624.52k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2012 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe/testsession 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe/testsession 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe/testsession 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
Analytics chooser extensions for site settings.
The PHP SDK for Checkmango
CitaNZ's SilverStripe picture object and field for SilverStripe 4
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
统计信息
- 总下载量: 624.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 21
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2012-12-19