承接 keios/oc-plugin-testsuite 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

keios/oc-plugin-testsuite

Composer 安装命令:

composer require keios/oc-plugin-testsuite

包简介

Testing middleware package for OctoberCMS Plugins

README 文档

README

Latest Version Software License Total Downloads

THIS PACKAGE IS NOW DEPRECATED AS OCTOBERCMS NOW SHIPS WITH IT'S OWN PLUGIN UNIT TESTING TEST CASE.

Testing middleware package: provides extended PHPUnit's TestCase class - OctoberPluginTestCase, which allows for unit testing in OctoberCMS / Laravel context and loads all related composer autoloaders.

Prepared for OctoberCMS Release Candidate, won't work with beta releases.

Requirements

OctoberCMS

Install

Via Composer

$ composer require keios/oc-plugin-testsuite dev-master --dev

Usage

phpunit.xml

Plugin's phpunit.xml should look somewhat like this:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/keios/oc-plugin-testsuite/bootstrap/autoload.php"
         backupGlobals="false"
         backupStaticAttributes="false"
         colors="true"
         verbose="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false">
    <testsuites>
        <testsuite name="October Plugin Unit Test Suite">
            <directory>tests/unit</directory>
        </testsuite>
        <testsuite name="October Plugin Functional Test Suite">
            <directory>tests/functional</directory>
        </testsuite>
    </testsuites>
    <logging>
        <log type="tap" target="build/report.tap"/>
        <log type="junit" target="build/report.junit.xml"/>
        <log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
        <log type="coverage-text" target="build/coverage.txt"/>
        <log type="coverage-clover" target="build/logs/clover.xml"/>
    </logging>
    <php>
        <env name="APP_ENV" value="plugin_testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
    </php>
</phpunit>

Test Cases

Package provides class OctoberPluginTestCase, which is prepared to run tests in Laravel 5 / OctoberCMS environment and comes with handy features like automatic migrations.

Your test cases should follow these rules:

basic unit test

<?php namespace Vendor\PluginName\Tests

class SomeClassTest extends \OctoberPluginTestCase {

    protected $someMockObjectUsedInAllTests;

    public function pluginTestSetUp () // PHPUnit's set up method is unavailable, use this instead
    {
        $this->someMockObjectUsedInAllTests = \Mockery::mock('Some\Other\Class');
    }

    public function testSomething() { 
        $instance = new SomeClass($this->someMockObjectUsedInAllTests);
        
        $this->assertEquals('result', $instance->getResult());
    }

}

functional test requiring October environment, but not refreshing plugins

<?php namespace Vendor\PluginName\Tests

class AFunctionalTest extends \OctoberPluginTestCase {

    protected $requiresOctoberMigration = true; // test suite will migrate october

}

functional test requiring October environment AND refreshing plugin 'Vendor.PluginName'

<?php namespace Vendor\PluginName\Tests

class AFunctionalTestRequiringMigrations extends \OctoberPluginTestCase {

    /*
     * Here you can add multiple plugin codes, ie.: your plugin and it's dependencies
     */
    protected $refreshPlugins = ['Vendor.PluginName', 'OtherVendor.OtherPlugin'];

}

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-09