Skip to content

Commit

Permalink
Wrap integration test in a fake controller
Browse files Browse the repository at this point in the history
  • Loading branch information
asgrim committed Dec 14, 2021
1 parent 9062cfe commit 27bb3b0
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions tests/Integration/AgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,18 +484,23 @@ public function testHttpSpansArePromoted(): void
$httpUrl = 'http://scoutapm.com/robots.txt';
$httpsUrl = 'https://scoutapm.com/robots.txt';

file_get_contents($httpUrl);
file_get_contents($httpsUrl);

$httpCurl = curl_init();
curl_setopt($httpCurl, CURLOPT_URL, $httpUrl);
curl_setopt($httpCurl, CURLOPT_RETURNTRANSFER, true);
curl_exec($httpCurl);

$httpsCurl = curl_init();
curl_setopt($httpsCurl, CURLOPT_URL, $httpsUrl);
curl_setopt($httpsCurl, CURLOPT_RETURNTRANSFER, true);
curl_exec($httpsCurl);
$this->agent->webTransaction(
'TestingHttpSpans',
static function () use ($httpUrl, $httpsUrl): void {
file_get_contents($httpUrl);
file_get_contents($httpsUrl);

$httpCurl = curl_init();
curl_setopt($httpCurl, CURLOPT_URL, $httpUrl);
curl_setopt($httpCurl, CURLOPT_RETURNTRANSFER, true);
curl_exec($httpCurl);

$httpsCurl = curl_init();
curl_setopt($httpsCurl, CURLOPT_URL, $httpsUrl);
curl_setopt($httpsCurl, CURLOPT_RETURNTRANSFER, true);
curl_exec($httpsCurl);
}
);

self::assertTrue($this->agent->send(), 'Failed to send messages. ' . $this->formatCapturedLogMessages());

Expand Down Expand Up @@ -526,11 +531,15 @@ static function (&$commands, string $outerOperation, string $url): void {
static function (array $commands) use ($assertSpanContainingHttpSpan, $httpUrl, $httpsUrl): bool {
TestHelper::assertUnserializedCommandContainsPayload('StartRequest', [], reset($commands), null);

TestHelper::assertUnserializedCommandContainsPayload('StartSpan', ['operation' => 'Controller/TestingHttpSpans'], next($commands), null);

$assertSpanContainingHttpSpan($commands, 'file_get_contents', $httpUrl);
$assertSpanContainingHttpSpan($commands, 'file_get_contents', $httpsUrl);
$assertSpanContainingHttpSpan($commands, 'curl_exec', $httpUrl);
$assertSpanContainingHttpSpan($commands, 'curl_exec', $httpsUrl);

TestHelper::assertUnserializedCommandContainsPayload('StopSpan', [], next($commands), null);

TestHelper::assertUnserializedCommandContainsPayload('TagRequest', ['tag' => 'memory_delta'], next($commands), null);
TestHelper::assertUnserializedCommandContainsPayload('TagRequest', ['tag' => 'path'], next($commands), null);

Expand Down

0 comments on commit 27bb3b0

Please sign in to comment.