/** * Get the column constant name (e.g. TableMapName::COLUMN_NAME). * * @param Column $col The column we need a name for. * @param string $classname The TableMap classname to use. * * @return string If $classname is provided, then will return $classname::COLUMN_NAME; if not, then the TableMapName is looked up for current table to yield $currTableTableMap::COLUMN_NAME. */ public function getColumnConstant($col, $classname = null) { if (null === $col) { throw new InvalidArgumentException('No columns were specified.'); } if (null === $classname) { return $this->getBuildProperty('classPrefix') . $col->getConstantName(); } // was it overridden in schema.xml ? if ($col->getTableMapName()) { $const = strtoupper($col->getTableMapName()); } else { $const = strtoupper($col->getName()); } return $classname . '::' . $const; }
public function testGetConstantName() { $table = $this->getTableMock('article'); $table->expects($this->once())->method('getPhpName')->will($this->returnValue('Article')); $column = new Column('created_at'); $column->setTable($table); $column->setTableMapName('created_at'); $this->assertSame('created_at', $column->getTableMapName()); $this->assertSame('COL_CREATED_AT', $column->getConstantName()); $this->assertSame('ArticleTableMap::COL_CREATED_AT', $column->getFQConstantName()); }