@@ -1812,4 +1812,128 @@ protected function removeTemporaryFiles(): void
18121812 $ fileInfo ->isDir () ? rmdir ($ pathname ) : unlink ($ pathname );
18131813 }
18141814 }
1815+
1816+ protected function getCoverageForFilesWithUncoveredIncluded (): CodeCoverage
1817+ {
1818+ $ data = $ this ->getLineCoverageXdebugDataForBankAccount ();
1819+
1820+ $ stub = $ this ->createStub (Driver::class);
1821+
1822+ $ stub ->method ('stop ' )
1823+ ->will ($ this ->onConsecutiveCalls (...$ data ));
1824+
1825+ $ filter = new Filter ;
1826+ $ filter ->includeFile (TEST_FILES_PATH . 'BankAccount.php ' );
1827+ $ filter ->includeFile (TEST_FILES_PATH . 'NamespacedBankAccount.php ' );
1828+
1829+ $ coverage = new CodeCoverage ($ stub , $ filter );
1830+ $ coverage ->includeUncoveredFiles ();
1831+
1832+ $ coverage ->start (
1833+ new BankAccountTest ('testBalanceIsInitiallyZero ' ),
1834+ true
1835+ );
1836+
1837+ $ coverage ->stop (
1838+ true ,
1839+ [TEST_FILES_PATH . 'BankAccount.php ' => range (6 , 9 )]
1840+ );
1841+
1842+ $ coverage ->start (
1843+ new BankAccountTest ('testBalanceCannotBecomeNegative ' )
1844+ );
1845+
1846+ $ coverage ->stop (
1847+ true ,
1848+ [TEST_FILES_PATH . 'BankAccount.php ' => range (27 , 32 )]
1849+ );
1850+
1851+ $ coverage ->start (
1852+ new BankAccountTest ('testBalanceCannotBecomeNegative2 ' )
1853+ );
1854+
1855+ $ coverage ->stop (
1856+ true ,
1857+ [TEST_FILES_PATH . 'BankAccount.php ' => range (20 , 25 )]
1858+ );
1859+
1860+ $ coverage ->start (
1861+ new BankAccountTest ('testDepositWithdrawMoney ' )
1862+ );
1863+
1864+ $ coverage ->stop (
1865+ true ,
1866+ [
1867+ TEST_FILES_PATH . 'BankAccount.php ' => array_merge (
1868+ range (6 , 9 ),
1869+ range (20 , 25 ),
1870+ range (27 , 32 )
1871+ ),
1872+ ]
1873+ );
1874+
1875+ return $ coverage ;
1876+ }
1877+
1878+ protected function getCoverageForFilesWithUncoveredExcluded (): CodeCoverage
1879+ {
1880+ $ data = $ this ->getLineCoverageXdebugDataForBankAccount ();
1881+
1882+ $ stub = $ this ->createStub (Driver::class);
1883+
1884+ $ stub ->method ('stop ' )
1885+ ->will ($ this ->onConsecutiveCalls (...$ data ));
1886+
1887+ $ filter = new Filter ;
1888+ $ filter ->includeFile (TEST_FILES_PATH . 'BankAccount.php ' );
1889+ $ filter ->includeFile (TEST_FILES_PATH . 'NamespacedBankAccount.php ' );
1890+
1891+ $ coverage = new CodeCoverage ($ stub , $ filter );
1892+ $ coverage ->excludeUncoveredFiles ();
1893+
1894+ $ coverage ->start (
1895+ new BankAccountTest ('testBalanceIsInitiallyZero ' ),
1896+ true
1897+ );
1898+
1899+ $ coverage ->stop (
1900+ true ,
1901+ [TEST_FILES_PATH . 'BankAccount.php ' => range (6 , 9 )]
1902+ );
1903+
1904+ $ coverage ->start (
1905+ new BankAccountTest ('testBalanceCannotBecomeNegative ' )
1906+ );
1907+
1908+ $ coverage ->stop (
1909+ true ,
1910+ [TEST_FILES_PATH . 'BankAccount.php ' => range (27 , 32 )]
1911+ );
1912+
1913+ $ coverage ->start (
1914+ new BankAccountTest ('testBalanceCannotBecomeNegative2 ' )
1915+ );
1916+
1917+ $ coverage ->stop (
1918+ true ,
1919+ [TEST_FILES_PATH . 'BankAccount.php ' => range (20 , 25 )]
1920+ );
1921+
1922+ $ coverage ->start (
1923+ new BankAccountTest ('testDepositWithdrawMoney ' )
1924+ );
1925+
1926+ $ coverage ->stop (
1927+ true ,
1928+ [
1929+ TEST_FILES_PATH . 'BankAccount.php ' => array_merge (
1930+ range (6 , 9 ),
1931+ range (20 , 25 ),
1932+ range (27 , 32 )
1933+ ),
1934+ ]
1935+ );
1936+
1937+ return $ coverage ;
1938+ }
18151939}
0 commit comments