Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with incompatible backups causing fatal errors #43

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Patch/Backup/BackupFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Meteor\Configuration\Exception\ConfigurationLoadingException;
use Meteor\Package\PackageConstants;
use Meteor\Patch\Version\VersionComparer;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

class BackupFinder
{
Expand Down Expand Up @@ -67,6 +68,8 @@ public function find($installDir, array $config)
}
} catch (ConfigurationLoadingException $exception) {
// Not a valid backup
} catch (InvalidConfigurationException $exception) {
// Unable to parse config
}
}

Expand Down
31 changes: 31 additions & 0 deletions tests/Patch/Backup/BackupFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Meteor\Configuration\Exception\ConfigurationLoadingException;
use Meteor\Patch\Version\VersionComparer;
use Mockery;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use org\bovigo\vfs\vfsStream;

class BackupFinderTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -95,6 +96,36 @@ public function testFindIgnoresBackupsWithoutMeteorConfig()
$this->assertCount(0, $backups);
}

public function testFindIgnoresBackupsWithAnInvalidMeteorConfig()
{
$config = array(
'name' => 'jadu/cms',
'package' => array(
'version' => 'VERSION',
),
);

vfsStream::setup('root', null, array(
'backups' => array(
'20160701102030' => array(
'to_patch' => array(
'VERSION' => '1.0.0',
),
),
),
'VERSION' => '1.1.0',
));

$this->configurationLoader->shouldReceive('load')
->with(vfsStream::url('root/backups/20160701102030'))
->andThrow(new InvalidConfigurationException())
->once();

$backups = $this->backupFinder->find(vfsStream::url('root'), $config);

$this->assertCount(0, $backups);
}

public function testFindWithCombinedPackages()
{
$config = array(
Expand Down