Skip to content

Commit

Permalink
Allow debug() to provide current fields instead of all content.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Oct 25, 2017
1 parent bb904d4 commit 66a424b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Database/Schema/TableSchema.php
Expand Up @@ -834,6 +834,33 @@ public function dropConstraintSql(Connection $connection)

return $dialect->dropConstraintSql($this);
}

/**
* Returns an array of the table schema.
*
* @return array
*/
public function toArray()
{
return [
'columns' => $this->_columns,
'indexes' => $this->_indexes,
'constraints' => $this->_constraints,
'options' => $this->_options,
'typeMap' => $this->_typeMap,
'temporary' => $this->_temporary,
];
}

/**
* Returns an array of the table schema.
*
* @return array
*/
public function __debugInfo()
{
return $this->toArray();
}
}

// @deprecated Add backwards compat alias.
Expand Down
42 changes: 42 additions & 0 deletions tests/TestCase/Database/Schema/TableTest.php
Expand Up @@ -662,6 +662,48 @@ public function testTemporary()
$this->assertFalse($table->temporary());
}

/**
* Tests the toArray() method.
*
* @return void
*/
public function testToArray()
{
$table = new Table('articles');
$result = $table->toArray();
$expected = [
'columns' => [],
'indexes' => [],
'constraints' => [],
'options' => [],
'typeMap' => [],
'temporary' => false,
];
$this->assertSame($expected, $result);
}

/**
* Tests the __debugInfo() method.
*
* @return void
*/
public function testDebugInfo()
{
$table = new Table('articles');
$table->setTemporary(true);

$result = $table->__debugInfo();
$expected = [
'columns' => [],
'indexes' => [],
'constraints' => [],
'options' => [],
'typeMap' => [],
'temporary' => true,
];
$this->assertSame($expected, $result);
}

/**
* Assertion for comparing a regex pattern against a query having its identifiers
* quoted. It accepts queries quoted with the characters `<` and `>`. If the third
Expand Down

0 comments on commit 66a424b

Please sign in to comment.