Browse Source

fix the ability to make code coverage reports

Puskás Zsolt 7 years ago
parent
commit
80c216b900

+ 3 - 0
.coveralls.yml

@@ -0,0 +1,3 @@
+service_name: travis-ci
+coverage_clover: build/logs/clover.xml
+json_path: build/logs/coveralls-upload.json

+ 3 - 0
.gitignore

@@ -12,3 +12,6 @@ application/logs/*
 # Composer
 # Composer
 /vendor/
 /vendor/
 composer.lock
 composer.lock
+
+# Coverage reports
+/build/logs/

+ 8 - 2
.travis.yml

@@ -6,8 +6,14 @@ php:
   - 7.1
   - 7.1
   - 7.2
   - 7.2
 
 
-script: 
-  - phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php
+before_script: 
+  - composer install
+
+script:
+  - vendor/bin/phpunit
+
+after_success:
+  - travis_retry vendor/bin/php-coveralls
 
 
 notifications:
 notifications:
   email: false
   email: false

+ 1 - 1
README.md

@@ -1,11 +1,11 @@
 [![Koseven Logo](https://i.imgur.com/2CeT8JL.png)](https://koseven.ga/)
 [![Koseven Logo](https://i.imgur.com/2CeT8JL.png)](https://koseven.ga/)
-
 [![Latest Stable Version](https://poser.pugx.org/koseven/koseven/v/stable)](https://packagist.org/packages/koseven/koseven)
 [![Latest Stable Version](https://poser.pugx.org/koseven/koseven/v/stable)](https://packagist.org/packages/koseven/koseven)
 [![Github Issues](http://githubbadges.herokuapp.com/koseven/koseven/issues.svg)](https://github.com/koseven/koseven/issues)
 [![Github Issues](http://githubbadges.herokuapp.com/koseven/koseven/issues.svg)](https://github.com/koseven/koseven/issues)
 [![Pending Pull-Requests](http://githubbadges.herokuapp.com/koseven/koseven/pulls.svg)](https://github.com/koseven/koseven/pulls)
 [![Pending Pull-Requests](http://githubbadges.herokuapp.com/koseven/koseven/pulls.svg)](https://github.com/koseven/koseven/pulls)
 [![License](https://poser.pugx.org/koseven/koseven/license.svg)](https://packagist.org/packages/koseven/koseven)
 [![License](https://poser.pugx.org/koseven/koseven/license.svg)](https://packagist.org/packages/koseven/koseven)
 [![Telegram](https://img.shields.io/badge/Telegram-joinChat-blue.svg)](https://telegram.me/koseven)
 [![Telegram](https://img.shields.io/badge/Telegram-joinChat-blue.svg)](https://telegram.me/koseven)
 [![Build Status](https://travis-ci.org/koseven/koseven.svg?branch=devel)](https://travis-ci.org/koseven/koseven)
 [![Build Status](https://travis-ci.org/koseven/koseven.svg?branch=devel)](https://travis-ci.org/koseven/koseven)
+[![Coverage Status](https://coveralls.io/repos/github/koseven/koseven/badge.svg?branch=devel)](https://coveralls.io/github/koseven/koseven?branch=devel)
 
 
 ## [Download 3.3.7](https://github.com/koseven/koseven/releases/tag/3.3.7)
 ## [Download 3.3.7](https://github.com/koseven/koseven/releases/tag/3.3.7)
 
 

+ 4 - 1
application/bootstrap.php

@@ -59,7 +59,10 @@ ini_set('unserialize_callback_func', 'spl_autoload_call');
 /**
 /**
  * Enable composer autoload libraries
  * Enable composer autoload libraries
  */
  */
-// require DOCROOT . '/vendor/autoload.php';
+if (is_file(DOCROOT.'/vendor/autoload.php'))
+{
+	require DOCROOT.'/vendor/autoload.php';
+}
 
 
 /**
 /**
  * Set the mb_substitute_character to "none"
  * Set the mb_substitute_character to "none"

+ 3 - 1
composer.json

@@ -30,7 +30,9 @@
   },
   },
   "require-dev": {
   "require-dev": {
     "phpunit/phpunit": "^6.0|^7.0",
     "phpunit/phpunit": "^6.0|^7.0",
-    "phpunit/dbunit":"3.*"
+    "phpunit/dbunit":"^3.0",
+    "phpunit/phpcov": "^4.0",
+    "php-coveralls/php-coveralls": "^2.0"
   },
   },
   "conflict": {
   "conflict": {
     "kohana/core": "3.3.*"
     "kohana/core": "3.3.*"

+ 2 - 0
modules/unittest/classes/Kohana/Unittest/Helpers.php

@@ -92,6 +92,7 @@ class Kohana_Unittest_Helpers {
 	 * * Static Variable
 	 * * Static Variable
 	 * * Config option
 	 * * Config option
 	 *
 	 *
+	 * @codeCoverageIgnore
 	 * @param array $environment List of environment to set
 	 * @param array $environment List of environment to set
 	 */
 	 */
 	public function set_environment(array $environment)
 	public function set_environment(array $environment)
@@ -159,6 +160,7 @@ class Kohana_Unittest_Helpers {
 	/**
 	/**
 	 * Restores the environment to the original state
 	 * Restores the environment to the original state
 	 *
 	 *
+	 * @codeCoverageIgnore
 	 * @chainable
 	 * @chainable
 	 * @return Kohana_Unittest_Helpers $this 
 	 * @return Kohana_Unittest_Helpers $this 
 	 */
 	 */

+ 5 - 0
modules/unittest/classes/Kohana/Unittest/TestCase.php

@@ -30,6 +30,8 @@ abstract class Kohana_Unittest_TestCase extends TestCase {
 	 *
 	 *
 	 * Extending classes that have their own setUp() should call
 	 * Extending classes that have their own setUp() should call
 	 * parent::setUp()
 	 * parent::setUp()
+	 * 
+	 * @codeCoverageIgnore
 	 */
 	 */
 	public function setUp()
 	public function setUp()
 	{
 	{
@@ -43,6 +45,8 @@ abstract class Kohana_Unittest_TestCase extends TestCase {
 	 *
 	 *
 	 * Extending classes that have their own tearDown()
 	 * Extending classes that have their own tearDown()
 	 * should call parent::tearDown()
 	 * should call parent::tearDown()
+	 * 
+	 * @codeCoverageIgnore
 	 */
 	 */
 	public function tearDown()
 	public function tearDown()
 	{
 	{
@@ -78,6 +82,7 @@ abstract class Kohana_Unittest_TestCase extends TestCase {
 	 * * Static Variable
 	 * * Static Variable
 	 * * Config option
 	 * * Config option
 	 *
 	 *
+	 * @codeCoverageIgnore
 	 * @param array $environment List of environment to set
 	 * @param array $environment List of environment to set
 	 */
 	 */
 	public function setEnvironment(array $environment)
 	public function setEnvironment(array $environment)

+ 6 - 26
modules/unittest/classes/Kohana/Unittest/TestSuite.php

@@ -2,22 +2,21 @@
 use PHPUnit\Framework\TestSuite;
 use PHPUnit\Framework\TestSuite;
 use PHPUnit\Framework\TestResult;
 use PHPUnit\Framework\TestResult;
 /**
 /**
- * A version of the stock PHPUnit testsuite that supports whitelisting and 
- * blacklisting for code coverage filter
+ * A version of the stock PHPUnit testsuite that supports whitelisting
+ * for code coverage filter
  */
  */
 abstract class Kohana_Unittest_TestSuite extends TestSuite 
 abstract class Kohana_Unittest_TestSuite extends TestSuite 
 {
 {
 	/**
 	/**
-	 * Holds the details of files that should be white and blacklisted for
+	 * Holds the details of files that should be whitelisted for
 	 * code coverage
 	 * code coverage
 	 * 
 	 * 
 	 * @var array
 	 * @var array
 	 */
 	 */
 	protected $_filter_calls = [
 	protected $_filter_calls = [
-		'addFileToBlacklist' => [],
-		'addDirectoryToBlacklist' => [],
-		'addFileToWhitelist' => []];
-	
+		'addFileToWhitelist' => []
+	];
+
 	/**
 	/**
      * Runs the tests and collects their result in a TestResult.
      * Runs the tests and collects their result in a TestResult.
      *
      *
@@ -31,7 +30,6 @@ abstract class Kohana_Unittest_TestSuite extends TestSuite
      */
      */
     public function run(TestResult $result = NULL): TestResult
     public function run(TestResult $result = NULL): TestResult
     {
     {
-		
 		// Get the code coverage filter from the suite's result object
 		// Get the code coverage filter from the suite's result object
 		$coverage = $result->getCodeCoverage();
 		$coverage = $result->getCodeCoverage();
 		
 		
@@ -51,25 +49,7 @@ abstract class Kohana_Unittest_TestSuite extends TestSuite
 		
 		
 		return parent::run($result);
 		return parent::run($result);
 	}
 	}
-	
-	/**
-	 * Queues a file to be added to the code coverage blacklist when the suite runs
-	 * @param string $file 
-	 */
-	public function addFileToBlacklist($file)
-	{
-		$this->_filter_calls['addFileToBlacklist'][] = $file;
-	}
 
 
-	/**
-	 * Queues a directory to be added to the code coverage blacklist when the suite runs
-	 * @param string $dir
-	 */
-	public function addDirectoryToBlacklist($dir)
-	{
-		$this->_filter_calls['addDirectoryToBlacklist'][] = $dir;
-	}
-	
 	/**
 	/**
 	 * Queues a file to be added to the code coverage whitelist when the suite runs
 	 * Queues a file to be added to the code coverage whitelist when the suite runs
 	 * @param string $file 
 	 * @param string $file 

+ 1 - 30
modules/unittest/classes/Kohana/Unittest/Tests.php

@@ -36,7 +36,7 @@ class Kohana_Unittest_Tests {
 	 * * Restores exception phpunit error handlers (for cli)
 	 * * Restores exception phpunit error handlers (for cli)
 	 * * registeres an autoloader to load test files
 	 * * registeres an autoloader to load test files
 	 */
 	 */
-	static public function configure_environment($do_whitelist = TRUE, $do_blacklist = TRUE)
+	static public function configure_environment()
 	{
 	{
 		restore_exception_handler();
 		restore_exception_handler();
 		restore_error_handler();
 		restore_error_handler();
@@ -44,7 +44,6 @@ class Kohana_Unittest_Tests {
 		spl_autoload_register(['Unittest_tests', 'autoload']);
 		spl_autoload_register(['Unittest_tests', 'autoload']);
 
 
 		Unittest_tests::$cache = (($cache = Kohana::cache('unittest_whitelist_cache')) === NULL) ? [] : $cache;
 		Unittest_tests::$cache = (($cache = Kohana::cache('unittest_whitelist_cache')) === NULL) ? [] : $cache;
-
 	}
 	}
 
 
 	/**
 	/**
@@ -72,11 +71,6 @@ class Kohana_Unittest_Tests {
 		{
 		{
 			Unittest_Tests::whitelist(NULL, $suite);
 			Unittest_Tests::whitelist(NULL, $suite);
 		}
 		}
-		
-		if (count($config['blacklist']))
-		{
-			Unittest_Tests::blacklist($config->blacklist, $suite);
-		}
 
 
 		// Add tests
 		// Add tests
 		$files = Kohana::list_files('tests');
 		$files = Kohana::list_files('tests');
@@ -119,34 +113,11 @@ class Kohana_Unittest_Tests {
 					{
 					{
 						require_once($file);
 						require_once($file);
 					}
 					}
-
-					$suite->addFileToBlacklist($file);
 				}
 				}
 			}
 			}
 		}
 		}
 	}
 	}
 
 
-	/**
-	 * Blacklist a set of files in PHPUnit code coverage
-	 *
-	 * @param array $blacklist_items A set of files to blacklist
-	 * @param Unittest_TestSuite $suite The test suite
-	 */
-	static public function blacklist(array $blacklist_items, Unittest_TestSuite $suite = NULL)
-	{
-		foreach ($blacklist_items as $item)
-		{
-			if (is_dir($item))
-			{
-				$suite->addDirectoryToBlacklist($item);
-			}
-			else
-			{
-				$suite->addFileToBlacklist($item);
-			}
-		}
-	}
-
 	/**
 	/**
 	 * Sets the whitelist
 	 * Sets the whitelist
 	 *
 	 *

Some files were not shown because too many files changed in this diff