laravel-6 support

This commit is contained in:
RafficMohammed
2023-01-08 01:17:22 +05:30
parent 1a5c16ae4b
commit 774eed8b0e
4962 changed files with 279380 additions and 297961 deletions

View File

@@ -11,17 +11,13 @@
namespace SebastianBergmann\CodeCoverage;
use SebastianBergmann\CodeCoverage\Driver\Driver;
use SebastianBergmann\CodeCoverage\Report\Xml\Coverage;
/**
* Abstract base class for test case classes.
*
* @since Class available since Release 1.0.0
*/
abstract class TestCase extends \PHPUnit\Framework\TestCase
{
protected static $TEST_TMP_PATH;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$TEST_TMP_PATH = TEST_FILES_PATH . 'tmp';
}
@@ -78,10 +74,9 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
];
}
protected function getCoverageForBankAccount()
protected function getCoverageForBankAccount(): CodeCoverage
{
$data = $this->getXdebugDataForBankAccount();
require_once TEST_FILES_PATH . '/BankAccountTest.php';
$stub = $this->createMock(Driver::class);
@@ -145,7 +140,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $coverage;
}
protected function getCoverageForBankAccountForFirstTwoTests()
protected function getCoverageForBankAccountForFirstTwoTests(): CodeCoverage
{
$data = $this->getXdebugDataForBankAccount();
@@ -230,7 +225,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $coverage;
}
protected function getExpectedDataArrayForBankAccount()
protected function getExpectedDataArrayForBankAccount(): array
{
return [
TEST_FILES_PATH . 'BankAccount.php' => [
@@ -264,7 +259,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
];
}
protected function getExpectedDataArrayForBankAccountInReverseOrder()
protected function getExpectedDataArrayForBankAccountInReverseOrder(): array
{
return [
TEST_FILES_PATH . 'BankAccount.php' => [
@@ -298,7 +293,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
];
}
protected function getCoverageForFileWithIgnoredLines()
protected function getCoverageForFileWithIgnoredLines(): CodeCoverage
{
$filter = new Filter;
$filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_ignore.php');
@@ -314,7 +309,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $coverage;
}
protected function setUpXdebugStubForFileWithIgnoredLines()
protected function setUpXdebugStubForFileWithIgnoredLines(): Driver
{
$stub = $this->createMock(Driver::class);
@@ -334,7 +329,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $stub;
}
protected function getCoverageForClassWithAnonymousFunction()
protected function getCoverageForClassWithAnonymousFunction(): CodeCoverage
{
$filter = new Filter;
$filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php');
@@ -350,7 +345,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $coverage;
}
protected function setUpXdebugStubForClassWithAnonymousFunction()
protected function setUpXdebugStubForClassWithAnonymousFunction(): Driver
{
$stub = $this->createMock(Driver::class);
@@ -375,7 +370,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $stub;
}
protected function getCoverageForCrashParsing()
protected function getCoverageForCrashParsing(): CodeCoverage
{
$filter = new Filter;
$filter->addFileToWhitelist(TEST_FILES_PATH . 'Crash.php');
@@ -387,7 +382,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
);
}
protected function setUpXdebugStubForCrashParsing()
protected function setUpXdebugStubForCrashParsing(): Driver
{
$stub = $this->createMock(Driver::class);

View File

@@ -7,7 +7,7 @@
</class>
<line num="6" type="method" name="getBalance" visibility="public" complexity="1" crap="1" count="2"/>
<line num="8" type="stmt" count="2"/>
<line num="11" type="method" name="setBalance" visibility="protected" complexity="2" crap="6.00" count="0"/>
<line num="11" type="method" name="setBalance" visibility="protected" complexity="2" crap="6" count="0"/>
<line num="13" type="stmt" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="15" type="stmt" count="0"/>

View File

@@ -1,13 +1,11 @@
<?php
require_once 'BankAccount.php';
use PHPUnit\Framework\TestCase;
class BankAccountTest extends TestCase
{
protected $ba;
protected function setUp()
protected function setUp(): void
{
$this->ba = new BankAccount;
}

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Code Coverage for %s%eBankAccount.php</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/octicons.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/octicons.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -130,7 +130,7 @@
</td>
<td class="danger small"><div align="right">0.00%</div></td>
<td class="danger small"><div align="right">0&nbsp;/&nbsp;1</div></td>
<td class="danger small">6.00</td>
<td class="danger small">6</td>
<td class="danger big"> <div class="progress">
<div class="progress-bar bg-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
<span class="sr-only">0.00% covered (danger)</span>
@@ -196,7 +196,7 @@
<tr><td><div align="right"><a name="5"></a><a href="#5">5</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="6"></a><a href="#6">6</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span></td></tr>
<tr><td><div align="right"><a name="7"></a><a href="#7">7</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="2 tests cover line 8" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testBalanceIsInitiallyZero&lt;/li&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="8"></a><a href="#8">8</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">balance</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="2 tests cover line 8" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testBalanceIsInitiallyZero&lt;/li&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="8"></a><a href="#8">8</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">balance</span><span class="keyword">;</span></td></tr>
<tr class="warning"><td><div align="right"><a name="9"></a><a href="#9">9</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="10"></a><a href="#10">10</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="11"></a><a href="#11">11</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">protected</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">setBalance</span><span class="keyword">(</span><span class="default">$balance</span><span class="keyword">)</span></td></tr>
@@ -210,16 +210,16 @@
<tr><td><div align="right"><a name="19"></a><a href="#19">19</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="20"></a><a href="#20">20</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">depositMoney</span><span class="keyword">(</span><span class="default">$balance</span><span class="keyword">)</span></td></tr>
<tr><td><div align="right"><a name="21"></a><a href="#21">21</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="2 tests cover line 22" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testBalanceCannotBecomeNegative2&lt;/li&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="22"></a><a href="#22">22</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">setBalance</span><span class="keyword">(</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">+</span><span class="default">&nbsp;</span><span class="default">$balance</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="2 tests cover line 22" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testBalanceCannotBecomeNegative2&lt;/li&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="22"></a><a href="#22">22</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">setBalance</span><span class="keyword">(</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">+</span><span class="default">&nbsp;</span><span class="default">$balance</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="23"></a><a href="#23">23</a></div></td><td class="codeLine"></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 24" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="24"></a><a href="#24">24</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 24" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="24"></a><a href="#24">24</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="warning"><td><div align="right"><a name="25"></a><a href="#25">25</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="26"></a><a href="#26">26</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="27"></a><a href="#27">27</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">withdrawMoney</span><span class="keyword">(</span><span class="default">$balance</span><span class="keyword">)</span></td></tr>
<tr><td><div align="right"><a name="28"></a><a href="#28">28</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="2 tests cover line 29" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testBalanceCannotBecomeNegative&lt;/li&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="29"></a><a href="#29">29</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">setBalance</span><span class="keyword">(</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">-</span><span class="default">&nbsp;</span><span class="default">$balance</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="2 tests cover line 29" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testBalanceCannotBecomeNegative&lt;/li&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="29"></a><a href="#29">29</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">setBalance</span><span class="keyword">(</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">-</span><span class="default">&nbsp;</span><span class="default">$balance</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="30"></a><a href="#30">30</a></div></td><td class="codeLine"></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 31" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="31"></a><a href="#31">31</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 31" data-content="&lt;ul&gt;&lt;li&gt;BankAccountTest::testDepositWithdrawMoney&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="31"></a><a href="#31">31</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="default">$this</span><span class="default">-&gt;</span><span class="default">getBalance</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="warning"><td><div align="right"><a name="32"></a><a href="#32">32</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="33"></a><a href="#33">33</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
@@ -241,9 +241,9 @@
</a>
</footer>
</div>
<script src=".js/jquery.min.js" type="text/javascript"></script>
<script src=".js/popper.min.js" type="text/javascript"></script>
<script src=".js/bootstrap.min.js" type="text/javascript"></script>
<script src=".js/file.js" type="text/javascript"></script>
<script src="_js/jquery.min.js" type="text/javascript"></script>
<script src="_js/popper.min.js" type="text/javascript"></script>
<script src="_js/bootstrap.min.js" type="text/javascript"></script>
<script src="_js/file.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Dashboard for %s</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -143,9 +143,9 @@
</p>
</footer>
</div>
<script src=".js/jquery.min.js" type="text/javascript"></script>
<script src=".js/d3.min.js" type="text/javascript"></script>
<script src=".js/nv.d3.min.js" type="text/javascript"></script>
<script src="_js/jquery.min.js" type="text/javascript"></script>
<script src="_js/d3.min.js" type="text/javascript"></script>
<script src="_js/nv.d3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
nv.addGraph(function() {

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Code Coverage for %s</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/octicons.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/octicons.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -70,7 +70,7 @@
</tr>
<tr>
<td class="danger"><img src=".icons/file-code.svg" class="octicon" /><a href="BankAccount.php.html">BankAccount.php</a></td>
<td class="danger"><img src="_icons/file-code.svg" class="octicon" /><a href="BankAccount.php.html">BankAccount.php</a></td>
<td class="danger big"> <div class="progress">
<div class="progress-bar bg-danger" role="progressbar" aria-valuenow="50.00" aria-valuemin="0" aria-valuemax="100" style="width: 50.00%">
<span class="sr-only">50.00% covered (danger)</span>

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Dashboard for %s</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -141,9 +141,9 @@
</p>
</footer>
</div>
<script src=".js/jquery.min.js" type="text/javascript"></script>
<script src=".js/d3.min.js" type="text/javascript"></script>
<script src=".js/nv.d3.min.js" type="text/javascript"></script>
<script src="_js/jquery.min.js" type="text/javascript"></script>
<script src="_js/d3.min.js" type="text/javascript"></script>
<script src="_js/nv.d3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
nv.addGraph(function() {

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Code Coverage for %s</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/octicons.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/octicons.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -70,7 +70,7 @@
</tr>
<tr>
<td class="warning"><img src=".icons/file-code.svg" class="octicon" /><a href="source_with_class_and_anonymous_function.php.html">source_with_class_and_anonymous_function.php</a></td>
<td class="warning"><img src="_icons/file-code.svg" class="octicon" /><a href="source_with_class_and_anonymous_function.php.html">source_with_class_and_anonymous_function.php</a></td>
<td class="warning big"> <div class="progress">
<div class="progress-bar bg-warning" role="progressbar" aria-valuenow="87.50" aria-valuemin="0" aria-valuemax="100" style="width: 87.50%">
<span class="sr-only">87.50% covered (warning)</span>

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Code Coverage for %s%esource_with_class_and_anonymous_function.php</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/octicons.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/octicons.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -132,18 +132,18 @@
<tr><td><div align="right"><a name="4"></a><a href="#4">4</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
<tr><td><div align="right"><a name="5"></a><a href="#5">5</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">static</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">runAnonymous</span><span class="keyword">(</span><span class="keyword">)</span></td></tr>
<tr><td><div align="right"><a name="6"></a><a href="#6">6</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 7" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="7"></a><a href="#7">7</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$filter</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">[</span><span class="default">'abc124'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'abc123'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'123'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 7" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="7"></a><a href="#7">7</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$filter</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">[</span><span class="default">'abc124'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'abc123'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'123'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="8"></a><a href="#8">8</a></div></td><td class="codeLine"></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 9" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="9"></a><a href="#9">9</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">array_walk</span><span class="keyword">(</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 9" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="9"></a><a href="#9">9</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">array_walk</span><span class="keyword">(</span></td></tr>
<tr class="danger"><td><div align="right"><a name="10"></a><a href="#10">10</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$filter</span><span class="keyword">,</span></td></tr>
<tr><td><div align="right"><a name="11"></a><a href="#11">11</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">&amp;</span><span class="default">$val</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$key</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 12" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="12"></a><a href="#12">12</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$val</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">preg_replace</span><span class="keyword">(</span><span class="default">'|[^0-9]|'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$val</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 13" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="13"></a><a href="#13">13</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 14" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="14"></a><a href="#14">14</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 12" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="12"></a><a href="#12">12</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$val</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">preg_replace</span><span class="keyword">(</span><span class="default">'|[^0-9]|'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$val</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 13" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="13"></a><a href="#13">13</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 14" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="14"></a><a href="#14">14</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="15"></a><a href="#15">15</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="16"></a><a href="#16">16</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Should&nbsp;be&nbsp;covered</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 17" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="17"></a><a href="#17">17</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$extravar</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">true</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 18" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="18"></a><a href="#18">18</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 17" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="17"></a><a href="#17">17</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$extravar</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">true</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 18" data-content="&lt;ul&gt;&lt;li&gt;ClassWithAnonymousFunction&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="18"></a><a href="#18">18</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="19"></a><a href="#19">19</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
</tbody>
@@ -164,9 +164,9 @@
</a>
</footer>
</div>
<script src=".js/jquery.min.js" type="text/javascript"></script>
<script src=".js/popper.min.js" type="text/javascript"></script>
<script src=".js/bootstrap.min.js" type="text/javascript"></script>
<script src=".js/file.js" type="text/javascript"></script>
<script src="_js/jquery.min.js" type="text/javascript"></script>
<script src="_js/popper.min.js" type="text/javascript"></script>
<script src="_js/bootstrap.min.js" type="text/javascript"></script>
<script src="_js/file.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Dashboard for %s</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -139,9 +139,9 @@
</p>
</footer>
</div>
<script src=".js/jquery.min.js" type="text/javascript"></script>
<script src=".js/d3.min.js" type="text/javascript"></script>
<script src=".js/nv.d3.min.js" type="text/javascript"></script>
<script src="_js/jquery.min.js" type="text/javascript"></script>
<script src="_js/d3.min.js" type="text/javascript"></script>
<script src="_js/nv.d3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
nv.addGraph(function() {

View File

@@ -4,10 +4,10 @@
<meta charset="UTF-8">
<title>Code Coverage for %s</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/octicons.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/octicons.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -65,7 +65,7 @@
</tr>
<tr>
<td class="danger"><img src=".icons/file-code.svg" class="octicon" /><a href="source_with_ignore.php.html">source_with_ignore.php</a></td>
<td class="danger"><img src="_icons/file-code.svg" class="octicon" /><a href="source_with_ignore.php.html">source_with_ignore.php</a></td>
<td class="danger big"> <div class="progress">
<div class="progress-bar bg-danger" role="progressbar" aria-valuenow="50.00" aria-valuemin="0" aria-valuemax="100" style="width: 50.00%">
<span class="sr-only">50.00% covered (danger)</span>

View File

@@ -2,12 +2,12 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code Coverage for %s/source_with_ignore.php</title>
<title>Code Coverage for %s%esource_with_ignore.php</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href=".css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href=".css/octicons.css" rel="stylesheet" type="text/css">
<link href=".css/style.css" rel="stylesheet" type="text/css">
<link href=".css/custom.css" rel="stylesheet" type="text/css">
<link href="_css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="_css/octicons.css" rel="stylesheet" type="text/css">
<link href="_css/style.css" rel="stylesheet" type="text/css">
<link href="_css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
@@ -133,7 +133,7 @@
<table id="code" class="table table-borderless table-condensed">
<tbody>
<tr><td><div align="right"><a name="1"></a><a href="#1">1</a></div></td><td class="codeLine"><span class="default">&lt;?php</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="1 test covers line 2" data-content="&lt;ul&gt;&lt;li&gt;FileWithIgnoredLines&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="2"></a><a href="#2">2</a></div></td><td class="codeLine"><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$neverHappens</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin"><td data-title="1 test covers line 2" data-content="&lt;ul&gt;&lt;li&gt;FileWithIgnoredLines&lt;/li&gt;&lt;/ul&gt;" data-placement="top" data-html="true"><div align="right"><a name="2"></a><a href="#2">2</a></div></td><td class="codeLine"><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$neverHappens</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">{</span></td></tr>
<tr><td><div align="right"><a name="3"></a><a href="#3">3</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;@codeCoverageIgnoreStart</span></td></tr>
<tr><td><div align="right"><a name="4"></a><a href="#4">4</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">print</span><span class="default">&nbsp;</span><span class="default">'*'</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="5"></a><a href="#5">5</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;@codeCoverageIgnoreEnd</span></td></tr>
@@ -188,9 +188,9 @@
</a>
</footer>
</div>
<script src=".js/jquery.min.js" type="text/javascript"></script>
<script src=".js/popper.min.js" type="text/javascript"></script>
<script src=".js/bootstrap.min.js" type="text/javascript"></script>
<script src=".js/file.js" type="text/javascript"></script>
<script src="_js/jquery.min.js" type="text/javascript"></script>
<script src="_js/popper.min.js" type="text/javascript"></script>
<script src="_js/bootstrap.min.js" type="text/javascript"></script>
<script src="_js/file.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -12,7 +12,7 @@
<package full="" name="" sub="" category=""/>
<namespace name=""/>
<method name="getBalance" signature="getBalance()" start="6" end="9" crap="1" executable="1" executed="1" coverage="100"/>
<method name="setBalance" signature="setBalance($balance)" start="11" end="18" crap="6.00" executable="5" executed="0" coverage="0"/>
<method name="setBalance" signature="setBalance($balance)" start="11" end="18" crap="6" executable="5" executed="0" coverage="0"/>
<method name="depositMoney" signature="depositMoney($balance)" start="20" end="25" crap="1" executable="2" executed="2" coverage="100"/>
<method name="withdrawMoney" signature="withdrawMoney($balance)" start="27" end="32" crap="1" executable="2" executed="2" coverage="100"/>
</class>

View File

@@ -2,7 +2,7 @@
<phpunit xmlns="https://schema.phpunit.de/coverage/1.0">
<build time="%s" phpunit="%s" coverage="%s">
<runtime name="%s" version="%s" url="%s"/>
<driver name="%s" version="%s"/>
<driver%S/>
</build>
<project source="%s">
<tests>

View File

@@ -2,7 +2,7 @@
<phpunit xmlns="https://schema.phpunit.de/coverage/1.0">
<build time="%s" phpunit="%s" coverage="%s">
<runtime name="%s" version="%s" url="%s"/>
<driver name="%s" version="%s"/>
<driver%S/>
</build>
<project source="%s">
<tests>

View File

@@ -2,7 +2,7 @@
<phpunit xmlns="https://schema.phpunit.de/coverage/1.0">
<build time="%s" phpunit="%s" coverage="%s">
<runtime name="%s" version="%s" url="%s"/>
<driver name="%s" version="%s"/>
<driver%S/>
</build>
<project source="%s">
<tests>

View File

@@ -0,0 +1,23 @@
<?php
namespace SebastianBergmann\CodeCoverage\TestFixture;
use stdClass;
use function array_filter;
use const ARRAY_FILTER_USE_BOTH;
class C
{
public function m(): void
{
$o = new stdClass;
array_filter(
['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4],
static function ($v, $k)
{
return $k === 'b' || $v === 4;
},
ARRAY_FILTER_USE_BOTH
);
}
}

View File

@@ -1,6 +1,5 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/TestCase.php';
define(
'TEST_FILES_PATH',

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,29 +7,25 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Report;
use SebastianBergmann\CodeCoverage\Driver\Driver;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Filter;
use SebastianBergmann\CodeCoverage\TestCase;
use SebastianBergmann\CodeCoverage\Node\Builder;
use SebastianBergmann\CodeCoverage\TestCase;
class BuilderTest extends TestCase
{
protected $factory;
protected function setUp()
protected function setUp(): void
{
$this->factory = new Builder;
}
public function testSomething()
public function testSomething(): void
{
$root = $this->getCoverageForBankAccount()->getReport();
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
$expectedPath = \rtrim(TEST_FILES_PATH, \DIRECTORY_SEPARATOR);
$this->assertEquals($expectedPath, $root->getName());
$this->assertEquals($expectedPath, $root->getPath());
$this->assertEquals(10, $root->getNumExecutableLines());
@@ -116,11 +112,11 @@ class BuilderTest extends TestCase
'fullPackage' => '',
'category' => '',
'package' => '',
'subpackage' => ''
'subpackage' => '',
],
'link' => 'BankAccount.php.html#2',
'className' => 'BankAccount'
]
'className' => 'BankAccount',
],
],
$root->getClasses()
);
@@ -128,22 +124,22 @@ class BuilderTest extends TestCase
$this->assertEquals([], $root->getFunctions());
}
public function testNotCrashParsing()
public function testNotCrashParsing(): void
{
$coverage = $this->getCoverageForCrashParsing();
$root = $coverage->getReport();
$root = $coverage->getReport();
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
$expectedPath = \rtrim(TEST_FILES_PATH, \DIRECTORY_SEPARATOR);
$this->assertEquals($expectedPath, $root->getName());
$this->assertEquals($expectedPath, $root->getPath());
$this->assertEquals(2, $root->getNumExecutableLines());
$this->assertEquals(0, $root->getNumExecutedLines());
$data = $coverage->getData();
$expectedFile = $expectedPath . DIRECTORY_SEPARATOR . 'Crash.php';
$data = $coverage->getData();
$expectedFile = $expectedPath . \DIRECTORY_SEPARATOR . 'Crash.php';
$this->assertSame([$expectedFile => [1 => [], 2 => []]], $data);
}
public function testBuildDirectoryStructure()
public function testBuildDirectoryStructure(): void
{
$s = \DIRECTORY_SEPARATOR;
@@ -159,20 +155,20 @@ class BuilderTest extends TestCase
'src' => [
'Money.php/f' => [],
'MoneyBag.php/f' => [],
'Foo' => [
'Foo' => [
'Bar' => [
'Baz' => [
'Foo.php/f' => [],
],
],
],
]
],
],
$method->invoke(
$this->factory,
[
"src{$s}Money.php" => [],
"src{$s}MoneyBag.php" => [],
"src{$s}Money.php" => [],
"src{$s}MoneyBag.php" => [],
"src{$s}Foo{$s}Bar{$s}Baz{$s}Foo.php" => [],
]
)
@@ -182,7 +178,7 @@ class BuilderTest extends TestCase
/**
* @dataProvider reducePathsProvider
*/
public function testReducePaths($reducedPaths, $commonPath, $paths)
public function testReducePaths($reducedPaths, $commonPath, $paths): void
{
$method = new \ReflectionMethod(
Builder::class,
@@ -203,45 +199,45 @@ class BuilderTest extends TestCase
yield [
[],
".",
[]
'.',
[],
];
$prefixes = ["C:$s", "$s"];
foreach($prefixes as $p){
foreach ($prefixes as $p) {
yield [
[
"Money.php" => []
'Money.php' => [],
],
"{$p}home{$s}sb{$s}Money{$s}",
[
"{$p}home{$s}sb{$s}Money{$s}Money.php" => []
]
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
],
];
yield [
[
"Money.php" => [],
"MoneyBag.php" => []
'Money.php' => [],
'MoneyBag.php' => [],
],
"{$p}home{$s}sb{$s}Money",
[
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => []
]
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => [],
],
];
yield [
[
"Money.php" => [],
"MoneyBag.php" => [],
'Money.php' => [],
'MoneyBag.php' => [],
"Cash.phar{$s}Cash.php" => [],
],
"{$p}home{$s}sb{$s}Money",
[
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => [],
"{$p}home{$s}sb{$s}Money{$s}Money.php" => [],
"{$p}home{$s}sb{$s}Money{$s}MoneyBag.php" => [],
"phar://{$p}home{$s}sb{$s}Money{$s}Cash.phar{$s}Cash.php" => [],
],
];

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Report;
use SebastianBergmann\CodeCoverage\TestCase;
@@ -17,7 +16,7 @@ use SebastianBergmann\CodeCoverage\TestCase;
*/
class CloverTest extends TestCase
{
public function testCloverForBankAccountTest()
public function testCloverForBankAccountTest(): void
{
$clover = new Clover;
@@ -27,7 +26,7 @@ class CloverTest extends TestCase
);
}
public function testCloverForFileWithIgnoredLines()
public function testCloverForFileWithIgnoredLines(): void
{
$clover = new Clover;
@@ -37,7 +36,7 @@ class CloverTest extends TestCase
);
}
public function testCloverForClassWithAnonymousFunction()
public function testCloverForClassWithAnonymousFunction(): void
{
$clover = new Clover;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,15 +7,10 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
require __DIR__ . '/../_files/BankAccount.php';
require __DIR__ . '/../_files/BankAccountTest.php';
use SebastianBergmann\CodeCoverage\Driver\Driver;
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
use SebastianBergmann\Environment\Runtime;
/**
* @covers SebastianBergmann\CodeCoverage\CodeCoverage
@@ -27,193 +22,32 @@ class CodeCoverageTest extends TestCase
*/
private $coverage;
protected function setUp()
protected function setUp(): void
{
$runtime = new Runtime;
if (!$runtime->canCollectCodeCoverage()) {
$this->markTestSkipped('No code coverage driver available');
}
$this->coverage = new CodeCoverage;
}
public function testCanBeConstructedForXdebugWithoutGivenFilterObject()
{
if (PHP_SAPI == 'phpdbg') {
$this->markTestSkipped('Requires PHP CLI and Xdebug');
}
$this->assertAttributeInstanceOf(
Xdebug::class,
'driver',
$this->coverage
);
$this->assertAttributeInstanceOf(
Filter::class,
'filter',
$this->coverage
);
}
public function testCanBeConstructedForXdebugWithGivenFilterObject()
{
if (PHP_SAPI == 'phpdbg') {
$this->markTestSkipped('Requires PHP CLI and Xdebug');
}
$filter = new Filter;
$coverage = new CodeCoverage(null, $filter);
$this->assertAttributeInstanceOf(
Xdebug::class,
'driver',
$coverage
);
$this->assertSame($filter, $coverage->filter());
}
public function testCanBeConstructedForPhpdbgWithoutGivenFilterObject()
{
if (PHP_SAPI != 'phpdbg') {
$this->markTestSkipped('Requires PHPDBG');
}
$this->assertAttributeInstanceOf(
PHPDBG::class,
'driver',
$this->coverage
);
$this->assertAttributeInstanceOf(
Filter::class,
'filter',
$this->coverage
);
}
public function testCanBeConstructedForPhpdbgWithGivenFilterObject()
{
if (PHP_SAPI != 'phpdbg') {
$this->markTestSkipped('Requires PHPDBG');
}
$filter = new Filter;
$coverage = new CodeCoverage(null, $filter);
$this->assertAttributeInstanceOf(
PHPDBG::class,
'driver',
$coverage
);
$this->assertSame($filter, $coverage->filter());
}
public function testCannotStopWithInvalidSecondArgument()
public function testCannotStopWithInvalidSecondArgument(): void
{
$this->expectException(Exception::class);
$this->coverage->stop(true, null);
}
public function testCannotAppendWithInvalidArgument()
public function testCannotAppendWithInvalidArgument(): void
{
$this->expectException(Exception::class);
$this->coverage->append([], null);
}
public function testSetCacheTokens()
{
$this->coverage->setCacheTokens(true);
$this->assertAttributeEquals(true, 'cacheTokens', $this->coverage);
}
public function testSetCheckForUnintentionallyCoveredCode()
{
$this->coverage->setCheckForUnintentionallyCoveredCode(true);
$this->assertAttributeEquals(
true,
'checkForUnintentionallyCoveredCode',
$this->coverage
);
}
public function testSetCheckForMissingCoversAnnotation()
{
$this->coverage->setCheckForMissingCoversAnnotation(true);
$this->assertAttributeEquals(
true,
'checkForMissingCoversAnnotation',
$this->coverage
);
}
public function testSetForceCoversAnnotation()
{
$this->coverage->setForceCoversAnnotation(true);
$this->assertAttributeEquals(
true,
'forceCoversAnnotation',
$this->coverage
);
}
public function testSetCheckForUnexecutedCoveredCode()
{
$this->coverage->setCheckForUnexecutedCoveredCode(true);
$this->assertAttributeEquals(
true,
'checkForUnexecutedCoveredCode',
$this->coverage
);
}
public function testSetAddUncoveredFilesFromWhitelist()
{
$this->coverage->setAddUncoveredFilesFromWhitelist(true);
$this->assertAttributeEquals(
true,
'addUncoveredFilesFromWhitelist',
$this->coverage
);
}
public function testSetProcessUncoveredFilesFromWhitelist()
{
$this->coverage->setProcessUncoveredFilesFromWhitelist(true);
$this->assertAttributeEquals(
true,
'processUncoveredFilesFromWhitelist',
$this->coverage
);
}
public function testSetIgnoreDeprecatedCode()
{
$this->coverage->setIgnoreDeprecatedCode(true);
$this->assertAttributeEquals(
true,
'ignoreDeprecatedCode',
$this->coverage
);
}
public function testClear()
{
$this->coverage->clear();
$this->assertAttributeEquals(null, 'currentId', $this->coverage);
$this->assertAttributeEquals([], 'data', $this->coverage);
$this->assertAttributeEquals([], 'tests', $this->coverage);
}
public function testCollect()
public function testCollect(): void
{
$coverage = $this->getCoverageForBankAccount();
@@ -227,13 +61,13 @@ class CodeCoverageTest extends TestCase
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1]
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1],
],
$coverage->getTests()
);
}
public function testMerge()
public function testMerge(): void
{
$coverage = $this->getCoverageForBankAccountForFirstTwoTests();
$coverage->merge($this->getCoverageForBankAccountForLastTwoTests());
@@ -244,7 +78,7 @@ class CodeCoverageTest extends TestCase
);
}
public function testMergeReverseOrder()
public function testMergeReverseOrder(): void
{
$coverage = $this->getCoverageForBankAccountForLastTwoTests();
$coverage->merge($this->getCoverageForBankAccountForFirstTwoTests());
@@ -255,7 +89,7 @@ class CodeCoverageTest extends TestCase
);
}
public function testMerge2()
public function testMerge2(): void
{
$coverage = new CodeCoverage(
$this->createMock(Driver::class),
@@ -270,7 +104,7 @@ class CodeCoverageTest extends TestCase
);
}
public function testGetLinesToBeIgnored()
public function testGetLinesToBeIgnored(): void
{
$this->assertEquals(
[
@@ -307,7 +141,7 @@ class CodeCoverageTest extends TestCase
35,
36,
37,
38
38,
],
$this->getLinesToBeIgnored()->invoke(
$this->coverage,
@@ -316,7 +150,7 @@ class CodeCoverageTest extends TestCase
);
}
public function testGetLinesToBeIgnored2()
public function testGetLinesToBeIgnored2(): void
{
$this->assertEquals(
[1, 5],
@@ -327,7 +161,7 @@ class CodeCoverageTest extends TestCase
);
}
public function testGetLinesToBeIgnored3()
public function testGetLinesToBeIgnored3(): void
{
$this->assertEquals(
[
@@ -341,7 +175,7 @@ class CodeCoverageTest extends TestCase
15,
16,
19,
20
20,
],
$this->getLinesToBeIgnored()->invoke(
$this->coverage,
@@ -350,7 +184,7 @@ class CodeCoverageTest extends TestCase
);
}
public function testGetLinesToBeIgnoredOneLineAnnotations()
public function testGetLinesToBeIgnoredOneLineAnnotations(): void
{
$this->assertEquals(
[
@@ -382,7 +216,7 @@ class CodeCoverageTest extends TestCase
32,
33,
34,
37
37,
],
$this->getLinesToBeIgnored()->invoke(
$this->coverage,
@@ -391,22 +225,7 @@ class CodeCoverageTest extends TestCase
);
}
/**
* @return \ReflectionMethod
*/
private function getLinesToBeIgnored()
{
$getLinesToBeIgnored = new \ReflectionMethod(
'SebastianBergmann\CodeCoverage\CodeCoverage',
'getLinesToBeIgnored'
);
$getLinesToBeIgnored->setAccessible(true);
return $getLinesToBeIgnored;
}
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled()
public function testGetLinesToBeIgnoredWhenIgnoreIsDisabled(): void
{
$this->coverage->setDisableIgnoredLines(true);
@@ -431,7 +250,7 @@ class CodeCoverageTest extends TestCase
34,
35,
36,
37
37,
],
$this->getLinesToBeIgnored()->invoke(
$this->coverage,
@@ -440,7 +259,33 @@ class CodeCoverageTest extends TestCase
);
}
public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted()
public function testUseStatementsAreIgnored(): void
{
$this->assertEquals(
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
13,
16,
23,
24,
],
$this->getLinesToBeIgnored()->invoke(
$this->coverage,
TEST_FILES_PATH . 'source_with_use_statements.php'
)
);
}
public function testAppendThrowsExceptionIfCoveredCodeWasNotExecuted(): void
{
$this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH);
$this->coverage->setCheckForUnexecutedCoveredCode(true);
@@ -448,15 +293,15 @@ class CodeCoverageTest extends TestCase
$data = [
TEST_FILES_PATH . 'BankAccount.php' => [
29 => -1,
31 => -1
]
31 => -1,
],
];
$linesToBeCovered = [
TEST_FILES_PATH . 'BankAccount.php' => [
22,
24
]
24,
],
];
$linesToBeUsed = [];
@@ -466,7 +311,7 @@ class CodeCoverageTest extends TestCase
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
}
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted()
public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted(): void
{
$this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH);
$this->coverage->setCheckForUnexecutedCoveredCode(true);
@@ -474,26 +319,41 @@ class CodeCoverageTest extends TestCase
$data = [
TEST_FILES_PATH . 'BankAccount.php' => [
29 => -1,
31 => -1
]
31 => -1,
],
];
$linesToBeCovered = [
TEST_FILES_PATH . 'BankAccount.php' => [
29,
31
]
31,
],
];
$linesToBeUsed = [
TEST_FILES_PATH . 'BankAccount.php' => [
22,
24
]
24,
],
];
$this->expectException(CoveredCodeNotExecutedException::class);
$this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
}
/**
* @return \ReflectionMethod
*/
private function getLinesToBeIgnored()
{
$getLinesToBeIgnored = new \ReflectionMethod(
'SebastianBergmann\CodeCoverage\CodeCoverage',
'getLinesToBeIgnored'
);
$getLinesToBeIgnored->setAccessible(true);
return $getLinesToBeIgnored;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Report;
use SebastianBergmann\CodeCoverage\TestCase;
@@ -17,7 +16,7 @@ use SebastianBergmann\CodeCoverage\TestCase;
*/
class Crap4jTest extends TestCase
{
public function testForBankAccountTest()
public function testForBankAccountTest(): void
{
$crap4j = new Crap4j;
@@ -27,7 +26,7 @@ class Crap4jTest extends TestCase
);
}
public function testForFileWithIgnoredLines()
public function testForFileWithIgnoredLines(): void
{
$crap4j = new Crap4j;
@@ -37,7 +36,7 @@ class Crap4jTest extends TestCase
);
}
public function testForClassWithAnonymousFunction()
public function testForClassWithAnonymousFunction(): void
{
$crap4j = new Crap4j;

View File

@@ -0,0 +1,51 @@
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\tests\Exception;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\CodeCoverage\RuntimeException;
use SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException;
final class UnintentionallyCoveredCodeExceptionTest extends TestCase
{
public function testCanConstructWithEmptyArray(): void
{
$unintentionallyCoveredUnits = [];
$exception = new UnintentionallyCoveredCodeException($unintentionallyCoveredUnits);
$this->assertInstanceOf(RuntimeException::class, $exception);
$this->assertSame($unintentionallyCoveredUnits, $exception->getUnintentionallyCoveredUnits());
$this->assertSame('', $exception->getMessage());
}
public function testCanConstructWithNonEmptyArray(): void
{
$unintentionallyCoveredUnits = [
'foo',
'bar',
'baz',
];
$exception = new UnintentionallyCoveredCodeException($unintentionallyCoveredUnits);
$this->assertInstanceOf(RuntimeException::class, $exception);
$this->assertSame($unintentionallyCoveredUnits, $exception->getUnintentionallyCoveredUnits());
$expected = <<<TXT
- foo
- bar
- baz
TXT;
$this->assertSame($expected, $exception->getMessage());
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
use PHPUnit\Framework\TestCase;
@@ -25,9 +24,9 @@ class FilterTest extends TestCase
*/
private $files = [];
protected function setUp()
protected function setUp(): void
{
$this->filter = unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}');
$this->filter = \unserialize('O:37:"SebastianBergmann\CodeCoverage\Filter":0:{}');
$this->files = [
TEST_FILES_PATH . 'BankAccount.php',
@@ -70,8 +69,9 @@ class FilterTest extends TestCase
TEST_FILES_PATH . 'source_with_ignore.php',
TEST_FILES_PATH . 'source_with_namespace.php',
TEST_FILES_PATH . 'source_with_oneline_annotations.php',
TEST_FILES_PATH . 'source_with_use_statements.php',
TEST_FILES_PATH . 'source_without_ignore.php',
TEST_FILES_PATH . 'source_without_namespace.php'
TEST_FILES_PATH . 'source_without_namespace.php',
];
}
@@ -79,7 +79,7 @@ class FilterTest extends TestCase
* @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
*/
public function testAddingAFileToTheWhitelistWorks()
public function testAddingAFileToTheWhitelistWorks(): void
{
$this->filter->addFileToWhitelist($this->files[0]);
@@ -93,7 +93,7 @@ class FilterTest extends TestCase
* @covers SebastianBergmann\CodeCoverage\Filter::removeFileFromWhitelist
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
*/
public function testRemovingAFileFromTheWhitelistWorks()
public function testRemovingAFileFromTheWhitelistWorks(): void
{
$this->filter->addFileToWhitelist($this->files[0]);
$this->filter->removeFileFromWhitelist($this->files[0]);
@@ -106,12 +106,12 @@ class FilterTest extends TestCase
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
* @depends testAddingAFileToTheWhitelistWorks
*/
public function testAddingADirectoryToTheWhitelistWorks()
public function testAddingADirectoryToTheWhitelistWorks(): void
{
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
$whitelist = $this->filter->getWhitelist();
sort($whitelist);
\sort($whitelist);
$this->assertEquals($this->files, $whitelist);
}
@@ -120,7 +120,7 @@ class FilterTest extends TestCase
* @covers SebastianBergmann\CodeCoverage\Filter::addFilesToWhitelist
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
*/
public function testAddingFilesToTheWhitelistWorks()
public function testAddingFilesToTheWhitelistWorks(): void
{
$facade = new FileIteratorFacade;
@@ -132,7 +132,7 @@ class FilterTest extends TestCase
$this->filter->addFilesToWhitelist($files);
$whitelist = $this->filter->getWhitelist();
sort($whitelist);
\sort($whitelist);
$this->assertEquals($this->files, $whitelist);
}
@@ -142,7 +142,7 @@ class FilterTest extends TestCase
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
* @depends testAddingADirectoryToTheWhitelistWorks
*/
public function testRemovingADirectoryFromTheWhitelistWorks()
public function testRemovingADirectoryFromTheWhitelistWorks(): void
{
$this->filter->addDirectoryToWhitelist(TEST_FILES_PATH);
$this->filter->removeDirectoryFromWhitelist(TEST_FILES_PATH);
@@ -153,7 +153,7 @@ class FilterTest extends TestCase
/**
* @covers SebastianBergmann\CodeCoverage\Filter::isFile
*/
public function testIsFile()
public function testIsFile(): void
{
$this->assertFalse($this->filter->isFile('vfs://root/a/path'));
$this->assertFalse($this->filter->isFile('xdebug://debug-eval'));
@@ -167,7 +167,7 @@ class FilterTest extends TestCase
/**
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
*/
public function testWhitelistedFileIsNotFiltered()
public function testWhitelistedFileIsNotFiltered(): void
{
$this->filter->addFileToWhitelist($this->files[0]);
$this->assertFalse($this->filter->isFiltered($this->files[0]));
@@ -176,7 +176,7 @@ class FilterTest extends TestCase
/**
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
*/
public function testNotWhitelistedFileIsFiltered()
public function testNotWhitelistedFileIsFiltered(): void
{
$this->filter->addFileToWhitelist($this->files[0]);
$this->assertTrue($this->filter->isFiltered($this->files[1]));
@@ -186,7 +186,7 @@ class FilterTest extends TestCase
* @covers SebastianBergmann\CodeCoverage\Filter::isFiltered
* @covers SebastianBergmann\CodeCoverage\Filter::isFile
*/
public function testNonFilesAreFiltered()
public function testNonFilesAreFiltered(): void
{
$this->assertTrue($this->filter->isFiltered('vfs://root/a/path'));
$this->assertTrue($this->filter->isFiltered('xdebug://debug-eval'));
@@ -195,4 +195,19 @@ class FilterTest extends TestCase
$this->assertTrue($this->filter->isFiltered('assert code'));
$this->assertTrue($this->filter->isFiltered('regexp code'));
}
/**
* @covers SebastianBergmann\CodeCoverage\Filter::addFileToWhitelist
* @covers SebastianBergmann\CodeCoverage\Filter::getWhitelist
*
* @ticket https://github.com/sebastianbergmann/php-code-coverage/issues/664
*/
public function testTryingToAddFileThatDoesNotExistDoesNotChangeFilter(): void
{
$filter = new Filter;
$filter->addFileToWhitelist('does_not_exist');
$this->assertEmpty($filter->getWhitelistedFiles());
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Report\Html;
use SebastianBergmann\CodeCoverage\TestCase;
@@ -16,14 +15,14 @@ class HTMLTest extends TestCase
{
private static $TEST_REPORT_PATH_SOURCE;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'HTML';
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . \DIRECTORY_SEPARATOR . 'HTML';
}
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
@@ -35,13 +34,13 @@ class HTMLTest extends TestCase
foreach ($tmpFilesIterator as $path => $fileInfo) {
/* @var \SplFileInfo $fileInfo */
$pathname = $fileInfo->getPathname();
$fileInfo->isDir() ? rmdir($pathname) : unlink($pathname);
$fileInfo->isDir() ? \rmdir($pathname) : \unlink($pathname);
}
}
public function testForBankAccountTest()
public function testForBankAccountTest(): void
{
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
$report = new Facade;
$report->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
@@ -49,9 +48,9 @@ class HTMLTest extends TestCase
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
}
public function testForFileWithIgnoredLines()
public function testForFileWithIgnoredLines(): void
{
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
$report = new Facade;
$report->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
@@ -59,10 +58,10 @@ class HTMLTest extends TestCase
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
}
public function testForClassWithAnonymousFunction()
public function testForClassWithAnonymousFunction(): void
{
$expectedFilesPath =
self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
$report = new Facade;
$report->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
@@ -74,14 +73,14 @@ class HTMLTest extends TestCase
* @param string $expectedFilesPath
* @param string $actualFilesPath
*/
private function assertFilesEquals($expectedFilesPath, $actualFilesPath)
private function assertFilesEquals($expectedFilesPath, $actualFilesPath): void
{
$expectedFilesIterator = new \FilesystemIterator($expectedFilesPath);
$actualFilesIterator = new \RegexIterator(new \FilesystemIterator($actualFilesPath), '/.html/');
$this->assertEquals(
iterator_count($expectedFilesIterator),
iterator_count($actualFilesIterator),
\iterator_count($expectedFilesIterator),
\iterator_count($actualFilesIterator),
'Generated files and expected files not match'
);
@@ -89,13 +88,13 @@ class HTMLTest extends TestCase
/* @var \SplFileInfo $fileInfo */
$filename = $fileInfo->getFilename();
$actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
$actualFile = $actualFilesPath . \DIRECTORY_SEPARATOR . $filename;
$this->assertFileExists($actualFile);
$this->assertStringMatchesFormatFile(
$fileInfo->getPathname(),
str_replace(PHP_EOL, "\n", file_get_contents($actualFile)),
\str_replace(\PHP_EOL, "\n", \file_get_contents($actualFile)),
"${filename} not match"
);
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Report;
use SebastianBergmann\CodeCoverage\TestCase;
@@ -17,33 +16,33 @@ use SebastianBergmann\CodeCoverage\TestCase;
*/
class TextTest extends TestCase
{
public function testTextForBankAccountTest()
public function testTextForBankAccountTest(): void
{
$text = new Text(50, 90, false, false);
$this->assertStringMatchesFormatFile(
TEST_FILES_PATH . 'BankAccount-text.txt',
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount()))
\str_replace(\PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount()))
);
}
public function testTextForFileWithIgnoredLines()
public function testTextForFileWithIgnoredLines(): void
{
$text = new Text(50, 90, false, false);
$this->assertStringMatchesFormatFile(
TEST_FILES_PATH . 'ignored-lines-text.txt',
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines()))
\str_replace(\PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines()))
);
}
public function testTextForClassWithAnonymousFunction()
public function testTextForClassWithAnonymousFunction(): void
{
$text = new Text(50, 90, false, false);
$this->assertStringMatchesFormatFile(
TEST_FILES_PATH . 'class-with-anonymous-function-text.txt',
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction()))
\str_replace(\PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction()))
);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage;
use PHPUnit\Framework\TestCase;
@@ -17,7 +16,7 @@ use PHPUnit\Framework\TestCase;
*/
class UtilTest extends TestCase
{
public function testPercent()
public function testPercent(): void
{
$this->assertEquals(100, Util::percent(100, 0));
$this->assertEquals(100, Util::percent(100, 100));

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the php-code-coverage package.
*
@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\CodeCoverage\Report\Xml;
use SebastianBergmann\CodeCoverage\TestCase;
@@ -16,14 +15,14 @@ class XmlTest extends TestCase
{
private static $TEST_REPORT_PATH_SOURCE;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . DIRECTORY_SEPARATOR . 'XML';
self::$TEST_REPORT_PATH_SOURCE = TEST_FILES_PATH . 'Report' . \DIRECTORY_SEPARATOR . 'XML';
}
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
@@ -31,13 +30,13 @@ class XmlTest extends TestCase
foreach ($tmpFilesIterator as $path => $fileInfo) {
/* @var \SplFileInfo $fileInfo */
unlink($fileInfo->getPathname());
\unlink($fileInfo->getPathname());
}
}
public function testForBankAccountTest()
public function testForBankAccountTest(): void
{
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForBankAccount';
$xml = new Facade('1.0.0');
$xml->process($this->getCoverageForBankAccount(), self::$TEST_TMP_PATH);
@@ -45,9 +44,9 @@ class XmlTest extends TestCase
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
}
public function testForFileWithIgnoredLines()
public function testForFileWithIgnoredLines(): void
{
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForFileWithIgnoredLines';
$xml = new Facade('1.0.0');
$xml->process($this->getCoverageForFileWithIgnoredLines(), self::$TEST_TMP_PATH);
@@ -55,9 +54,9 @@ class XmlTest extends TestCase
$this->assertFilesEquals($expectedFilesPath, self::$TEST_TMP_PATH);
}
public function testForClassWithAnonymousFunction()
public function testForClassWithAnonymousFunction(): void
{
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
$expectedFilesPath = self::$TEST_REPORT_PATH_SOURCE . \DIRECTORY_SEPARATOR . 'CoverageForClassWithAnonymousFunction';
$xml = new Facade('1.0.0');
$xml->process($this->getCoverageForClassWithAnonymousFunction(), self::$TEST_TMP_PATH);
@@ -69,14 +68,14 @@ class XmlTest extends TestCase
* @param string $expectedFilesPath
* @param string $actualFilesPath
*/
private function assertFilesEquals($expectedFilesPath, $actualFilesPath)
private function assertFilesEquals($expectedFilesPath, $actualFilesPath): void
{
$expectedFilesIterator = new \FilesystemIterator($expectedFilesPath);
$actualFilesIterator = new \FilesystemIterator($actualFilesPath);
$this->assertEquals(
iterator_count($expectedFilesIterator),
iterator_count($actualFilesIterator),
\iterator_count($expectedFilesIterator),
\iterator_count($actualFilesIterator),
'Generated files and expected files not match'
);
@@ -84,13 +83,13 @@ class XmlTest extends TestCase
/* @var \SplFileInfo $fileInfo */
$filename = $fileInfo->getFilename();
$actualFile = $actualFilesPath . DIRECTORY_SEPARATOR . $filename;
$actualFile = $actualFilesPath . \DIRECTORY_SEPARATOR . $filename;
$this->assertFileExists($actualFile);
$this->assertStringMatchesFormatFile(
$fileInfo->getPathname(),
file_get_contents($actualFile),
\file_get_contents($actualFile),
"${filename} not match"
);
}