Overview

Packages

  • Pinoco
    • PAL

Classes

  • Pinoco
  • Pinoco_Delegate
  • Pinoco_DynamicVars
  • Pinoco_HttpRequestVars
  • Pinoco_List
  • Pinoco_MIMEType
  • Pinoco_NativeRenderer
  • Pinoco_NothingVars
  • Pinoco_NullRenderer
  • Pinoco_OptionalParam
  • Pinoco_Pagination
  • Pinoco_PDOStatementWrapper
  • Pinoco_PDOWrapper
  • Pinoco_Renderer
  • Pinoco_Router
  • Pinoco_TALRenderer
  • Pinoco_TestEnvironment
  • Pinoco_Validator
  • Pinoco_ValidatorContext
  • Pinoco_Vars

Interfaces

  • Pinoco_ArrayConvertible

Functions

  • __pinoco_autoload_impl
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Pinoco: makes existing static web site dynamic transparently.
 4:  * Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
 5:  *
 6:  * Licensed under The MIT License
 7:  * Redistributions of files must retain the above copyright notice.
 8:  *
 9:  * PHP Version 5
10:  *
11:  * @author     Hisateru Tanaka <tanakahisateru@gmail.com>
12:  * @copyright  Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
13:  * @license    MIT License (http://www.opensource.org/licenses/mit-license.php)
14:  * @package    Pinoco
15:  */
16: 
17: /**
18:  * Testable Pinoco instance factory for unit test framework.
19:  *
20:  * @package Pinoco
21:  */
22: class Pinoco_TestEnvironment extends Pinoco_Vars
23: {
24:     private $_basedir;
25:     private $_sysdir;
26:     private $_baseuri;
27:     private $_dispatcher;
28: 
29:     private $_preprocess;
30: 
31:     /**
32:      * Initialize testable Pinoco factory mainly by base directory and app directory.
33:      *
34:      * @param string $sysdir
35:      * @param string $basedir
36:      * @param string $baseuri
37:      * @param string $dispatcher
38:      */
39:     public function __construct($basedir, $sysdir, $baseuri="/", $dispatcher="")
40:     {
41:         $this->_basedir = $basedir;
42:         $this->_sysdir = $sysdir;
43:         $this->_baseuri = $baseuri;
44:         $this->_dispatcher = $dispatcher;
45:         $this->_preprocess = false;
46:     }
47: 
48:     /**
49:      * Use this to define Pinoco's instance initialize process.
50:      *
51:      * @param callback $callable
52:      * @param mixed $context
53:      * @return Pinoco_TestEnvironment
54:      */
55:     public function initBy($callable, $context=null)
56:     {
57:         $this->_preprocess = array($callable, $context);
58:         return $this;
59:     }
60: 
61:     /**
62:      * Provides an initialized Pinoco instance.
63:      *
64:      * @param string $path
65:      * @return Pinoco
66:      */
67:     public function create($path)
68:     {
69:         $pinoco = new Pinoco(
70:             $this->_baseuri, $this->_dispatcher, $path,
71:             $this->_basedir, $this->_sysdir, true
72:         );
73:         if ($this->_preprocess) {
74:             call_user_func($this->_preprocess[0], $pinoco, $this->_preprocess[1]);
75:         }
76:         return $pinoco;
77:     }
78: }
79: 
80: 
Pinoco 0.8.0 Documentation API documentation generated by ApiGen 2.8.0