-
Notifications
You must be signed in to change notification settings - Fork 50
TypeError: Argument 1 passed to ProfileClient::collectExceptionInformations() must be an instance of Exception #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
use Http\Promise\FulfilledPromise; | ||
use Http\Promise\Promise; | ||
use Http\Promise\RejectedPromise; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
@@ -34,7 +35,7 @@ class ProfileClientTest extends TestCase | |
private $activeStack; | ||
|
||
/** | ||
* @var HttpClient | ||
* @var HttpClient|MockObject | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right. just a comment, no need to change anything now: i have seen the syntax There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, it's right, PhpStorm don't suggest any method of MockObject so I should to add this, |
||
*/ | ||
private $client; | ||
|
||
|
@@ -44,7 +45,7 @@ class ProfileClientTest extends TestCase | |
private $request; | ||
|
||
/** | ||
* @var Formatter | ||
* @var Formatter|MockObject | ||
*/ | ||
private $formatter; | ||
|
||
|
@@ -110,11 +111,6 @@ public function setUp(): void | |
->with($this->response) | ||
->willReturn('FormattedResponse') | ||
; | ||
$this->formatter | ||
->method('formatException') | ||
->with($this->exception) | ||
->willReturn('FormattedException') | ||
; | ||
|
||
$this->stopwatch | ||
->method('start') | ||
|
@@ -145,6 +141,26 @@ public function testSendRequest(): void | |
$this->assertEquals('https', $this->activeStack->getRequestScheme()); | ||
} | ||
|
||
/** | ||
* @expectedException \Error | ||
* @expectedException "You set string to int prop" | ||
*/ | ||
public function testSendRequestTypeError() | ||
{ | ||
$this->client | ||
->expects($this->once()) | ||
->method('sendRequest') | ||
->willReturnCallback(function () { | ||
throw new \Error('You set string to int prop'); | ||
}); | ||
$this->formatter | ||
->expects($this->once()) | ||
->method('formatException') | ||
->with($this->isInstanceOf(\Error::class)); | ||
|
||
$this->subject->sendRequest($this->request); | ||
} | ||
|
||
public function testSendAsyncRequest(): void | ||
{ | ||
$this->client | ||
|
@@ -211,6 +227,12 @@ public function testOnRejected(): void | |
->willReturn($this->rejectedPromise) | ||
; | ||
|
||
$this->formatter | ||
->method('formatException') | ||
->with($this->exception) | ||
->willReturn('FormattedException') | ||
; | ||
|
||
$this->subject->sendAsyncRequest($this->request); | ||
|
||
$this->assertEquals(42, $this->activeStack->getDuration()); | ||
|
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.
This is not a BC break because the class is internal.
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.
even more, Throwable is wide variation of Exception, so no BC break will happen
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.
Yes. But that reason alone is still a BC break because the class is not final.