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

contributte / codeception / 4402734265

pending completion
4402734265

push

github

GitHub
Fix netteConnector with phpunit10 (#41)

2 of 2 new or added lines in 1 file covered. (100.0%)

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

76.67
/src/Connector/NetteConnector.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Codeception\Connector;
4

5
use Contributte\Codeception\Http\Request as HttpRequest;
6
use Contributte\Codeception\Http\Response as HttpResponse;
7
use Exception;
8
use Nette\Application\Application;
9
use Nette\DI\Container;
10
use Nette\Http\IRequest;
11
use Nette\Http\IResponse;
12
use Symfony\Component\BrowserKit\AbstractBrowser;
13
use Symfony\Component\BrowserKit\Request;
14
use Symfony\Component\BrowserKit\Response;
15
use Throwable;
16

17
class NetteConnector extends AbstractBrowser
18
{
19

20
        /** @var callable */
21
        protected $containerAccessor;
22

23
        public function setContainerAccessor(callable $containerAccessor): void
24
        {
25
                $this->containerAccessor = $containerAccessor;
×
26
        }
27

28
        /**
29
         * @param Request $request
30
         * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
31
         */
32
        public function doRequest($request): Response
33
        {
34
                $phpSelf = $_SERVER['PHP_SELF'];
4✔
35
                $_COOKIE = $request->getCookies();
4✔
36
                $_SERVER = $request->getServer();
4✔
37
                $_FILES = $request->getFiles();
4✔
38

39
                $_SERVER['PHP_SELF'] = $phpSelf;
4✔
40
                $_SERVER['REQUEST_METHOD'] = $method = strtoupper($request->getMethod());
4✔
41
                $_SERVER['REQUEST_URI'] = str_replace('http://localhost', '', $request->getUri());
4✔
42
                $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
4✔
43

44
                if ($method === 'HEAD' || $method === 'GET') {
4✔
45
                        $_GET = $request->getParameters();
4✔
46
                        $_POST = [];
4✔
47
                } else {
48
                        $_GET = [];
×
49
                        $_POST = $request->getParameters();
×
50
                }
51

52
                /** @var Container $container */
53
                $container = ($this->containerAccessor)();
4✔
54

55
                $httpRequest = $container->getByType(IRequest::class);
4✔
56
                $httpResponse = $container->getByType(IResponse::class);
4✔
57
                if (!$httpRequest instanceof HttpRequest || !$httpResponse instanceof HttpResponse) {
4✔
58
                        throw new Exception('Contributte\Codeception\DI\HttpExtension is not used or conflicts with another extension.');
×
59
                }
60

61
                $httpRequest->reset();
4✔
62
                $httpResponse->reset();
4✔
63

64
                try {
65
                        ob_start();
4✔
66
                        $container->getByType(Application::class)->run();
4✔
67
                        $content = (string) ob_get_clean();
4✔
68
                } catch (Throwable $e) {
×
69
                        ob_end_clean();
×
70
                        throw $e;
×
71
                }
72

73
                $code = $httpResponse->getCode();
4✔
74
                $headers = $httpResponse->getHeaders();
4✔
75

76
                return new Response($content, $code, $headers);
4✔
77
        }
78

79
}
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

© 2026 Coveralls, Inc