5
* Copyright (c) 2002-2010, Sebastian Bergmann <sebastian@phpunit.de>.
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
12
* * Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in
17
* the documentation and/or other materials provided with the
20
* * Neither the name of Sebastian Bergmann nor the names of his
21
* contributors may be used to endorse or promote products derived
22
* from this software without specific prior written permission.
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
* POSSIBILITY OF SUCH DAMAGE.
38
* @subpackage Util_Log
39
* @author Benjamin Eberlei <kontakt@beberlei.de>
40
* @author Sebastian Bergmann <sebastian@phpunit.de>
41
* @copyright 2002-2010 Sebastian Bergmann <sebastian@phpunit.de>
42
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
43
* @link http://www.phpunit.de/
44
* @since File available since Release 3.5.0
48
* A TestListener that integrates with DBUS.
51
* @subpackage Util_Log
52
* @author Benjamin Eberlei <kontakt@beberlei.de>
53
* @author Sebastian Bergmann <sebastian@phpunit.de>
54
* @copyright 2002-2010 Sebastian Bergmann <sebastian@phpunit.de>
55
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
56
* @version Release: 3.5.5
57
* @link http://www.phpunit.de/
58
* @since Class available since Release 3.5.0
60
class PHPUnit_Util_Log_DBUS implements PHPUnit_Framework_TestListener
65
protected $errors = 0;
70
protected $failures = 0;
75
protected $startTime = NULL;
80
protected $suiteName = '';
90
protected $startedSuites = 0;
95
protected $endedSuites = 0;
100
* @param PHPUnit_Framework_Test $test
101
* @param Exception $e
104
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
110
* A failure occurred.
112
* @param PHPUnit_Framework_Test $test
113
* @param PHPUnit_Framework_AssertionFailedError $e
116
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
124
* @param PHPUnit_Framework_Test $test
125
* @param Exception $e
128
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
135
* @param PHPUnit_Framework_Test $test
136
* @param Exception $e
138
* @since Method available since Release 3.0.0
140
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
145
* A test suite started.
147
* @param PHPUnit_Framework_TestSuite $suite
148
* @since Method available since Release 2.2.0
150
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
152
if($this->startedSuites == 0) {
153
$this->startTime = time();
154
$this->suiteName = $suite->getName();
157
$this->startedSuites++;
161
* A test suite ended.
163
* @param PHPUnit_Framework_TestSuite $suite
164
* @since Method available since Release 2.2.0
166
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
168
$this->endedSuites++;
170
if($this->startedSuites <= $this->endedSuites) {
178
* @param PHPUnit_Framework_Test $test
180
public function startTest(PHPUnit_Framework_Test $test)
188
* @param PHPUnit_Framework_Test $test
191
public function endTest(PHPUnit_Framework_Test $test, $time)
198
protected function notify()
200
$d = new Dbus(Dbus::BUS_SESSION);
202
$n = $d->createProxy(
203
'org.freedesktop.Notifications',
204
'/org/freedesktop/Notifications',
205
'org.freedesktop.Notifications'
209
'PHPUnit_Util_Log_DBUS',
212
'PHPUnit Test Report',
214
"Suite: %s\n%d tests run in %s minutes.\n%d errors, %d failures",
217
(date('i:s', time() - $this->startTime)),
221
new DBusArray(DBus::STRING, array()),
222
new DBusDict(DBus::VARIANT, array()),