openbuildings / kohana-test-bootstrap
此软件包已被弃用且不再维护。未建议替代软件包。
Kohana模块测试的辅助软件包
0.2.0
2016-07-28 14:07 UTC
Requires
- kohana/core: ^3.3
This package is auto-updated.
Last update: 2020-07-03 19:39:13 UTC
README
用于单独测试Kohana模块 - 包含所有Kohana框架系统和核心模块的composer包。
如果您想编写一个模块并独立测试它(例如通过某些Cloud CI) - 那么您需要Kohana环境,因为它尚未在composer中,可能会存在问题。此包添加了所有Kohana自动加载和级联文件系统,以及核心模块,您可以根据需要启用它们。
用法
由于其用途是测试,建议将其放置在composer.json的require-dev部分,如下所示
"require-dev": { "openbuildings/kohana-test-bootsrap": "dev-master" }
之后,您应该在测试文件夹中创建一个"test bootstrap文件",如下所示
tests/bootstrap.php
require_once __DIR__.'/../vendor/autoload.php'; Kohana::modules(array( // Add some core kohaan modules 'database' => MODPATH.'database', 'cache' => MODPATH.'cache', // Your own module - this is where the module you are testing will appear in kohana's cascading filesystem 'functest' => __DIR__.'/..', // Any other kohana modules, required with composer.json can be added like this 'test' => __DIR__.'/../tests/testmodule', )); // Add some custom configuration, to be used only in testing - for example we adda a database config. Kohana::$config ->load('database') ->set(Kohana::TESTING, array( 'type' => 'MySQL', 'connection' => array( 'hostname' => 'localhost', 'database' => 'test-functest', 'username' => 'root', 'password' => '', 'persistent' => TRUE, ), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE, ));
一个示例phpunit可能如下所示
phpunit.xml
<phpunit colors="true" bootstrap="tests/bootstrap.php"> <testsuites> <testsuite> <directory>tests/tests</directory> </testsuite> </testsuites> <filter> <blacklist> <directory suffix=".php">vendor/</directory> </blacklist> </filter> </phpunit>
它将tests/bootstrap.php指定为phpunit的引导文件。
作者
由Ivan Kerin作为clippings.com的一部分开发