MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
munittest.class
Ir para a documentação deste ficheiro.
1<?php //
25/*
26 * Configuration to have MIOLO working on command line
27 */
28//
29//global $module;
30//global $dir;
31//global $path;
32//$classPath = "$path/classes/";
33//require_once "$classPath/miolo.class";
34//
36// * MIOLOConsole class
37// */
38//class MIOLOConsole
39//{
40// /**
41// * @var object MIOLO instance
42// */
43// private $MIOLO;
44//
45// /**
46// * @var string Module name
47// */
48// private $module;
49//
50// /**
51// * Create a MIOLO instance
52// *
53// * @param string $pathMiolo MIOLO direcotry path
54// * @param string $module Module
55// * @return object MIOLO instance
56// */
57// public function getMIOLOInstance($pathMiolo, $module)
58// {
59// ob_start();
60// echo "MIOLO console\n\n";
61//
62// $this->module = $module;
63//
64// /*
65// * Simulates apache variables which are required by MIOLO
66// */
67// $_SERVER['DOCUMENT_ROOT'] = "$pathMiolo/html";
68// $_SERVER['SCRIPT_FILENAME'] = "$pathMiolo/html";
69// $_SERVER['HTTP_HOST'] = 'miolo2.5';
70// $_SERVER['SCRIPT_NAME'] = '/index.php';
71// $_SERVER['QUERY_STRING'] = strlen($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : 'module=' . $this->module . '&action=main';
72// $_SERVER['REQUEST_URI'] = "http://{$_SERVER['HTTP_HOST']}/{$_SERVER['SCRIPT_NAME']}?{$_SERVER['QUERY_STRING']}";
73//
74// /*
75// * Instantiates MIOLO
76// */
77// $this->MIOLO = MIOLO::getInstance();
78// ob_end_clean();
79//
80// return $this->MIOLO;
81// }
82//
83// /**
84// * Load MIOLO configuration
85// */
86// public function loadMIOLO()
87// {
88// ob_start();
89// $this->MIOLO->handlerRequest();
90// $this->MIOLO->conf->loadConf($this->module);
91// ob_end_clean();
92// }
93//
94//}
95//
96//$MIOLOConsole = new MIOLOConsole();
97//$GLOBALS['MIOLO'] = $MIOLO = $MIOLOConsole->getMIOLOInstance($path, $module);
98//$MIOLOConsole->loadMIOLO();
99//
100//$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
101
105class MUnitTest extends PHPUnit_Framework_TestCase
106{
110 protected $backupGlobalsBlacklist = array('MIOLO', 'autoload', 'MIOLOConsole');
111
112 protected $backupGlobals = false;
113 protected $backupStaticAttributes = false;
114
118 protected $type = array();
119
123 protected $business = array();
124
128 protected $pkeys = array('id');
129
135 public function addType($type)
136 {
137 $this->type[] = $type;
138 }
139
145 public function addBusiness($business)
146 {
147 $this->business[] = $business;
148 }
149
153// public function testBusiness()
154// {
155// foreach ( $this->business as $key => $obj )
156// {
157// echo "Business $key:\n";
158//
159// // TODO: BEGIN
160//
161// try
162// {
163// echo "Testing insert\t";
164// $ret = $obj->insert();
165// $this->assertTrue($ret);
166// echo "OK\n";
167//
168// echo "Testing search\t";
169// $ret = $obj->search($obj);
170// $this->assertTrue(count($ret) > 0);
171// echo "OK\n";
172//
173// // define primary keys if they are not defined
174// // FIXME: only works if there is only one primary key
175// if ( count($this->pkeys) == 1 )
176// {
177// foreach ( $this->pkeys as $pk )
178// {
179// $method = 'get' . $pk;
180// if ( !$obj->$method() )
181// {
182// $method = 'set' . $pk;
183// // first column, last row
184// $obj->$method(current(end($ret)));
185// }
186// }
187// }
188//
189// echo "Testing update\t";
190// $ret = $obj->update();
191// $this->assertTrue($ret > 0);
192// echo "OK\n";
193//
194// echo "Testing delete\t";
195// $ret = $obj->delete();
196// $this->assertTrue($ret);
197// echo "OK\n";
198// }
199// catch ( MDatabaseException $e )
200// {
201// echo "FAIL\n\n";
202// echo $e;
203// throw new Exception;
204// }
205// catch ( Exception $e )
206// {
207// echo "FAIL\n\n";
208// echo str_replace('<br />', "\n", $e->getMessage());
209// throw new Exception;
210// }
211//
212// echo "\n";
213//
214// // TODO: ROLLBACK
215// }
216// }
217}
218
219?>
$backupStaticAttributes
addBusiness($business)
addType($type)
$backupGlobalsBlacklist