• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

contributte / codeception / 5505700945

pending completion
5505700945

push

github

web-flow
Fix for 8.2 (#42)

96 of 175 relevant lines covered (54.86%)

1.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/src/Http/Response.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Codeception\Http;
4

5
use DateTimeInterface;
6
use Nette\Http\Helpers;
7
use Nette\Http\IResponse;
8
use Nette\Utils\DateTime;
9

10
/**
11
 * HttpResponse class for tests.
12
 */
13
class Response implements IResponse
14
{
15

16
        /** @var string The domain in which the cookie will be available */
17
        public $cookieDomain = '';
18

19
        /** @var string The path in which the cookie will be available */
20
        public $cookiePath = '/';
21

22
        /** @var bool Whether the cookie is available only through HTTPS */
23
        public $cookieSecure = false;
24

25
        /** @var int */
26
        private $code = self::S200_OK;
27

28
        /** @var string[] */
29
        private $headers = [];
30

31
        public function reset(): void
32
        {
33
                $this->code = self::S200_OK;
4✔
34
                $this->headers = [];
4✔
35
        }
36

37
        public function getCode(): int
38
        {
39
                return $this->code;
4✔
40
        }
41

42
        /**
43
         * @return static
44
         */
45
        public function setCode(int $code, ?string $reason = null)
46
        {
47
                $this->code = $code;
2✔
48
                return $this;
2✔
49
        }
50

51
        /**
52
         * @return static
53
         */
54
        public function setHeader(string $name, string $value)
55
        {
56
                $this->headers[$name] = $value;
2✔
57
                return $this;
2✔
58
        }
59

60
        /**
61
         * @return static
62
         */
63
        public function addHeader(string $name, string $value)
64
        {
65
                $this->headers[$name] = $value;
4✔
66
                return $this;
4✔
67
        }
68

69
        /**
70
         * @return static
71
         */
72
        public function setContentType(string $type, ?string $charset = null)
73
        {
74
                $this->setHeader('Content-Type', $type . ($charset !== null ? '; charset=' . $charset : ''));
×
75
                return $this;
×
76
        }
77

78
        public function redirect(string $url, int $code = self::S302_Found): void
79
        {
80
                $this->setCode($code);
1✔
81
                $this->setHeader('Location', $url);
1✔
82
        }
83

84
        /**
85
         * @return static
86
         */
87
        public function setExpiration(?string $time)
88
        {
89
                if (!$time) {
×
90
                        $this->setHeader('Cache-Control', 's-maxage=0, max-age=0, must-revalidate');
×
91
                        $this->setHeader('Expires', 'Mon, 23 Jan 1978 10:00:00 GMT');
×
92

93
                        return $this;
×
94
                }
95

96
                $time = DateTime::from($time);
×
97
                $this->setHeader('Cache-Control', 'max-age=' . ((int) $time->format('U') - time()));
×
98
                $this->setHeader('Expires', Helpers::formatDate($time));
×
99

100
                return $this;
×
101
        }
102

103
        public function isSent(): bool
104
        {
105
                return false;
4✔
106
        }
107

108
        public function getHeader(string $name): ?string
109
        {
110
                return $this->headers[$name] ?? null;
4✔
111
        }
112

113
        /**
114
         * @return string[]
115
         */
116
        public function getHeaders(): array
117
        {
118
                return $this->headers;
4✔
119
        }
120

121
        /**
122
         * @param string|int|DateTimeInterface $time
123
         * @return static
124
         */
125
        public function setCookie(string $name, string $value, $time, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null)
126
        {
127
                return $this;
1✔
128
        }
129

130
        public function deleteCookie(string $name, ?string $path = null, ?string $domain = null, ?bool $secure = null): void
131
        {
132
        }
133

134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc