File: HeaderTest.php

package info (click to toggle)
php-slim-psr7 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 656 kB
  • sloc: php: 5,274; makefile: 17; sh: 11; xml: 10
file content (61 lines) | stat: -rw-r--r-- 1,530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

/**
 * Slim Framework (https://slimframework.com)
 *
 * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
 */

declare(strict_types=1);

namespace Slim\Tests\Psr7;

use PHPUnit\Framework\TestCase;
use Slim\Psr7\Header;

class HeaderTest extends TestCase
{
    /**
     * Instantiate a default header.
     *
     * @return Header
     */
    protected function headerFactory(): Header
    {
        $originalName = 'ACCEPT';
        $normalizedName = 'accept';
        $values = ['application/json'];

        return new Header($originalName, $normalizedName, $values);
    }

    public function testGetOriginalName(): void
    {
        $header = $this->headerFactory();
        $this->assertEquals('ACCEPT', $header->getOriginalName());
    }

    public function testGetNormalizedName(): void
    {
        $header = $this->headerFactory();
        $this->assertEquals('accept', $header->getNormalizedName());
    }

    public function testAddValue(): void
    {
        $header = $this->headerFactory();
        $header2 = $header->addValue('text/html');

        $this->assertEquals(['application/json', 'text/html'], $header->getValues());
        $this->assertSame($header2, $header);
    }

    public function testAddValuesString(): void
    {
        $header = $this->headerFactory();
        $header2 = $header->addValues('text/html');

        $this->assertEquals(['application/json', 'text/html'], $header->getValues());
        $this->assertSame($header2, $header);
    }
}