Skip to content

Commit

Permalink
Updated test for CurlRemoteFilesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
hirak committed Jan 31, 2016
1 parent fe2b1bc commit da30b2f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CurlRemoteFilesystem.php
Expand Up @@ -8,6 +8,7 @@

use Composer\Config;
use Composer\IO;
use Composer\Downloader;
use Composer\Util;

/**
Expand Down
46 changes: 44 additions & 2 deletions tests/unit/CurlRemoteFilesystemTest.php
Expand Up @@ -26,6 +26,15 @@ protected function setUp()
));
}

public static function tearDownAfterClass()
{
$targetFile = 'tests/workspace/target/0.txt';
if (file_exists($targetFile)) {
unlink($targetFile);
rmdir(dirname($targetFile));
}
}

public function testConstruct()
{
self::assertInstanceOf('Hirak\Prestissimo\CurlRemoteFilesystem', $this->rfs);
Expand Down Expand Up @@ -56,12 +65,45 @@ public function testCopy()
rmdir(dirname($targetFile));
}

public function testCopyFailure()
{
$targetUrl = 'http://localhost:1337/?status=404';
$targetFile = 'tests/workspace/target/0.txt';

$this->rfs->copy('localhost', $targetUrl, $targetFile);

self::assertFileNotExists($targetFile);
self::assertFileNotExists(dirname($targetFile));
}

/**
* @expectedException Composer\Downloader\TransportException
*/
public function testCopyPromptAndRetry1()
{
$targetUrl = 'http://localhost:1337/?status=401';
$targetFile = 'tests/workspace/target/0.txt';

$this->rfs->copy('localhost', $targetUrl, $targetFile);
}

/**
* @expectedException Composer\Downloader\TransportException
*/
public function testCopyPromptAndRetry2()
{
$targetUrl = 'http://localhost:1337/?status=403';
$targetFile = 'tests/workspace/target/0.txt';

$this->rfs->copy('localhost', $targetUrl, $targetFile);
}

public function testGetContents()
{
$targetUrl = 'http://localhost:1337/?wait=0';
$targetFile = 'tests/workspace/target/0.txt';

$response = $this->rfs->getContents('localhost', $targetUrl);
$progress = false;
$response = $this->rfs->getContents('localhost', $targetUrl, $progress);

self::assertEquals('0', $response);
}
Expand Down

0 comments on commit da30b2f

Please sign in to comment.