add myCalendar into
[awl.git] / vendor / phpunit / php-code-coverage / Tests / TestCase.php
blob6a04513f8a9c59d1a6f1199a5f2fa0b1786dc04a
1 <?php
2 /**
3 * PHP_CodeCoverage
5 * Copyright (c) 2009-2013, Sebastian Bergmann <sebastian@phpunit.de>.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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
18 * distribution.
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.
37 * @category PHP
38 * @package CodeCoverage
39 * @subpackage Tests
40 * @author Sebastian Bergmann <sebastian@phpunit.de>
41 * @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
42 * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
43 * @link http://github.com/sebastianbergmann/php-code-coverage
44 * @since File available since Release 1.0.0
47 /**
48 * Abstract base class for test case classes.
50 * @category PHP
51 * @package CodeCoverage
52 * @subpackage Tests
53 * @author Sebastian Bergmann <sebastian@phpunit.de>
54 * @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
55 * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
56 * @link http://github.com/sebastianbergmann/php-code-coverage
57 * @since Class available since Release 1.0.0
59 abstract class PHP_CodeCoverage_TestCase extends PHPUnit_Framework_TestCase
61 protected function getXdebugDataForBankAccount()
63 return array(
64 array(
65 TEST_FILES_PATH . 'BankAccount.php' => array(
66 8 => 1,
67 9 => -2,
68 13 => -1,
69 14 => -1,
70 15 => -1,
71 16 => -1,
72 18 => -1,
73 22 => -1,
74 24 => -1,
75 25 => -2,
76 29 => -1,
77 31 => -1,
78 32 => -2
81 array(
82 TEST_FILES_PATH . 'BankAccount.php' => array(
83 8 => 1,
84 13 => 1,
85 16 => 1,
86 29 => 1,
89 array(
90 TEST_FILES_PATH . 'BankAccount.php' => array(
91 8 => 1,
92 13 => 1,
93 16 => 1,
94 22 => 1,
97 array(
98 TEST_FILES_PATH . 'BankAccount.php' => array(
99 8 => 1,
100 13 => 1,
101 14 => 1,
102 15 => 1,
103 18 => 1,
104 22 => 1,
105 24 => 1,
106 29 => 1,
107 31 => 1,
113 protected function getCoverageForBankAccount()
115 $data = $this->getXdebugDataForBankAccount();
117 $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
118 $stub->expects($this->any())
119 ->method('stop')
120 ->will($this->onConsecutiveCalls(
121 $data[0], $data[1], $data[2], $data[3]
124 $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter);
126 $coverage->start(
127 new BankAccountTest('testBalanceIsInitiallyZero'), TRUE
129 $coverage->stop();
131 $coverage->start(
132 new BankAccountTest('testBalanceCannotBecomeNegative')
134 $coverage->stop();
136 $coverage->start(
137 new BankAccountTest('testBalanceCannotBecomeNegative2')
139 $coverage->stop();
141 $coverage->start(
142 new BankAccountTest('testDepositWithdrawMoney')
144 $coverage->stop();
146 return $coverage;
149 protected function getCoverageForBankAccountForFirstTwoTests()
151 $data = $this->getXdebugDataForBankAccount();
153 $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
154 $stub->expects($this->any())
155 ->method('stop')
156 ->will($this->onConsecutiveCalls(
157 $data[0], $data[1]
160 $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter);
162 $coverage->start(
163 new BankAccountTest('testBalanceIsInitiallyZero'), TRUE
165 $coverage->stop();
167 $coverage->start(
168 new BankAccountTest('testBalanceCannotBecomeNegative')
170 $coverage->stop();
172 return $coverage;
175 protected function getCoverageForBankAccountForLastTwoTests()
177 $data = $this->getXdebugDataForBankAccount();
179 $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
180 $stub->expects($this->any())
181 ->method('stop')
182 ->will($this->onConsecutiveCalls(
183 $data[2], $data[3]
186 $coverage = new PHP_CodeCoverage($stub, new PHP_CodeCoverage_Filter);
188 $coverage->start(
189 new BankAccountTest('testBalanceCannotBecomeNegative2'), TRUE
191 $coverage->stop();
193 $coverage->start(
194 new BankAccountTest('testDepositWithdrawMoney')
196 $coverage->stop();
198 return $coverage;
201 protected function getExpectedDataArrayForBankAccount()
203 return array(
204 TEST_FILES_PATH . 'BankAccount.php' => array(
205 8 => array(
206 0 => 'BankAccountTest::testBalanceIsInitiallyZero',
207 1 => 'BankAccountTest::testDepositWithdrawMoney'
209 9 => NULL,
210 13 => array(),
211 14 => array(),
212 15 => array(),
213 16 => array(),
214 18 => array(),
215 22 => array(
216 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2',
217 1 => 'BankAccountTest::testDepositWithdrawMoney'
219 24 => array(
220 0 => 'BankAccountTest::testDepositWithdrawMoney',
222 25 => NULL,
223 29 => array(
224 0 => 'BankAccountTest::testBalanceCannotBecomeNegative',
225 1 => 'BankAccountTest::testDepositWithdrawMoney'
227 31 => array(
228 0 => 'BankAccountTest::testDepositWithdrawMoney'
230 32 => NULL
235 protected function getCoverageForFileWithIgnoredLines()
237 $coverage = new PHP_CodeCoverage(
238 $this->setUpXdebugStubForFileWithIgnoredLines(),
239 new PHP_CodeCoverage_Filter
242 $coverage->start('FileWithIgnoredLines', TRUE);
243 $coverage->stop();
245 return $coverage;
248 protected function setUpXdebugStubForFileWithIgnoredLines()
250 $stub = $this->getMock('PHP_CodeCoverage_Driver_Xdebug');
251 $stub->expects($this->any())
252 ->method('stop')
253 ->will($this->returnValue(
254 array(
255 TEST_FILES_PATH . 'source_with_ignore.php' => array(
256 2 => 1,
257 4 => -1,
258 6 => -1,
259 7 => 1
264 return $stub;