Skip to content

Commit

Permalink
create fixtures for destructible and streamable responses
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Jun 22, 2022
1 parent baae916 commit ab29d18
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Sentry\SentryBundle\Tests\Tracing\HttpClient\Fixtures;

use Symfony\Contracts\HttpClient\ResponseInterface;

interface DestructibleResponseInterface extends ResponseInterface
{
public function __destruct();
}
12 changes: 12 additions & 0 deletions tests/Tracing/HttpClient/Fixtures/StreamableResponseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Sentry\SentryBundle\Tests\Tracing\HttpClient\Fixtures;

use Symfony\Component\HttpClient\Response\StreamableInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;

interface StreamableResponseInterface extends ResponseInterface, StreamableInterface
{
}
12 changes: 4 additions & 8 deletions tests/Tracing/HttpClient/TraceableResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Sentry\SentryBundle\Tests\Tracing\HttpClient\Fixtures\DestructibleResponseInterface;
use Sentry\SentryBundle\Tests\Tracing\HttpClient\Fixtures\StreamableResponseInterface;
use Sentry\SentryBundle\Tracing\HttpClient\TraceableResponse;
use Sentry\State\HubInterface;
use Sentry\Tracing\SpanContext;
Expand Down Expand Up @@ -62,10 +64,7 @@ public function testDestructor(): void
$context = new SpanContext();
$span = $transaction->startChild($context);

$this->mockedResponse = $this->getMockBuilder(ResponseInterface::class)
->addMethods(['__destruct'])
->getMockForAbstractClass();

$this->mockedResponse = $this->createMock(DestructibleResponseInterface::class);
$this->mockedResponse
->expects($this->once())
->method('__destruct');
Expand Down Expand Up @@ -145,10 +144,7 @@ public function testToStream(): void
self::markTestSkipped('Response toStream method is not existent in this version of http-client');
}

$this->mockedResponse = $this->getMockBuilder(ResponseInterface::class)
->addMethods(['toStream'])
->getMockForAbstractClass();

$this->mockedResponse = $this->createMock(StreamableResponseInterface::class);
$this->mockedResponse
->expects($this->once())
->method('toStream')
Expand Down

0 comments on commit ab29d18

Please sign in to comment.