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

contributte / codeception / 7002289178

01 Aug 2023 06:33PM CUT coverage: 55.814% (+1.0%) from 54.857%
7002289178

push

github

f3l1x
fix: universal Nette\Caching\Storages\Journal cleaning (#37)

0 of 1 new or added line in 1 file covered. (0.0%)

96 of 172 relevant lines covered (55.81%)

1.35 hits per line

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

20.83
/src/Module/NetteApplicationModule.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Codeception\Module;
4

5
use Codeception\Lib\Framework;
6
use Codeception\TestInterface;
7
use Contributte\Codeception\Connector\NetteConnector;
8
use Nette\DI\Container;
9
use Nette\Http\IRequest;
10
use Nette\Http\IResponse;
11

12
/**
13
 * @property NetteConnector $client
14
 */
15
class NetteApplicationModule extends Framework
16
{
17

18
        /** @var array<string, mixed>  */
19
        protected array $config = [
20
                'followRedirects' => true,
21
        ];
22

23
        private string $path;
24

25
        /**
26
         * @param array{path?: string} $settings
27
         * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
28
         */
29
        public function _beforeSuite($settings = []): void
30
        {
31
                assert(isset($settings['path']));
×
32

33
                $this->path = $settings['path'];
×
34
        }
35

36
        public function _before(TestInterface $test): void
37
        {
38
                $this->client = new NetteConnector();
×
39
                $this->client->setContainerAccessor(
×
40
                        function (): Container {
×
41
                                /** @var NetteDIModule $diModule */
42
                                $diModule = $this->getModule(NetteDIModule::class);
43

44
                                return $diModule->getContainer();
45
                        }
×
46
                );
×
47
                $this->client->followRedirects((bool) $this->config['followRedirects']);
×
48

49
                parent::_before($test);
×
50
        }
51

52
        public function _after(TestInterface $test): void
53
        {
54
                parent::_after($test);
×
55

56
                $_SESSION = [];
×
57
                $_GET = [];
×
58
                $_POST = [];
×
59
                $_FILES = [];
×
60
                $_COOKIE = [];
×
61
        }
62

63
        public function followRedirects(bool $followRedirects): void
64
        {
65
                $this->client->followRedirects($followRedirects);
×
66
        }
67

68
        public function seeRedirectTo(string $url): void
69
        {
70
                if ($this->client->isFollowingRedirects()) {
1✔
71
                        $this->fail('Method seeRedirectTo only works when followRedirects option is disabled');
×
72
                }
73

74
                /** @var NetteDIModule $diModule */
75
                $diModule = $this->getModule(NetteDIModule::class);
1✔
76
                $request = $diModule->grabService(IRequest::class);
1✔
77
                $response = $diModule->grabService(IResponse::class);
1✔
78
                if ($response->getHeader('Location') !== $request->getUrl()->getHostUrl() . $url && $response->getHeader('Location') !== $url) {
1✔
79
                        $this->fail('Couldn\'t confirm redirect target to be "' . $url . '", Location header contains "' . $response->getHeader('Location') . '".');
×
80
                }
81
        }
82

83
        public function debugContent(): void
84
        {
85
                $this->debugSection('Content', $this->client->getInternalResponse()->getContent());
×
86
        }
87

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