Overview

Namespaces

  • Budovy
  • Kdyby
    • BootstrapFormRenderer
      • DI
      • Latte
  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • Nextras
    • Datagrid
  • None
  • PHP
  • Tester
    • CodeCoverage
    • Runner
      • Output
  • Vodacek
    • Forms
      • Controls
  • WebLoader
    • Filter
    • Nette

Classes

  • Assert
  • DataProvider
  • DomQuery
  • Dumper
  • Environment
  • Helpers
  • TestCase

Exceptions

  • AssertException
  • TestCaseException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Tester.
 5:  * Copyright (c) 2009 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Tester;
 9: 
10: 
11: /**
12:  * Test helpers.
13:  *
14:  * @author     David Grudl
15:  */
16: class Helpers
17: {
18: 
19:     /**
20:      * Purges directory.
21:      * @param  string
22:      * @return void
23:      */
24:     public static function purge($dir)
25:     {
26:         if (!is_dir($dir)) {
27:             mkdir($dir);
28:         }
29:         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $entry) {
30:             if ($entry->isDir()) {
31:                 rmdir($entry);
32:             } else {
33:                 unlink($entry);
34:             }
35:         }
36:     }
37: 
38: 
39:     /**
40:      * Parse phpDoc comment.
41:      * @return array
42:      * @internal
43:      */
44:     public static function parseDocComment($s)
45:     {
46:         $options = array();
47:         if (!preg_match('#^/\*\*(.*?)\*/#ms', $s, $content)) {
48:             return array();
49:         }
50:         if (preg_match('#^[ \t\*]*+([^\s@].*)#mi', $content[1], $matches)) {
51:             $options[0] = trim($matches[1]);
52:         }
53:         preg_match_all('#^[ \t\*]*@(\w+)([^\w\r\n].*)?#mi', $content[1], $matches, PREG_SET_ORDER);
54:         foreach ($matches as $match) {
55:             $ref = & $options[strtolower($match[1])];
56:             if (isset($ref)) {
57:                 $ref = (array) $ref;
58:                 $ref = & $ref[];
59:             }
60:             $ref = isset($match[2]) ? trim($match[2]) : '';
61:         }
62:         return $options;
63:     }
64: 
65: 
66:     /**
67:      * @internal
68:      */
69:     public static function errorTypeToString($type)
70:     {
71:         $consts = get_defined_constants(TRUE);
72:         foreach ($consts['Core'] as $name => $val) {
73:             if ($type === $val && substr($name, 0, 2) === 'E_') {
74:                 return $name;
75:             }
76:         }
77:     }
78: 
79: 
80:     /**
81:      * Escape a string to be used as a shell argument.
82:      * @return string
83:      */
84:     public static function escapeArg($s)
85:     {
86:         return defined('PHP_WINDOWS_VERSION_BUILD')
87:             ? '"' . str_replace('"', '""', $s) . '"'
88:             : escapeshellarg($s);
89:     }
90: 
91: }
92: 
API documentation generated by ApiGen 2.8.0