Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from krichprollsch/fix-reverse-mssql-quote
fix #320 reverse engineering : select tablename can returns quoted name ...
- Loading branch information
Showing
2 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
test/testsuite/generator/reverse/mssql/MssqlSchemaParserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Propel package. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @license MIT License | ||
*/ | ||
|
||
require_once dirname(__FILE__) . '/../../../../../generator/lib/reverse/mssql/MssqlSchemaParser.php'; | ||
require_once dirname(__FILE__) . '/../../../../../generator/lib/model/PropelTypes.php'; | ||
|
||
/** | ||
* Tests for Mssql database schema parser. | ||
* | ||
* @author Pierre Tachoire | ||
* @version $Revision$ | ||
* @package propel.generator.reverse.mssql | ||
*/ | ||
class MssqlSchemaParserTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testCleanDelimitedIdentifiers() | ||
{ | ||
$parser = new TestableMssqlSchemaParser(null); | ||
|
||
$expected = 'this is a tablename'; | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); | ||
$this->assertEquals($expected, $tested); | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers('\''.$expected); | ||
$this->assertEquals('\''.$expected, $tested); | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers($expected.'\''); | ||
$this->assertEquals($expected.'\'', $tested); | ||
|
||
$expected = 'this is a tabl\'ename'; | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); | ||
$this->assertEquals($expected, $tested); | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers('\''.$expected); | ||
$this->assertEquals('\''.$expected, $tested); | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers($expected.'\''); | ||
$this->assertEquals($expected.'\'', $tested); | ||
|
||
$expected = 'this is a\'tabl\'ename'; | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); | ||
$this->assertEquals($expected, $tested); | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers('\''.$expected); | ||
$this->assertEquals('\''.$expected, $tested); | ||
|
||
$tested = $parser->cleanDelimitedIdentifiers($expected.'\''); | ||
$this->assertEquals($expected.'\'', $tested); | ||
|
||
} | ||
} | ||
|
||
class TestableMssqlSchemaParser extends MssqlSchemaParser | ||
{ | ||
public function cleanDelimitedIdentifiers($identifier) | ||
{ | ||
return parent::cleanDelimitedIdentifiers($identifier); | ||
} | ||
} |