1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the doyo/code-coverage project. |
5
|
|
|
* |
6
|
|
|
* (c) Anthonius Munthi <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Doyo\Bridge\CodeCoverage\Session; |
15
|
|
|
|
16
|
|
|
use Doyo\Bridge\CodeCoverage\ContainerFactory; |
17
|
|
|
use Doyo\Bridge\CodeCoverage\Driver\Dummy; |
18
|
|
|
use Doyo\Bridge\CodeCoverage\Exception\SessionException; |
19
|
|
|
use Doyo\Bridge\CodeCoverage\Processor; |
20
|
|
|
use Doyo\Bridge\CodeCoverage\TestCase; |
21
|
|
|
use SebastianBergmann\CodeCoverage\Filter; |
22
|
|
|
|
23
|
|
|
class RemoteSession extends AbstractSession |
24
|
|
|
{ |
25
|
|
|
const HEADER_SESSION_KEY = 'HTTP_DOYO_COVERAGE_SESSION'; |
26
|
|
|
const HEADER_TEST_CASE_KEY = 'HTTP_DOYO_COVERAGE_TESTCASE'; |
27
|
|
|
|
28
|
|
|
public static function startSession() |
29
|
|
|
{ |
30
|
|
|
if (!isset($_SERVER[static::HEADER_SESSION_KEY])) { |
31
|
|
|
return false; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$name = $_SERVER[static::HEADER_SESSION_KEY]; |
35
|
|
|
$session = new static($name); |
36
|
|
|
|
37
|
|
|
if (isset($_SERVER[static::HEADER_TEST_CASE_KEY])) { |
38
|
|
|
$session->doStartSession(); |
39
|
|
|
} else { |
40
|
|
|
return false; |
41
|
|
|
} |
42
|
|
|
$session->save(); |
43
|
|
|
|
44
|
|
|
return true; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function doStartSession() |
48
|
|
|
{ |
49
|
|
|
$name = $_SERVER[static::HEADER_TEST_CASE_KEY]; |
50
|
|
|
$testCase = new TestCase($name); |
51
|
|
|
$this->setTestCase($testCase); |
52
|
|
|
|
53
|
|
|
try { |
54
|
|
|
$this->start(); |
55
|
|
|
register_shutdown_function([$this, 'shutdown']); |
56
|
|
|
} catch (\Exception $e) { |
57
|
|
|
$this->reset(); |
58
|
|
|
$this->exceptions[] = $e; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|