2017 © Pedro Peláez
 

library phpt

Parses PHPT unit test files into sections as key-value pairs.

image

skyzyx/phpt

Parses PHPT unit test files into sections as key-value pairs.

  • Wednesday, February 8, 2012
  • by skyzyx
  • Repository
  • 1 Watchers
  • 4 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHPT Component

Parses PHPT unit test files into sections as key-value pairs., (*1)

Example

Say, for example, you have this PHPT unit test:, (*2)

--TEST--
Test that my code works!

--DESCRIPTION--
This test covers [blah, blah, blah...]

--CREDITS--
Zoe Slattery zoe@php.net
# TestFest Munich 2009-05-19

--FILE--
<?php
var_dump(array(
    'hello' => 'World',
    'goodbye' => 'MrChips'
));
?>

--EXPECT--
array(2) {
  ["hello"]=>
  string(5) "World"
  ["goodbye"]=>
  string(7) "MrChips"
}

You decide that you want to grab the contents of the FILE header:, (*3)

<?php
use Skyzyx\Components\PHPT;

$file = file_get_contents('sample.phpt');
$phpt = new PHPT($file);
$results = $phpt->get_section('FILE');

echo $results;

This would display the following:, (*4)

<?php
var_dump(array(
    'hello' => 'World',
    'goodbye' => 'MrChips'
));
?>

Installation

Install source from GitHub

To install the source code:, (*5)

git clone git://github.com/skyzyx/phpt.git

And include it in your scripts:, (*6)

require_once '/path/to/phpt/src/PHPT.php';

Install with Composer

If you're using Composer to manage dependencies, you can add PHP with it., (*7)

{
    "require": {
        "skyzyx/phpt": ">=1.1"
    }
}

Using a Class Loader

If you're using a class loader (e.g., Symfony Class Loader):, (*8)

$loader->registerNamespace('Skyzyx\\Components\\PHPT', 'path/to/vendor/phpt/src');

Tests

Tests are written in PHPT format. You can run them with either the PEAR Test Runner or with PHPUnit 3.6+., (*9)

cd tests/
pear run-tests .

...or..., (*10)

cd tests/
phpunit .

Copyright (c) 2010-2012 Ryan Parman. Licensed for use under the terms of the MIT license., (*11)

The Versions

08/02 2012

dev-master

9999999-dev http://github.com/skyzyx/phpt

Parses PHPT unit test files into sections as key-value pairs.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

test phpt

08/02 2012

1.1

1.1.0.0 http://github.com/skyzyx/phpt

Parses PHPT unit test files into sections as key-value pairs.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

test phpt