public function testShortenEntityNameReducedHash()
 {
     /** Length of 64 characters, to go over max MySql identifier length */
     $length64 = '________________________________________________________________';
     $longPrefix = 'pre_____________________________________';
     $shortenedName = ExpressionConverter::shortenEntityName($length64 . '_cannotBeAbbreviated', $longPrefix);
     $this->assertNotSame(0, strpos($shortenedName, 'pre'), 'Entity name not supposed to with long prefix');
 }
示例#2
0
 /**
  * Retrieve valid foreign key name
  * Check foreign key name length and allowed symbols
  *
  * @param string $priTableName
  * @param string $priColumnName
  * @param string $refTableName
  * @param string $refColumnName
  * @return string
  */
 public function getForeignKeyName($priTableName, $priColumnName, $refTableName, $refColumnName)
 {
     $prefix = 'fk_';
     $hash = sprintf('%s_%s_%s_%s', $priTableName, $priColumnName, $refTableName, $refColumnName);
     if (strlen($prefix . $hash) > self::LENGTH_FOREIGN_NAME) {
         $short = ExpressionConverter::shortName($prefix . $hash);
         if (strlen($short) > self::LENGTH_FOREIGN_NAME) {
             $hash = md5($hash);
             if (strlen($prefix . $hash) > self::LENGTH_FOREIGN_NAME) {
                 $hash = $this->_minusSuperfluous($hash, $prefix, self::LENGTH_FOREIGN_NAME);
             } else {
                 $hash = $prefix . $hash;
             }
         } else {
             $hash = $short;
         }
     } else {
         $hash = $prefix . $hash;
     }
     return strtoupper($hash);
 }
示例#3
0
 /**
  * Retrieve valid foreign key name
  * Check foreign key name length and allowed symbols
  *
  * @param string $priTableName
  * @param string $priColumnName
  * @param string $refTableName
  * @param string $refColumnName
  * @return string
  * @codeCoverageIgnore
  */
 public function getForeignKeyName($priTableName, $priColumnName, $refTableName, $refColumnName)
 {
     $fkName = sprintf('%s_%s_%s_%s', $priTableName, $priColumnName, $refTableName, $refColumnName);
     return strtoupper(ExpressionConverter::shortenEntityName($fkName, 'fk_'));
 }