定制 christophwurst/nextcloud_testing 二次开发

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

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

christophwurst/nextcloud_testing

最新稳定版本:v1.1.0

Composer 安装命令:

composer require christophwurst/nextcloud_testing

包简介

Simple and fast unit and integration testing framework for Nextcloud, based on PHPUnit

README 文档

README

Simple and fast unit and integration testing framework for Nextcloud 25+, based on PHPUnit

Features

  • Minimal setUp/tearDown overhead for unit tests
  • Simple trait-based mechanism to reset database after integration tests
  • Based on PHPUnit

Unit Tests

Use TestCase as base class for your test case:

<?php

use ChristophWurst\Nextcloud\Testing\TestCase;

class ControllerTest extends TestCase {

    … your test code …

}

Integration Tests

Include the DatabaseTransaction trait in your test case and any changes to the database will be rolled back after each test:

<?php

use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
use ChristophWurst\Nextcloud\Testing\TestCase;

class ControllerTest extends TestCase {

    use DatabaseTransaction;

    … your test code …

}

Selenium Tests

Include the Selenium trait in your test case and access the Webdriver instance via $this->webDriver:

<?php

use ChristophWurst\Nextcloud\Testing\Selenium;
use ChristophWurst\Nextcloud\Testing\TestCase;

class ControllerTest extends TestCase {

    use Selenium;

    public function testWithSelenium() {
        …

        $this->webDriver->get('http://localhost:8080/index.php/login');

        …
    }

}

This framework targets Sauce Labs as testing back-end that runs the test browser instances. Hence, it is necessary to set the SAUCE_USERNAME and SAUCE_ACCESS_KEY env variables. SELENIUM_BROWSER lets you choose the browser to run your tests against.

Test Users

Include the TestUser trait in your test case to conveniently generate new test users. The trait will create a new user with a random UID (including collision detection).

<?php

use ChristophWurst\Nextcloud\Testing\TestCase;
use ChristophWurst\Nextcloud\Testing\TestUser;

class ControllerTest extends TestCase {

    use TestUser;

    public function testWithSelenium() {
        …

        $user = $this->createTestUser();

        …
    }

}

The returned user is of type IUser. You can read its UID with $user->getUID(). Note that the user is not removed after the test.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-12