Skip to content

Commit

Permalink
- Fixed #16042: ezcTemplateTranslationExtractor::unifyFilepath() chop…
Browse files Browse the repository at this point in the history
…s off

  character


git-svn-id: http://svn.ez.no/svn/ezcomponents/trunk@11373 bc0e7bdc-f0fc-0310-8ff6-f601c06e1256
  • Loading branch information
kn committed Feb 12, 2010
1 parent 9b32e67 commit 0a8d038
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
7 changes: 7 additions & 0 deletions TemplateTranslationTiein/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.1.1 - [RELEASEDATE]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fixed #16042: ezcTemplateTranslationExtractor::unifyFilepath() chops off
character


1.1 - Monday 29 June 2009
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
3 changes: 2 additions & 1 deletion TemplateTranslationTiein/src/extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ function getTranslationsFromTsFile( $contextName )
*/
function unifyFilepath( $pathname, $templatePath )
{
return str_replace( '\\', '/', substr( $pathname, strlen( $templatePath ) + 1 ) );
$file = str_replace( '\\', '/', substr( $pathname, strlen( $templatePath ) ) );
return $file[0] === '/' ? substr( $file, 1 ) : $file;
}

/**
Expand Down
44 changes: 44 additions & 0 deletions TemplateTranslationTiein/tests/extracter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,50 @@ function testExtracterWithQuotes()
);
}

function testUnifyFileName()
{
ob_start();
$extractor = new ezcTemplateTranslationExtractor();
ob_end_clean();
$this->assertSame(
'foo.txt',
$extractor->unifyFilepath( '/path/to/foo.txt', '/path/to' )
);
}

function testUnifyFileNameTrailingSlash()
{
ob_start();
$extractor = new ezcTemplateTranslationExtractor();
ob_end_clean();
$this->assertSame(
'foo.txt',
$extractor->unifyFilepath( '/path/to/foo.txt', '/path/to/' )
);
}

function testUnifyFileNameSubDir()
{
ob_start();
$extractor = new ezcTemplateTranslationExtractor();
ob_end_clean();
$this->assertSame(
'bar/foo.txt',
$extractor->unifyFilepath( '/path/to/bar/foo.txt', '/path/to/' )
);
}

function testUnifyFileNameWin()
{
ob_start();
$extractor = new ezcTemplateTranslationExtractor();
ob_end_clean();
$this->assertSame(
'foo.txt',
$extractor->unifyFilepath( '\\path\\to\\foo.txt', '\\path\\to' )
);
}

public static function suite()
{
return new PHPUnit_Framework_TestSuite( 'ezcTemplateTranslationExtracterTest' );
Expand Down

0 comments on commit 0a8d038

Please sign in to comment.