Location: PHPKode > scripts > Flatfile > flatfile/tests/utils_tests.php
#!/usr/bin/env php
<?php

// Simple tests suite for the utils.php in flatfile

error_reporting(E_ALL);
require_once('../flatfile_utils.php');

// Constants for the DB structure

function setUp()
{
	$tables = array();
	
	$tables['carrier'] = array(
		'ID' => new Column(0, INT_COL),
		'NAME' => new Column(1, STRING_COL)
	);
	
	$tables['game'] = array(
		'ID' => new Column(0, INT_COL),
		'TITLE' => new Column(1, STRING_COL),
	);
	
	$tables['game_carrier'] = array(
		'CARRIER_ID' => new JoinColumn(0, 'carrier', 'ID'),
		'GAME_ID' => new JoinColumn(1, 'game', 'ID')
	);

	$GLOBALS['tables'] = &$tables;
}

setUp();

// Test resolveJoins 
TableUtils::resolveJoins($tables);

assert('$tables["game_carrier"]["CARRIER_ID"]->type == INT_COL');
assert('$tables["game_carrier"]["GAME_ID"]->type == INT_COL');

// Test createDefines
TableUtils::createDefines($tables);

assert('CARRIER_ID == 0');
assert('CARRIER_NAME == 1');
assert('GAME_ID == 0');
assert('GAME_TITLE == 1');
assert('GAME_CARRIER_CARRIER_ID == 0');
assert('GAME_CARRIER_GAME_ID == 1');

// Test createRowSchema
$row_schema = TableUtils::createRowSchema($tables['game']);
assert('$row_schema == array(INT_COL, STRING_COL)');

?>
Return current item: Flatfile