Skip to content

Commit

Permalink
Mock realpath if path argument is a vfs path
Browse files Browse the repository at this point in the history
  • Loading branch information
aaa2000 committed Jul 2, 2016
1 parent 2c5bd9a commit 569813b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Migrations/SqlFileWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private function buildMigrationFilePath()
{
$path = $this->destPath;
if (is_dir($path)) {
$path = realpath($path);
$path = $path . '/doctrine_migration_' . date('YmdHis') . '.sql';
}

Expand Down
21 changes: 21 additions & 0 deletions tests/Doctrine/DBAL/Migrations/Tests/MigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\DBAL\Migrations;

if (!function_exists(__NAMESPACE__ . '\realpath')) {
/**
* Override realpath() in current namespace for testing
*
* @param $path
*
* @return string|false
*/
function realpath($path)
{
// realpath issue with vfsStream
// @see https://github.com/mikey179/vfsStream/wiki/Known-Issues
if (0 === strpos($path, 'vfs://')) {
return $path;
}
return \realpath($path);
}
}

namespace Doctrine\DBAL\Migrations\Tests;

use Doctrine\DBAL\Migrations\Configuration\Configuration;
Expand Down
21 changes: 21 additions & 0 deletions tests/Doctrine/DBAL/Migrations/Tests/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\DBAL\Migrations;

if (!function_exists(__NAMESPACE__ . '\realpath')) {
/**
* Override realpath() in current namespace for testing
*
* @param $path
*
* @return string|false
*/
function realpath($path)
{
// realpath issue with vfsStream
// @see https://github.com/mikey179/vfsStream/wiki/Known-Issues
if (0 === strpos($path, 'vfs://')) {
return $path;
}
return \realpath($path);
}
}

namespace Doctrine\DBAL\Migrations\Tests;

use Doctrine\DBAL\Migrations\MigrationException;
Expand Down

0 comments on commit 569813b

Please sign in to comment.