Completed
Pull Request — master (#365)
by Alessandro
13:08
created

WebServerListener::addIncompleteTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 3
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 3
loc 3
rs 10
c 1
b 0
f 0
cc 1
eloc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCache package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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
namespace FOS\HttpCache\Test\Legacy;
13
14
use FOS\HttpCache\Test\WebServerListenerTrait;
15
16
/**
17
 * A PHPUnit test listener that starts and stops the PHP built-in web server.
18
 *
19
 * This listener is configured with a couple of constants from the phpunit.xml
20
 * file. To define constants in the phpunit file, use this syntax:
21
 * <php>
22
 *     <const name="WEB_SERVER_HOSTNAME" value="localhost" />
23
 * </php>
24
 *
25
 * WEB_SERVER_HOSTNAME host name of the web server (required)
26
 * WEB_SERVER_PORT     port to listen on (required)
27
 * WEB_SERVER_DOCROOT  path to the document root for the server (required)
28
 */
29 View Code Duplication
class WebServerListener implements \PHPUnit_Framework_TestListener
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
{
31
    /** @var WebServerListenerTrait */
32
    private $trait;
33
34
    public function __construct()
35
    {
36
        $this->trait = new WebServerListenerTrait();
37
    }
38
39
    /**
40
     * Make sure the PHP built-in web server is running for tests with group
41
     * 'webserver'.
42
     */
43
    public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
44
    {
45
        $this->trait->startTestSuite($suite);
46
    }
47
48
    /**
49
     *  We don't need these.
50
     */
51
    public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
52
    {
53
    }
54
55
    public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
56
    {
57
    }
58
59
    public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
60
    {
61
    }
62
63
    public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
64
    {
65
    }
66
67
    public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
68
    {
69
    }
70
71
    public function startTest(\PHPUnit_Framework_Test $test)
72
    {
73
    }
74
75
    public function endTest(\PHPUnit_Framework_Test $test, $time)
76
    {
77
    }
78
79
    public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
80
    {
81
    }
82
83
    /**
84
     * Get web server hostname.
85
     *
86
     * @throws \Exception
87
     *
88
     * @return string
89
     */
90
    protected function getHostName()
91
    {
92
        return $this->trait->getHostName();
93
    }
94
95
    /**
96
     * Get web server port.
97
     *
98
     * @throws \Exception
99
     *
100
     * @return int
101
     */
102
    protected function getPort()
103
    {
104
        return $this->trait->getPort();
105
    }
106
107
    /**
108
     * Get web server port.
109
     *
110
     * @throws \Exception
111
     *
112
     * @return int
113
     */
114
    protected function getDocRoot()
115
    {
116
        return $this->trait->getDocRoot();
117
    }
118
119
    /**
120
     * Start PHP built-in web server.
121
     *
122
     * @return int PID
123
     */
124
    protected function startPhpWebServer()
125
    {
126
        return $this->trait->startPhpWebServer();
127
    }
128
129
    /**
130
     * Wait for caching proxy to be started up and reachable.
131
     *
132
     * @param string $ip
133
     * @param int    $port
134
     * @param int    $timeout Timeout in milliseconds
135
     *
136
     * @throws \RuntimeException If proxy is not reachable within timeout
137
     */
138
    protected function waitFor($ip, $port, $timeout)
139
    {
140
        $this->trait->waitFor($ip, $port, $timeout);
141
    }
142
}
143