Skip to content

Commit

Permalink
(Refactor): Move updateHash() and loadGitignore() to update()
Browse files Browse the repository at this point in the history
To minimise duplication.
  • Loading branch information
RobjS authored and dgmstuart committed Feb 10, 2017
1 parent 8caec0e commit 8d47603
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Dependencies/Updater.php
Expand Up @@ -59,6 +59,8 @@ public function updateAll()

private function update(array $dependencies)
{
$this->updateHash();
$this->loadGitignore();
$count = 0;
foreach ($dependencies as $type => $typeDependencies) {
foreach ($typeDependencies as $dep) {
Expand All @@ -84,8 +86,6 @@ private function prepareForUpdate()
if ($result->isErr()) {
return $result;
}
$this->updateHash();
$this->loadGitignore();
return \Result\Result::ok();
}

Expand Down
6 changes: 3 additions & 3 deletions tests/dependencies/updater_test.php
Expand Up @@ -26,7 +26,7 @@ private function getGitignore(array $get, array $save, /* bool */ $saveIgnores,
return $gitignore;
}

private function getWhippetLockWritable(array $addDependency, /* string */ $hash, /* string */ $path, array $getDependencies)
private function getWhippetLockWritable(array $addDependency, /* string */ $hash, /* string */ $path, array $getDependencies, /* boolean */ $setHash = true)
{
$whippetLock = $this->getMockBuilder('\\Dxw\\Whippet\\Files\\WhippetLock')
->disableOriginalConstructor()
Expand All @@ -41,7 +41,7 @@ private function getWhippetLockWritable(array $addDependency, /* string */ $hash
$addDependency
);

$whippetLock->expects($this->exactly(1))
$whippetLock->expects($this->exactly($setHash === true ? 1 : 0))
->method('setHash')
->with($hash);

Expand Down Expand Up @@ -683,7 +683,7 @@ public function testUpdateSingleNoMatch()
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetJson', 'fromFile', $dir.'/whippet.json', \Result\Result::ok($whippetJson));


$whippetLock = $this->getWhippetLockWritable([], sha1('foobar'), null, []);
$whippetLock = $this->getWhippetLockWritable([], sha1('foobar'), null, [], false);
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
Expand Down

0 comments on commit 8d47603

Please sign in to comment.