igarastudio/visit 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

igarastudio/visit

Composer 安装命令:

composer require igarastudio/visit

包简介

A library to simulate and test user visits using php-cgi

README 文档

README

With visit you can simulate your website navigation through php-cgi without running a web server or a web browser. It supports cookies so you can use your PHP session to simulate user logins, etc.

Example

use PHPUnit\Framework\TestCase;

use IgaraStudio\Visit;
use function IgaraStudio\visit;

// If this test is in /tests/ and your index.php file in /public/ dir
Visit::$shared_options = [ 'docroot' => __DIR__ . '/../public',
                           'script' => __DIR__ . '/../public/index.php' ];

class UserLoginTest extends TestCase
{
  // Simulates a GET request to /login to check if the 'Login' text appears
  // in the page.
  public function testVisibleLoginButton(): void
  {
    visit('/login')->assertSee('Login');
  }

  // Simulates a POST request to /login with a specific form data, checks
  public function testInvalidLogin(): void
  {
    visit()
      ->post('/login', ['username' => 'invalid',
                        'password' => 'invalid'])
      ->assertSee('Invalid user or password');
  }

  // This login works because we process Cookie and Set-Cookie to keep the PHP
  // session in the same visit().
  public function testValidLogin(): void
  {
    visit()
      ->post('/login', ['username' => 'valid-username',
                        'password' => 'valid-password'])
      ->assertSee('Dashboard');
  }
}

Installation

You can add this library as a dependency to your project using Composer, generally you only need this library during development, for instance to run your project's test suite:

composer require --dev igarastudio/visit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固