protected function getColName($phpName, $peerClass = null, $withPeerClass = false, $autoAddJoin = true)
 {
     if (array_key_exists($phpName, $this->withColumns)) {
         return $phpName;
     }
     if (strpos($phpName, '.') !== false) {
         // Table.Column
         list($class, $phpName) = explode('.', $phpName);
         if ($this->hasRelation($class)) {
             $relation = $this->relations[$class];
             $toClass = $relation->getToClass();
             if ($toClass == $class) {
                 // Relation with no alias
                 $peerClass = sfPropelFinderUtils::getPeerClassFromClass($relation->getToClass());
             } else {
                 // Relation with an alias
                 return sfPropelFinderUtils::getColNameUsingAlias($class, $phpName, $toClass, $withPeerClass);
             }
         } elseif ($class == $this->alias) {
             $class = $this->class;
         } else {
             $peerClass = sfPropelFinderUtils::getPeerClassFromClass($class);
         }
     } else {
         if (strpos($phpName, '_') !== false) {
             // Table_Column, or Table_Name_Column, so explode is not a solution here
             $limit = strrpos($phpName, '_');
             $class = substr($phpName, 0, $limit);
             $phpName = substr($phpName, $limit + 1);
             $peerClass = sfPropelFinderUtils::getPeerClassFromClass($class);
         }
     }
     if (!$peerClass) {
         // Column
         $peerClass = $this->peerClass;
     }
     if ($peerClass != $this->peerClass && !$this->hasRelation($class) && $autoAddJoin) {
         $this->join($class);
     }
     try {
         $column = call_user_func(array($peerClass, 'translateFieldName'), ucfirst($phpName), BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
         return $withPeerClass ? array($peerClass, $column) : $column;
     } catch (PropelException $e) {
         throw new Exception(sprintf('sfPropelFinder: %s has no %s column', $peerClass, $phpName));
     }
 }
        category_id: ~
      article_i18n:
        content:     varchar(255)
      category:
        id:          ~
        name:        varchar(255)
      comment:
        id:          ~
        content:     varchar(255)
        article_id:  ~
        author_id:   ~
      author:
        id:          ~
        name:        varchar(255)

Beware that the tables for these models will be emptied by the tests, so use a test database connection.
*/

include dirname(__FILE__).'/../../bootstrap.php';

$t = new lime_test(3, new lime_output_color());

$t->diag('sfPropelFinderUtils::getColNameUsingAlias()');

$col = sfPropelFinderUtils::getColNameUsingAlias('foo', 'Title', 'Article');
$t->is($col, 'foo.TITLE', 'getColNameUsingAlias() returns the correct colname when the columnname is simple');
$col = sfPropelFinderUtils::getColNameUsingAlias('c', 'ArticleId', 'Comment');
$t->is($col, 'c.ARTICLE_ID', 'getColNameUsingAlias() returns the correct colname when the column name is CamelCased');
$col = sfPropelFinderUtils::getColNameUsingAlias('Comment', 'ArticleId', 'Comment');
$t->is($col, 'Comment.ARTICLE_ID', 'getColNameUsingAlias() returns the correct colname even when the alias and the main class are the same');