Skip to content
Permalink
Browse files

Extract table from class logic to method

  • Loading branch information...
fxleblanc committed Feb 4, 2016
1 parent dc2d623 commit 5119690337f3eb511e8bafdd257db05911f2b55a
Showing with 19 additions and 7 deletions.
  1. +19 −7 src/TestSuite/Fixture/TestFixture.php
@@ -134,13 +134,7 @@ public function sourceName()
public function init()
{
if ($this->table === null) {
list(, $class) = namespaceSplit(get_class($this));
preg_match('/^(.*)Fixture$/', $class, $matches);
$table = $class;
if (isset($matches[1])) {
$table = $matches[1];
}
$this->table = Inflector::tableize($table);
$this->table = $this->_tableFromClass();
}
if (empty($this->import) && !empty($this->fields)) {
@@ -156,6 +150,24 @@ public function init()
}
}
/**
* Returns the table name using the fixture class
*
* @return string
*/
protected function _tableFromClass()
{
list(, $class) = namespaceSplit(get_class($this));
preg_match('/^(.*)Fixture$/', $class, $matches);
$table = $class;
if (isset($matches[1])) {
$table = $matches[1];
}
return Inflector::tableize($table);
}
/**
* Build the fixtures table schema from the fields property.
*

0 comments on commit 5119690

Please sign in to comment.
You can’t perform that action at this time.