phine/test

该包已被弃用且不再维护。未建议替代包。

一个用于提高单元测试的PHP库。

1.0.1 2013-12-30 23:23 UTC

This package is not auto-updated.

Last update: 2021-12-07 01:42:46 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads

一个用于提高单元测试的PHP库。

使用

use Phine\Test\Method;
use Phine\Test\Property;
use Phine\Test\Temp;

class Example
{
    private static $isStatic = 'original';

    private $nonStatic = 'original';

    protected static function isStatic($arg)
    {
        return "Static: $arg";
    }

    protected function nonStatic($arg)
    {
        return "Non static: $arg";
    }
}

$example = new Example();

// retrieve hidden values
echo Property::get('Example', 'isStatic'); // "original"
echo Property::get($example, 'nonStatic'); // "original"

// change hidden values
Property::set('Example', 'isStatic', 'changed');
Property::set($example, 'nonStatic', 'changed');

echo Property::get('Example', 'isStatic'); // "changed"
echo Property::get($example, 'nonStatic'); // "changed"

// invoke hidden methods
echo Method::invoke('Example', 'isStatic', 123); // "Static: 123"
echo Method::invoke($example, 'nonStatic', 456); // "Non static: 456"

echo Method::invokeArgs('Example', 'isStatic', array(123)); // "Static: 123"
echo Method::invokeArgs($example, 'nonStatic', array(456)); // "Static: 456"

$temp = new Temp();

// create temporary paths
$dir = $temp->createDir();
$file = $temp->createFile();

// copy existing paths to temporary ones (names are preserved)
$dir = $temp->copyDir('/path/to/dir');
$file = $temp->copyFile('/path/to/file');

// purge all temporary paths
$temp->purgePaths();

要求

安装

通过 Composer

$ composer require "phine/test=~1.0"

文档

您可以在 docs/ 目录中找到文档。

许可证

本库可在 MIT 许可证 下使用。