Removed some bugs in abstract class, added testcase

This commit is contained in:
2019-05-22 15:26:24 +02:00
parent b3e28d7884
commit b868f0fe86
5 changed files with 103 additions and 8 deletions

View File

@@ -127,7 +127,7 @@ abstract class AbstractCommonClubsModel
{
foreach($this->getFactory()->getAttributes() as $k => $v)
{
if($v['type'] !== 'ref')
if(empty($v['type']) || $v['type'] !== 'ref')
continue;
if(empty($v['ref']))
@@ -148,7 +148,7 @@ abstract class AbstractCommonClubsModel
return $factory->loadById($value);
}
private static const CLASSNAME_MAP = array(
private const CLASSNAME_MAP = array(
);

View File

@@ -62,7 +62,7 @@ abstract class AbstractCommonClubsModelFactory
// }
$q->select('main.id AS id');//->select($columns);
$q->from($this->getTableName(), 'main');
$q->from($this->getTableName() . ' AS main');
// TODO Joins
@@ -72,13 +72,11 @@ abstract class AbstractCommonClubsModelFactory
$db->setQuery($q);
$db->execute();
$it = $db->getIterator();
$rows = $db->loadAssocList();
$ret = array();
while($it->valid())
foreach($rows as $row)
{
$row = $it->current();
$ret[] = $this->generateObject($row);
$it->next();
}
return $ret;
@@ -109,7 +107,7 @@ abstract class AbstractCommonClubsModelFactory
protected function generateObject($row)
{
$obj = $this->generatePlainObject($row['id']);
$obj->marksAsNew(false);
$obj->markAsNew(false);
//unset($row['id']);
//$obj->setValues($row);

View File

@@ -11,4 +11,50 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
return new CommonClubsModelFactoryClub();
}
public function getName()
{
return $this->getValues()['name'];
}
public function getAddress()
{
return $this->getValues()['address'];
}
public function getCity()
{
return $this->getValues()['city'];
}
public function getHomepage()
{
return $this->getValues()['homepage'];
}
public function getMail()
{
return $this->getValues()['mail'];
}
public function getIban()
{
return $this->getValues()['iban'];
}
public function getBic()
{
return $this->getValues()['bic'];
}
public function isCharitable()
{
return $this->getValues()['charitable'];
}
public function getPresident()
{
return $this->getValues()['president'];
}
}