Skip to content

Commit

Permalink
Merge branch '1.3' into scaffold-design
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 13, 2010
2 parents 6ba16f3 + 84840c7 commit ee8ebce
Show file tree
Hide file tree
Showing 56 changed files with 2,407 additions and 1,516 deletions.
83 changes: 3 additions & 80 deletions app/webroot/test.php
Expand Up @@ -18,7 +18,6 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
set_time_limit(0);
ini_set('memory_limit','128M');
ini_set('display_errors', 1);
/**
* Use the DS to separate the directories in other defines
Expand Down Expand Up @@ -85,89 +84,13 @@
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
}

require_once CAKE_TESTS_LIB . 'test_manager.php';

if (Configure::read('debug') < 1) {
die(__('Debug setting does not allow access to this url.', true));
}

if (!isset($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = '';
}
if (empty( $_GET['output'])) {
$_GET['output'] = 'html';
}
/**
*
* Used to determine output to display
*/
define('CAKE_TEST_OUTPUT_HTML', 1);
define('CAKE_TEST_OUTPUT_TEXT', 2);

if (isset($_GET['output']) && $_GET['output'] == 'html') {
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
} else {
Debugger::output('txt');
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
}

if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
CakePHPTestHeader();
include CAKE_TESTS_LIB . 'simpletest.php';
CakePHPTestSuiteFooter();
exit();
}

$analyzeCodeCoverage = false;
if (isset($_GET['code_coverage'])) {
$analyzeCodeCoverage = true;
require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
if (!extension_loaded('xdebug')) {
CakePHPTestHeader();
include CAKE_TESTS_LIB . 'xdebug.php';
CakePHPTestSuiteFooter();
exit();
}
}

CakePHPTestHeader();
CakePHPTestSuiteHeader();
define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);

if (isset($_GET['group'])) {
if ('all' == $_GET['group']) {
TestManager::runAllTests(CakeTestsGetReporter());
} else {
if ($analyzeCodeCoverage) {
CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
}
TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
if ($analyzeCodeCoverage) {
CodeCoverageManager::report();
}
}
require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php';

CakePHPTestRunMore();
CakePHPTestAnalyzeCodeCoverage();
} elseif (isset($_GET['case'])) {
if ($analyzeCodeCoverage) {
CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
}

TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());

if ($analyzeCodeCoverage) {
CodeCoverageManager::report();
}
$Dispatcher = new CakeTestSuiteDispatcher();
$Dispatcher->dispatch();

CakePHPTestRunMore();
CakePHPTestAnalyzeCodeCoverage();
} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
CakePHPTestCaseList();
} else {
CakePHPTestGroupTestList();
}
CakePHPTestSuiteFooter();
$output = ob_get_clean();
echo $output;
?>
15 changes: 11 additions & 4 deletions cake/console/libs/tasks/fixture.php
Expand Up @@ -54,13 +54,15 @@ class FixtureTask extends Shell {
* The db connection being used for baking
*
* @var string
* @access public
*/
var $connection = null;

/**
* Schema instance
*
* @var object
* @access protected
*/
var $_Schema = null;

Expand Down Expand Up @@ -140,6 +142,7 @@ function __interactive() {
*
* @param string $modelName Name of model you are dealing with.
* @return array Array of import options.
* @access public
*/
function importOptions($modelName) {
$options = array();
Expand Down Expand Up @@ -167,8 +170,8 @@ function importOptions($modelName) {
* @param string $model Name of model to bake.
* @param string $useTable Name of table to use.
* @param array $importOptions Options for var $import
* @return string Baked fixture
* @access private
* @return string Baked fixture content
* @access public
*/
function bake($model, $useTable = false, $importOptions = array()) {
if (!class_exists('CakeSchema')) {
Expand Down Expand Up @@ -228,8 +231,8 @@ function bake($model, $useTable = false, $importOptions = array()) {
*
* @param string $model name of the model being generated
* @param string $fixture Contents of the fixture file.
* @return string Content saved into fixture file.
* @access public
* @return void
*/
function generateFixtureFile($model, $otherVars) {
$defaults = array('table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null);
Expand All @@ -255,6 +258,7 @@ function generateFixtureFile($model, $otherVars) {
*
* @param array $table Table schema array
* @return string fields definitions
* @access protected
*/
function _generateSchema($tableInfo) {
$schema = $this->_Schema->generateTable('f', $tableInfo);
Expand All @@ -266,6 +270,7 @@ function _generateSchema($tableInfo) {
*
* @param array $table Table schema array
* @return array Array of records to use in the fixture.
* @access protected
*/
function _generateRecords($tableInfo, $recordCount = 1) {
$records = array();
Expand Down Expand Up @@ -337,6 +342,7 @@ function _generateRecords($tableInfo, $recordCount = 1) {
*
* @param array $records Array of records to be converted to string
* @return string A string value of the $records array.
* @access protected
*/
function _makeRecordString($records) {
$out = "array(\n";
Expand All @@ -360,6 +366,7 @@ function _makeRecordString($records) {
* @param string $modelName name of the model to take records from.
* @param string $useTable Name of table to use.
* @return array Array of records.
* @access protected
*/
function _getRecordsFromTable($modelName, $useTable = null) {
if ($this->interactive) {
Expand All @@ -378,7 +385,7 @@ function _getRecordsFromTable($modelName, $useTable = null) {
'recursive' => -1
));
$db =& ConnectionManager::getDataSource($modelObject->useDbConfig);
$schema = $modelObject->schema();
$schema = $modelObject->schema(true);
$out = array();
foreach ($records as $record) {
$row = array();
Expand Down
11 changes: 6 additions & 5 deletions cake/console/libs/tasks/model.php
Expand Up @@ -186,7 +186,7 @@ function __interactive() {

if (in_array($useTable, $this->__tables)) {
$tempModel = new Model(array('name' => $currentModelName, 'table' => $useTable, 'ds' => $this->connection));
$fields = $tempModel->schema();
$fields = $tempModel->schema(true);
if (!array_key_exists('id', $fields)) {
$primaryKey = $this->findPrimaryKey($fields);
}
Expand Down Expand Up @@ -447,7 +447,7 @@ function doAssociations(&$model) {
$this->out(__('One moment while the associations are detected.', true));
}

$fields = $model->schema();
$fields = $model->schema(true);
if (empty($fields)) {
return false;
}
Expand Down Expand Up @@ -487,7 +487,7 @@ function doAssociations(&$model) {
* @return array $associations with belongsTo added in.
*/
function findBelongsTo(&$model, $associations) {
$fields = $model->schema();
$fields = $model->schema(true);
foreach ($fields as $fieldName => $field) {
$offset = strpos($fieldName, '_id');
if ($fieldName != $model->primaryKey && $fieldName != 'parent_id' && $offset !== false) {
Expand Down Expand Up @@ -562,7 +562,7 @@ function findHasAndBelongsToMany(&$model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->__tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
$modelFieldsTemp = $tempOtherModel->schema();
$modelFieldsTemp = $tempOtherModel->schema(true);

$offset = strpos($otherTable, $model->table . '_');
$otherOffset = strpos($otherTable, '_' . $model->table);
Expand Down Expand Up @@ -695,7 +695,7 @@ function _generatePossibleKeys() {
$possible = array();
foreach ($this->__tables as $otherTable) {
$tempOtherModel = & new Model(array('table' => $otherTable, 'ds' => $this->connection));
$modelFieldsTemp = $tempOtherModel->schema();
$modelFieldsTemp = $tempOtherModel->schema(true);
foreach ($modelFieldsTemp as $fieldName => $field) {
if ($field['type'] == 'integer' || $field['type'] == 'string') {
$possible[$otherTable][] = $fieldName;
Expand Down Expand Up @@ -821,6 +821,7 @@ function getAllTables($useDbConfig = null) {

$tables = array();
$db =& ConnectionManager::getDataSource($useDbConfig);
$db->cacheSources = false;
$usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix'];
if ($usePrefix) {
foreach ($db->listSources() as $table) {
Expand Down

0 comments on commit ee8ebce

Please sign in to comment.