Skip to content

Commit

Permalink
Merge pull request #128 from geekish/fix-verbosity
Browse files Browse the repository at this point in the history
Fix Prefetcher output verbosity
  • Loading branch information
hirak committed Nov 24, 2016
2 parents cafe97e + 34683f0 commit abfc45c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Prefetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function fetchAll(IO\IOInterface $io, array $requests)
$successCnt += $result['successCnt'];
$failureCnt += $result['failureCnt'];
foreach ($result['urls'] as $url) {
$io->writeError(" <comment>$successCnt/$totalCnt</comment>:\t$url");
$io->writeError(" <comment>$successCnt/$totalCnt</comment>:\t$url", true, IO\IOInterface::VERBOSE);
}
} while ($multi->remain());
} catch (FetchException $e) {
// do nothing
}

$skippedCnt = $totalCnt - $successCnt - $failureCnt;
$io->writeError(" Finished: <comment>success: $successCnt, skipped: $skippedCnt, failure: $failureCnt, total: $totalCnt</comment>");
$io->writeError(" Finished: <comment>success: $successCnt, skipped: $skippedCnt, failure: $failureCnt, total: $totalCnt</comment>", true, IO\IOInterface::VERBOSE);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/PrefetcherTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Hirak\Prestissimo;

use Composer\IO\IOInterface;
use Prophecy\Argument as arg;

class PrefetcherTest extends \PHPUnit_Framework_TestCase
Expand All @@ -24,7 +25,7 @@ public function testFetchAllOnFailure()
CURLOPT_URL => 'file://uso800.txt',
CURLOPT_FILE => tmpfile(),
));
$this->iop->writeError(" Finished: <comment>success: 0, skipped: 0, failure: 1, total: 1</comment>")->shouldBeCalledTimes(1);
$this->iop->writeError(" Finished: <comment>success: 0, skipped: 0, failure: 1, total: 1</comment>", true, IOInterface::VERBOSE)->shouldBeCalledTimes(1);

$fetcher = new Prefetcher;
$fetcher->fetchAll($this->iop->reveal(), array($reqp->reveal()));
Expand All @@ -39,7 +40,7 @@ public function testFetchAllOnSuccess()
));
$reqp->makeSuccess()->willReturn(null);
$reqp->getMaskedURL()->willReturn('file://' . __DIR__ . '/test.txt');
$this->iop->writeError(arg::type('string'))->shouldBeCalled();
$this->iop->writeError(arg::type('string'), true, IOInterface::VERBOSE)->shouldBeCalled();

$fetcher = new Prefetcher;
$fetcher->fetchAll($this->iop->reveal(), array($reqp->reveal()));
Expand Down

0 comments on commit abfc45c

Please sign in to comment.