Open Journal Systems  3.3.0
ResponseHeaderSame.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
14 use PHPUnit\Framework\Constraint\Constraint;
16 
17 final class ResponseHeaderSame extends Constraint
18 {
19  private $headerName;
20  private $expectedValue;
21 
22  public function __construct(string $headerName, string $expectedValue)
23  {
24  $this->headerName = $headerName;
25  $this->expectedValue = $expectedValue;
26  }
27 
31  public function toString(): string
32  {
33  return sprintf('has header "%s" with value "%s"', $this->headerName, $this->expectedValue);
34  }
35 
41  protected function matches($response): bool
42  {
43  return $this->expectedValue === $response->headers->get($this->headerName, null);
44  }
45 
51  protected function failureDescription($response): string
52  {
53  return 'the Response '.$this->toString();
54  }
55 }
Symfony\Component\HttpFoundation\Response
Definition: lib/vendor/symfony/http-foundation/Response.php:19
Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderSame\matches
matches($response)
Definition: ResponseHeaderSame.php:41
Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderSame\toString
toString()
Definition: ResponseHeaderSame.php:31
Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderSame\__construct
__construct(string $headerName, string $expectedValue)
Definition: ResponseHeaderSame.php:22
Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderSame\failureDescription
failureDescription($response)
Definition: ResponseHeaderSame.php:51
Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderSame
Definition: ResponseHeaderSame.php:17
Symfony\Component\HttpFoundation\Test\Constraint
Definition: RequestAttributeValueSame.php:12