PHPUnit TestCase For PHP Extension
PHP
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/PHPUnit/Framework
tests
README.md
composer.json
package.ini
package.xml
phpunit.xml

README.md

PHPUnit Framework ExtensionTestCase

Installation

composer:

{
    require: {
        "corneltek/phpunit-framework-extensiontestcase": "dev-master"
    }
}
$ pear channel-discover pear.corneltek.com
$ pear install corneltek/PHPUnit_Framework_ExtensionTestCase

Usage

The Sample ExtensionTestcase class:


class FileUtilTest extends PHPUnit_Framework_ExtensionTestCase
{

    public function getExtensionName()
    {
        return 'fileutil';
    }


    public function getFunctions()
    {
        return array(
            'futil_scandir',
            'futil_scandir_dir',
        );
    }

    public function testScanDirOnExistingDir()
    {
        $files = futil_scandir("/etc");
        ok($files,"Should return a file list");
        ok(is_array($files));
        foreach($files as $file) {
            path_ok($file);
        }
    }

    public function testScanDirOnExistingFile()
    {
        $files = futil_scandir("tests/FileUtilTest.php");
        is(false,$files,"Should return false on file path");
    }

    public function testScanDirOnNonExistingPath()
    {
        $files = futil_scandir("blah/blah");
        is(false,$files,"Should return false on file path");
    }


    public function testScanDirDir()
    {
        $paths = futil_scandir_dir("/");
        foreach($paths as $path) {
            ok(is_dir($path),'is_dir ok');
        }
    }
}