Login   Register  
PHP Classes
elePHPant
Icontem

File: square.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Benjie Velarde  >  SquareSpec  >  square.php  >  Download  
File: square.php
Role: Application script
Content type: text/plain
Description: Application script
Class: SquareSpec
Test PHP code using Behavior Driven Development
Author: By
Last change:
Date: 2013-04-30 02:48
Size: 1,007 bytes
 

Contents

Class file image Download
#!/usr/bin/php
<?php
define
('APP_ROOT'dirname(dirname(__FILE__)) . '/');
define('SPECS_DIR'APP_ROOT 'specs/');

use 
SquareSpec\SpecSubject;

$t1 microtime(TRUE);

echo 
"\n";
$ok TRUE;
if (!isset(
$argv[1])) {
    
$files scandir(SPECS_DIR);
    foreach (
$files as $file) {
        if (
preg_match('/^([a-z0-9_]+)\.specs\.php$/'$file$matches)) {
            include(
SPECS_DIR $matches[0]);
        } 
    }
} elseif (
file_exists(SPECS_DIR $argv[1] . '.specs.php')) {
    include(
SPECS_DIR $argv[1] . '.specs.php');
} else {
    
$ok FALSE;
}
if (
$ok) {
    echo 
"\n";
    if (
SpecSubject::$failures) {    
        echo 
"\nFailed on: \n -" implode("\n -"SpecSubject::$failures);
        echo 
"\n";
    }
    echo 
"\nFailures: " count(SpecSubject::$failures) . "\n";
    echo 
'Success: ' SpecSubject::$success "\n";
    echo 
'Total: ' SpecSubject::$total "\n\n";
    
    echo 
'Time Elapsed: ' . (microtime(TRUE) - $t1);
} else {
    echo 
"Can't find specs for $argv[1]";
}
?>