From ed9fcc5074f04fe3f108467ff367481f30de1a34 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 19 Oct 2012 12:25:53 +0200 Subject: [PATCH] Fix tests --- .../Test/Downloader/GitDownloaderTest.php | 7 ++++- .../Test/Util/RemoteFilesystemTest.php | 30 +++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index feb009b1e..3df4f5242 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -68,10 +68,15 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase $processExecutor->expects($this->at(1)) ->method('execute') - ->with($this->equalTo($this->getCmd("git checkout 'master'")), $this->equalTo(null), $this->equalTo('composerPath')) + ->with($this->equalTo($this->getCmd("git branch -r")), $this->equalTo(null), $this->equalTo('composerPath')) ->will($this->returnValue(0)); $processExecutor->expects($this->at(2)) + ->method('execute') + ->with($this->equalTo($this->getCmd("git checkout 'master'")), $this->equalTo(null), $this->equalTo('composerPath')) + ->will($this->returnValue(0)); + + $processExecutor->expects($this->at(3)) ->method('execute') ->with($this->equalTo($this->getCmd("git reset --hard '1234567890123456789012345678901234567890'")), $this->equalTo(null), $this->equalTo('composerPath')) ->will($this->returnValue(0)); diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index def4b14c4..90362c8f4 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -26,7 +26,15 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase ; $res = $this->callGetOptionsForUrl($io, array('http://example.org', array())); - $this->assertTrue(isset($res['http']['header']) && false !== strpos($res['http']['header'], 'User-Agent'), 'getOptions must return an array with a header containing a User-Agent'); + $this->assertTrue(isset($res['http']['header']) && is_array($res['http']['header']), 'getOptions must return an array with headers'); + $found = false; + foreach ($res['http']['header'] as $header) { + if (0 === strpos($header, 'User-Agent:')) { + $found = true; + } + } + + $this->assertTrue($found, 'getOptions must have a User-Agent header'); } public function testGetOptionsForUrlWithAuthorization() @@ -44,7 +52,14 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase ; $options = $this->callGetOptionsForUrl($io, array('http://example.org', array())); - $this->assertContains('Authorization: Basic', $options['http']['header']); + + $found = false; + foreach ($options['http']['header'] as $header) { + if (0 === strpos($header, 'Authorization: Basic')) { + $found = true; + } + } + $this->assertTrue($found, 'getOptions must have an Authorization header'); } public function testGetOptionsForUrlWithStreamOptions() @@ -79,7 +94,16 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase $res = $this->callGetOptionsForUrl($io, array('https://example.org', $streamOptions)); $this->assertTrue(isset($res['http']['header']), 'getOptions must return an array with a http.header key'); - $this->assertGreaterThan(strlen('Foo: bar'), strlen($res['http']['header'])); + + $found = false; + foreach ($res['http']['header'] as $header) { + if ($header === 'Foo: bar') { + $found = true; + } + } + + $this->assertTrue($found, 'getOptions must have a Foo: bar header'); + $this->assertGreaterThan(1, count($res['http']['header'])); } public function testCallbackGetFileSize()