<?php

require dirname(__FILE__) . '/setup.php';
require dirname(__FILE__) . '/db_init.php';
$pdo = new PDO('mysql:host=localhost; dbname=hermit_test', 'root', 'password');
db_init($pdo);
$test = new lime_test();
$test->diag(basename(__FILE__));
$dbmeta = new HermitMySQLDatabaseMeta($pdo);
$test->diag(basename(__FILE__) . '::parameter[in:out]');
$procedureInfo = $dbmeta->getProcedureInfo('PROC_IN_OUT');
$test->ok($procedureInfo !== null);
$parameters = array_map('strtolower', $procedureInfo->getParamNames());
$expect = array('sales', 'tax');
$test->is(count(array_diff($parameters, $expect)), 0);
$test->is($procedureInfo->typeofIn('sales'), true);
$test->is($procedureInfo->typeofOut('sales'), false);
$test->is($procedureInfo->typeofInOut('sales'), false);
$test->is($procedureInfo->typeofIn('tax'), false);
$test->is($procedureInfo->typeofOut('tax'), true);
$test->is($procedureInfo->typeofInOut('tax'), false);
$procedureInfo2 = $dbmeta->getProcedureInfo('PROC_IN_OUT');
$test->ok($procedureInfo === $procedureInfo2, 'same instance');
$test->diag(basename(__FILE__) . '::parameter[in:out:out]');
$procedureInfo = $dbmeta->getProcedureInfo('PROC_IN_OUT_OUT');
$parameters = array_map('strtolower', $procedureInfo->getParamNames());
$expect = array('sales', 'tax', 'total');
$test->is(count(array_diff($parameters, $expect)), 0);
$test->is($procedureInfo->typeofIn('sales'), true);
$test->is($procedureInfo->typeofOut('sales'), false);
$test->is($procedureInfo->typeofInOut('sales'), false);
예제 #2
0
<?php

require dirname(__FILE__) . '/setup.php';
require dirname(__FILE__) . '/db_init.php';
$pdo = new PDO('mysql:host=localhost; dbname=hermit_test', 'root', 'password');
db_init($pdo);
$test = new lime_test();
$test->diag(basename(__FILE__));
$dbmeta = new HermitMySQLDatabaseMeta($pdo);
$tableInfo = $dbmeta->getTableInfo('EMP');
$test->isa_ok($tableInfo, 'HermitTableInfo', 'typeof HermitTableInfo');
$test->is(count($tableInfo->getPrimaryKeys()), 1, 'EMP table primary key is empno only');
$test->ok(in_array('empno', array_map('strtolower', array_values($tableInfo->getPrimaryKeys()))));
$tableInfo_hoge = $dbmeta->getTableInfo('EMP');
$test->ok($tableInfo === $tableInfo_hoge, 'same instance');
$test->is(spl_object_hash($tableInfo), spl_object_hash($tableInfo_hoge), 'same instance hash');
$columns = array_map('strtolower', array_values($tableInfo->getColumns()));
$expect = array('empno', 'ename', 'job', 'mgr', 'hiredate', 'sal', 'comm', 'deptno', 'tstamp');
$test->is(count(array_diff($expect, $columns)), 0);