PHP code example of phine / test

1. Go to this page and download the library: Download phine/test library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phine / test example snippets


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