Skip to content

Commit

Permalink
Merge pull request #11505 from creative-commoners/pulls/6.0/major-dep
Browse files Browse the repository at this point in the history
DEP Require psr/http-message ^2.0
  • Loading branch information
GuySartorelli authored Dec 11, 2024
2 parents a4028d0 + 9dde201 commit 4cdd203
Showing 5 changed files with 147 additions and 54 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
"monolog/monolog": "^3.8",
"nikic/php-parser": "^5.3",
"psr/container": "^2.0",
"psr/http-message": "^1",
"psr/http-message": "^2.0",
"sebastian/diff": "^6.0",
"sensiolabs/ansi-to-html": "^1.2",
"silverstripe/config": "^3",
43 changes: 26 additions & 17 deletions tests/php/View/Embed/MockRequest.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UriInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\MessageInterface;

class MockRequest implements RequestInterface
{
@@ -17,80 +18,88 @@ public function __construct(EmbedUnitTest $unitTest, MockUri $mockUri)
$this->mockUri = $mockUri;
}

public function getRequestTarget()
public function getRequestTarget(): string
{
return '';
}

public function getMethod()
public function getMethod(): string
{
return '';
}

public function getUri()
public function getUri(): UriInterface
{
$this->unitTest->setFirstRequest(false);
return $this->mockUri;
}

public function getProtocolVersion()
public function getProtocolVersion(): string
{
return '';
}

public function getHeaders()
public function getHeaders(): array
{
return [];
}

public function getHeader($name)
public function getHeader($name): array
{
return [];
}

public function getHeaderLine($name)
public function getHeaderLine($name): string
{
return '';
}

public function getBody()
public function getBody(): StreamInterface
{
return MockUtil::createStreamInterface('');
}

public function hasHeader($name)
public function hasHeader($name): bool
{
return false;
}

public function withHeader($name, $value)
public function withHeader($name, $value): MessageInterface
{
return $this;
}

public function withAddedHeader($name, $value)
public function withAddedHeader($name, $value): MessageInterface
{
return $this;
}

public function withoutHeader($name)
public function withoutHeader($name): MessageInterface
{
return $this;
}

public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body): MessageInterface
{
return $this;
}

public function withProtocolVersion($version)
public function withProtocolVersion($version): MessageInterface
{
return $this;
}

public function withRequestTarget($requestTarget)
public function withRequestTarget($requestTarget): RequestInterface
{
return $this;
}

public function withMethod($method)
public function withMethod($method): RequestInterface
{
return $this;
}

public function withUri(UriInterface $uri, $preserveHost = false)
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
{
return $this;
}
35 changes: 18 additions & 17 deletions tests/php/View/Embed/MockResponse.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\MessageInterface;

class MockResponse implements ResponseInterface
{
@@ -18,78 +19,78 @@ public function __construct(EmbedUnitTest $unitTest, string $firstResponse, stri
$this->secondResponse = $secondResponse;
}

public function getStatusCode()
public function getStatusCode(): int
{
return 200;
}

public function getBody()
public function getBody(): StreamInterface
{
// first request is to the video HTML to get to find the oembed link
// second request is to the oembed endpoint to fetch JSON
if ($this->unitTest->getFirstRequest()) {
return $this->firstResponse;
return MockUtil::createStreamInterface($this->firstResponse);
} else {
return $this->secondResponse;
return MockUtil::createStreamInterface($this->secondResponse);
}
}

public function getReasonPhrase()
public function getReasonPhrase(): string
{
return '';
}

public function getProtocolVersion()
public function getProtocolVersion(): string
{
return '';
}

public function getHeaders()
public function getHeaders(): array
{
return [];
}

public function getHeader($name)
public function getHeader($name): array
{
return '';
return [];
}

public function getHeaderLine($name)
public function getHeaderLine($name): string
{
return '';
}

public function hasHeader($name)
public function hasHeader($name): bool
{
return false;
}

public function withHeader($name, $value)
public function withHeader($name, $value): MessageInterface
{
return $this;
}

public function withAddedHeader($name, $value)
public function withAddedHeader($name, $value): MessageInterface
{
return $this;
}

public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body): MessageInterface
{
return $this;
}

public function withoutHeader($name)
public function withoutHeader($name): MessageInterface
{
return $this;
}

public function withProtocolVersion($version)
public function withProtocolVersion($version): MessageInterface
{
return $this;
}

public function withStatus($code, $reasonPhrase = '')
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
{
return $this;
}
42 changes: 23 additions & 19 deletions tests/php/View/Embed/MockUri.php
Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@

class MockUri implements UriInterface, Stringable
{
private string $scheme;
private string $host;
private string $path;
private string $query;
private string $scheme = '';
private string $host = '';
private string $path = '';
private string $query = '';

public function __construct(string $url)
{
@@ -21,73 +21,77 @@ public function __construct(string $url)
$this->query = $p['query'] ?? '';
}

public function getScheme()
public function getScheme(): string
{
return $this->scheme;
}

public function getHost()
public function getHost(): string
{
return $this->host;
}

public function getPath()
public function getPath(): string
{
return $this->path;
}

public function getQuery()
public function getQuery(): string
{
return $this->query;
}

public function getPort()
public function getPort(): ?int
{
return null;
}

public function getAuthority()
public function getAuthority(): string
{
return '';
}

public function getUserInfo()
public function getUserInfo(): string
{
return '';
}

public function getFragment()
public function getFragment(): string
{
return '';
}

public function withPath($path)
public function withPath($path): UriInterface
{
return $this;
}

public function withScheme($scheme)
public function withScheme($scheme): UriInterface
{
return $this;
}

public function withUserInfo($user, $password = null)
public function withUserInfo($user, $password = null): UriInterface
{
return $this;
}

public function withHost($host)
public function withHost($host): UriInterface
{
return $this;
}

public function withPort($port)
public function withPort($port): UriInterface
{
return $this;
}

public function withQuery($query)
public function withQuery($query): UriInterface
{
return $this;
}

public function withFragment($fragment)
public function withFragment($fragment): UriInterface
{
return $this;
}
Loading

0 comments on commit 4cdd203

Please sign in to comment.