2017 © Pedro PelĂĄez
 

library oc-plugin-testsuite

Testing middleware package for OctoberCMS Plugins

image

keios/oc-plugin-testsuite

Testing middleware package for OctoberCMS Plugins

  • Tuesday, October 25, 2016
  • by keiosweb
  • Repository
  • 3 Watchers
  • 2 Stars
  • 1,148 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Keios/oc-plugin-testsuite

Latest 
Version Software License Total Downloads, (*1)

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., (*2)

Prepared for OctoberCMS Release Candidate, won't work with beta releases., (*3)

Requirements

OctoberCMS, (*4)

Install

Via Composer, (*5)

``` bash $ composer require keios/oc-plugin-testsuite dev-master --dev, (*6)


## Usage #### phpunit.xml Plugin's phpunit.xml should look somewhat like this: ``` xml <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., (*7)

Your test cases should follow these rules:, (*8)

basic unit test ``` php <?php namespace Vendor\PluginName\Tests, (*9)

class SomeClassTest extends \OctoberPluginTestCase {, (*10)

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());
}

}, (*11)


**functional test requiring October environment, but not refreshing plugins** ``` php <?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 <?php namespace Vendor\PluginName\Tests, (*12)

class AFunctionalTestRequiringMigrations extends \OctoberPluginTestCase {, (*13)

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

} ```, (*14)

Credits

License

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

The Versions

25/10 2016

dev-master

9999999-dev

Testing middleware package for OctoberCMS Plugins

  Sources   Download

MIT

The Requires