forked from nategood/httpful
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed call to error_log and added detail exception output from curl…
… execute to capturing exception
- Loading branch information
nick.fox
committed
Nov 22, 2013
1 parent
3d0eb21
commit cd87e6a
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Port over the original tests into a more traditional PHPUnit | ||
* format. Still need to hook into a lightweight HTTP server to | ||
* better test some things (e.g. obscure cURL settings). I've moved | ||
* the old tests and node.js server to the tests/.legacy directory. | ||
* @author nick fox <quixand gmail com> | ||
*/ | ||
namespace Httpful\Test; | ||
|
||
class curlOutputBugTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
/** | ||
* @author Nick Fox | ||
* @expectedException Httpful\Exception\ConnectionErrorException | ||
* @expectedExceptionMessage Unable to connect | ||
*/ | ||
public function testInvalidURLGeneratesUnexpectedOutput() | ||
{ | ||
\Httpful\Request::get('unavailable.url')->send(); | ||
} | ||
|
||
/** | ||
* @author Nick Fox | ||
*/ | ||
public function testInvalidURLGeneratesUnexpectedOutput_catchException() | ||
{ | ||
try { | ||
$output = \Httpful\Request::get('unavailable.url')->send(); | ||
} catch (\Httpful\Exception\ConnectionErrorException $expected) { | ||
$this->assertEquals('Unable to connect: 6 Couldn\'t resolve host \'unavailable.url\'', $expected->getMessage()); | ||
return; | ||
} | ||
$this->fail('An expected exception has not been raised.'); | ||
} | ||
} |
cd87e6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to open this up as a pull request? We'll get it merged in.
cd87e6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK but I'm not sure the test class has the most appropriate name 'curlOutputBugTest'. It was done in bit of a rush. You don't seem to have dedicated test classes and this is testing a specific method of the Request class so perhaps this could be renamed TestRequest? Also those two tests are doing the same thing so one needs to be removed, that was more so you could copy the one you preferred, up to you if you prefer the annotation pattern of phpunit or the try catch? The test method names don't describe the current behavior but rather the unexpected error output I was seeing originally. Let me know which test patten you would prefer and I'll get this all cleaned up