Skip to content

Commit

Permalink
added test for config.fxp-asset.git-skip-update
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed Feb 28, 2017
1 parent 0346ef0 commit 7a62259
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Tests/Repository/Vcs/GitDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,61 @@ public function testPublicRepositoryWithEmptyComposer($type, $filename)
$this->assertSame($validEmpty, $gitDriver->getComposerInformation($identifier));
}

/**
* @dataProvider getAssetTypes
*
* @param string $type
* @param string $filename
*/
public function testPublicRepositoryWithSkipUpdate($type, $filename)
{
$repoUrl = 'https://github.com/fxpio/composer-asset-plugin.git';
$identifier = '92bebbfdcde75ef2368317830e54b605bc938123';
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();

$this->config->merge(array(
'config' => array(
'git-skip-update' => '1 week',
),
));

$repoConfig = array(
'url' => $repoUrl,
'asset-type' => $type,
'filename' => $filename,
);

$process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$process->expects($this->any())
->method('splitLines')
->will($this->returnValue(array()));
$process->expects($this->any())
->method('execute')
->will($this->returnCallback(function ($command, &$output = null) use ($identifier, $repoConfig) {
if ($command === sprintf('git show %s', sprintf('%s:%s', escapeshellarg($identifier), $repoConfig['filename']))) {
$output = '{"name": "foo"}';
} elseif (false !== strpos($command, 'git log')) {
$date = new \DateTime(null, new \DateTimeZone('UTC'));
$output = $date->getTimestamp();
}

return 0;
}));

/* @var IOInterface $io */
/* @var ProcessExecutor $process */

$gitDriver = new GitDriver($repoConfig, $io, $this->config, $process, null);
$gitDriver->initialize();

$validEmpty = array(
'_nonexistent_package' => true,
);

$this->assertNotNull($gitDriver->getComposerInformation($identifier));
$this->assertNotSame($validEmpty, $gitDriver->getComposerInformation($identifier));
}

/**
* @dataProvider getAssetTypes
*
Expand Down

0 comments on commit 7a62259

Please sign in to comment.