Initial Drupal 11 with DDEV setup
This commit is contained in:
		
							
								
								
									
										45
									
								
								vendor/symfony/http-foundation/Test/Constraint/RequestAttributeValueSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vendor/symfony/http-foundation/Test/Constraint/RequestAttributeValueSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
 | 
			
		||||
final class RequestAttributeValueSame extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private string $name,
 | 
			
		||||
        private string $value,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return \sprintf('has attribute "%s" with value "%s"', $this->name, $this->value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Request $request
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($request): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->value === $request->attributes->get($this->name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Request $request
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($request): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Request '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										70
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseCookieValueSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseCookieValueSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,70 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Cookie;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseCookieValueSame extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private string $name,
 | 
			
		||||
        private string $value,
 | 
			
		||||
        private string $path = '/',
 | 
			
		||||
        private ?string $domain = null,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        $str = \sprintf('has cookie "%s"', $this->name);
 | 
			
		||||
        if ('/' !== $this->path) {
 | 
			
		||||
            $str .= \sprintf(' with path "%s"', $this->path);
 | 
			
		||||
        }
 | 
			
		||||
        if ($this->domain) {
 | 
			
		||||
            $str .= \sprintf(' for domain "%s"', $this->domain);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $str.\sprintf(' with value "%s"', $this->value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        $cookie = $this->getCookie($response);
 | 
			
		||||
        if (!$cookie) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->value === (string) $cookie->getValue();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function getCookie(Response $response): ?Cookie
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = $response->headers->getCookies();
 | 
			
		||||
 | 
			
		||||
        $filteredCookies = array_filter($cookies, fn (Cookie $cookie) => $cookie->getName() === $this->name && $cookie->getPath() === $this->path && $cookie->getDomain() === $this->domain);
 | 
			
		||||
 | 
			
		||||
        return reset($filteredCookies) ?: null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										60
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseFormatSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseFormatSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,60 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Asserts that the response is in the given format.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Kévin Dunglas <dunglas@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
final class ResponseFormatSame extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private Request $request,
 | 
			
		||||
        private ?string $format,
 | 
			
		||||
        private readonly bool $verbose = true,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'format is '.($this->format ?? 'null');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->format === $this->request->getFormat($response->headers->get('Content-Type'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function additionalFailureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHasCookie.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHasCookie.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Cookie;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseHasCookie extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private string $name,
 | 
			
		||||
        private string $path = '/',
 | 
			
		||||
        private ?string $domain = null,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        $str = \sprintf('has cookie "%s"', $this->name);
 | 
			
		||||
        if ('/' !== $this->path) {
 | 
			
		||||
            $str .= \sprintf(' with path "%s"', $this->path);
 | 
			
		||||
        }
 | 
			
		||||
        if ($this->domain) {
 | 
			
		||||
            $str .= \sprintf(' for domain "%s"', $this->domain);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $str;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return null !== $this->getCookie($response);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function getCookie(Response $response): ?Cookie
 | 
			
		||||
    {
 | 
			
		||||
        $cookies = $response->headers->getCookies();
 | 
			
		||||
 | 
			
		||||
        $filteredCookies = array_filter($cookies, fn (Cookie $cookie) => $cookie->getName() === $this->name && $cookie->getPath() === $this->path && $cookie->getDomain() === $this->domain);
 | 
			
		||||
 | 
			
		||||
        return reset($filteredCookies) ?: null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHasHeader.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHasHeader.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseHasHeader extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private string $headerName,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return \sprintf('has header "%s"', $this->headerName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $response->headers->has($this->headerName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										65
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHeaderLocationSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHeaderLocationSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,65 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseHeaderLocationSame extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(private Request $request, private string $expectedValue)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return \sprintf('has header "Location" matching "%s"', $this->expectedValue);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function matches($other): bool
 | 
			
		||||
    {
 | 
			
		||||
        if (!$other instanceof Response) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $location = $other->headers->get('Location');
 | 
			
		||||
 | 
			
		||||
        if (null === $location) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->toFullUrl($this->expectedValue) === $this->toFullUrl($location);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function failureDescription($other): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function toFullUrl(string $url): string
 | 
			
		||||
    {
 | 
			
		||||
        if (null === parse_url($url, \PHP_URL_PATH)) {
 | 
			
		||||
            $url .= '/';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (str_starts_with($url, '//')) {
 | 
			
		||||
            return \sprintf('%s:%s', $this->request->getScheme(), $url);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (str_starts_with($url, '/')) {
 | 
			
		||||
            return $this->request->getSchemeAndHttpHost().$url;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $url;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHeaderSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseHeaderSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseHeaderSame extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private string $headerName,
 | 
			
		||||
        private string $expectedValue,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return \sprintf('has header "%s" with value "%s"', $this->headerName, $this->expectedValue);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->expectedValue === $response->headers->get($this->headerName, null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseIsRedirected.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseIsRedirected.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,54 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseIsRedirected extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param bool $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(private readonly bool $verbose = true)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'is redirected';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $response->isRedirect();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function additionalFailureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseIsSuccessful.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseIsSuccessful.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,54 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseIsSuccessful extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param bool $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(private readonly bool $verbose = true)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'is successful';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $response->isSuccessful();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function additionalFailureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseIsUnprocessable.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseIsUnprocessable.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,54 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseIsUnprocessable extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param bool $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(private readonly bool $verbose = true)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'is unprocessable';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $other
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($other): bool
 | 
			
		||||
    {
 | 
			
		||||
        return Response::HTTP_UNPROCESSABLE_ENTITY === $other->getStatusCode();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $other
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($other): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function additionalFailureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										53
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseStatusCodeSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								vendor/symfony/http-foundation/Test/Constraint/ResponseStatusCodeSame.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view the LICENSE
 | 
			
		||||
 * file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\Constraint\Constraint;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
 | 
			
		||||
final class ResponseStatusCodeSame extends Constraint
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private int $statusCode,
 | 
			
		||||
        private readonly bool $verbose = true,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'status code is '.$this->statusCode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function matches($response): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->statusCode === $response->getStatusCode();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function failureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'the Response '.$this->toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param Response $response
 | 
			
		||||
     */
 | 
			
		||||
    protected function additionalFailureDescription($response): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->verbose ? (string) $response : explode("\r\n\r\n", (string) $response)[0];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user