mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-05 07:33:39 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -6,18 +6,22 @@
|
|||
* PHP5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.TestSuite.Coverage
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Inflector', 'Utility');
|
||||
App::uses('CakePlugin', 'Core');
|
||||
|
||||
/**
|
||||
* Abstract class for common CoverageReport methods.
|
||||
* Provides several template methods for custom output.
|
||||
|
@ -48,7 +52,7 @@ abstract class BaseCoverageReport {
|
|||
public $pluginTest = false;
|
||||
|
||||
/**
|
||||
* Array of test case file names. Used to do basename() matching with
|
||||
* Array of test case file names. Used to do basename() matching with
|
||||
* files that have coverage to decide which results to show on page load.
|
||||
*
|
||||
* @var array
|
||||
|
@ -60,7 +64,6 @@ abstract class BaseCoverageReport {
|
|||
*
|
||||
* @param array $coverage Array of coverage data from PHPUnit_Test_Result
|
||||
* @param CakeBaseReporter $reporter A reporter to use for the coverage report.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($coverage, CakeBaseReporter $reporter) {
|
||||
$this->_rawCoverage = $coverage;
|
||||
|
@ -95,14 +98,14 @@ abstract class BaseCoverageReport {
|
|||
/**
|
||||
* Gets the base path that the files we are interested in live in.
|
||||
*
|
||||
* @return void
|
||||
* @return string Path
|
||||
*/
|
||||
public function getPathFilter() {
|
||||
$path = ROOT . DS;
|
||||
if ($this->appTest) {
|
||||
$path .= APP_DIR . DS;
|
||||
} elseif ($this->pluginTest) {
|
||||
$path = App::pluginPath($this->pluginTest);
|
||||
$path = CakePlugin::path($this->pluginTest);
|
||||
} else {
|
||||
$path = CAKE;
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ abstract class BaseCoverageReport {
|
|||
}
|
||||
|
||||
/**
|
||||
* Filters the coverage data by path. Files not in the provided path will be removed.
|
||||
* Filters the coverage data by path. Files not in the provided path will be removed.
|
||||
*
|
||||
* @param string $path Path to filter files by.
|
||||
* @return array Array of coverage data for files that match the given path.
|
||||
|
@ -134,9 +137,9 @@ abstract class BaseCoverageReport {
|
|||
* 3.5 uses -1 for uncovered, and -2 for dead.
|
||||
* 3.6 uses array() for uncovered and null for dead.
|
||||
*
|
||||
* @param array $fileLines
|
||||
* @param array $coverageData
|
||||
* @return array. Array of covered, total lines.
|
||||
* @param array $fileLines The lines in the file.
|
||||
* @param array $coverageData The raw coverage data.
|
||||
* @return array Array of covered, total lines.
|
||||
*/
|
||||
protected function _calculateCoveredLines($fileLines, $coverageData) {
|
||||
$covered = $total = 0;
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Generates code coverage reports in HTML from data obtained from PHPUnit
|
||||
*
|
||||
* PHP5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.TestSuite.Coverage
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('BaseCoverageReport', 'TestSuite/Coverage');
|
||||
|
@ -27,9 +26,23 @@ App::uses('BaseCoverageReport', 'TestSuite/Coverage');
|
|||
class HtmlCoverageReport extends BaseCoverageReport {
|
||||
|
||||
/**
|
||||
* Generates report html to display.
|
||||
* Holds the total number of processed rows.
|
||||
*
|
||||
* @return string compiled html report.
|
||||
* @var int
|
||||
*/
|
||||
protected $_total = 0;
|
||||
|
||||
/**
|
||||
* Holds the total number of covered rows.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_covered = 0;
|
||||
|
||||
/**
|
||||
* Generates report HTML to display.
|
||||
*
|
||||
* @return string Compiled HTML report.
|
||||
*/
|
||||
public function report() {
|
||||
$pathFilter = $this->getPathFilter();
|
||||
|
@ -47,6 +60,12 @@ HTML;
|
|||
$fileData = file($file);
|
||||
$output .= $this->generateDiff($file, $fileData, $coverageData);
|
||||
}
|
||||
|
||||
$percentCovered = 100;
|
||||
if ($this->_total > 0) {
|
||||
$percentCovered = round(100 * $this->_covered / $this->_total, 2);
|
||||
}
|
||||
$output .= '<div class="total">Overall coverage: <span class="coverage">' . $percentCovered . '%</span></div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -68,6 +87,8 @@ HTML;
|
|||
$diff = array();
|
||||
|
||||
list($covered, $total) = $this->_calculateCoveredLines($fileLines, $coverageData);
|
||||
$this->_covered += $covered;
|
||||
$this->_total += $total;
|
||||
|
||||
//shift line numbers forward one;
|
||||
array_unshift($fileLines, ' ');
|
||||
|
@ -104,9 +125,9 @@ HTML;
|
|||
}
|
||||
|
||||
/**
|
||||
* Guess the classname the test was for based on the test case filename.
|
||||
* Guess the class name the test was for based on the test case filename.
|
||||
*
|
||||
* @param ReflectionClass $testReflection.
|
||||
* @param ReflectionClass $testReflection The class to reflect
|
||||
* @return string Possible test subject name.
|
||||
*/
|
||||
protected function _guessSubjectName($testReflection) {
|
||||
|
@ -120,9 +141,13 @@ HTML;
|
|||
}
|
||||
|
||||
/**
|
||||
* Renders the html for a single line in the html diff.
|
||||
* Renders the HTML for a single line in the HTML diff.
|
||||
*
|
||||
* @return void
|
||||
* @param string $line The line content.
|
||||
* @param int $linenumber The line number
|
||||
* @param string $class The classname to use.
|
||||
* @param array $coveringTests The tests covering the line.
|
||||
* @return string
|
||||
*/
|
||||
protected function _paintLine($line, $linenumber, $class, $coveringTests) {
|
||||
$coveredBy = '';
|
||||
|
@ -145,21 +170,21 @@ HTML;
|
|||
/**
|
||||
* generate some javascript for the coverage report.
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
public function coverageScript() {
|
||||
return <<<HTML
|
||||
<script type="text/javascript">
|
||||
function coverage_show_hide(selector) {
|
||||
var element = document.getElementById(selector);
|
||||
element.style.display = (element.style.display == 'none') ? '' : 'none';
|
||||
element.style.display = (element.style.display === 'none') ? '' : 'none';
|
||||
}
|
||||
function coverage_toggle_all() {
|
||||
var divs = document.querySelectorAll('div.coverage-container');
|
||||
var i = divs.length;
|
||||
while (i--) {
|
||||
if (divs[i] && divs[i].className.indexOf('primary') == -1) {
|
||||
divs[i].style.display = (divs[i].style.display == 'none') ? '' : 'none';
|
||||
divs[i].style.display = (divs[i].style.display === 'none') ? '' : 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,21 +195,24 @@ HTML;
|
|||
/**
|
||||
* Generate an HTML snippet for coverage headers
|
||||
*
|
||||
* @return void
|
||||
* @param string $filename The file name being covered
|
||||
* @param string $percent The percentage covered
|
||||
* @return string
|
||||
*/
|
||||
public function coverageHeader($filename, $percent) {
|
||||
$hash = md5($filename);
|
||||
$filename = basename($filename);
|
||||
list($file, $ext) = explode('.', $filename);
|
||||
list($file) = explode('.', $filename);
|
||||
$display = in_array($file, $this->_testNames) ? 'block' : 'none';
|
||||
$primary = $display == 'block' ? 'primary' : '';
|
||||
$primary = $display === 'block' ? 'primary' : '';
|
||||
return <<<HTML
|
||||
<div class="coverage-container $primary" style="display:$display;">
|
||||
<h4>
|
||||
<a href="#coverage-$filename" onclick="coverage_show_hide('coverage-$filename');">
|
||||
<a href="#coverage-$filename-$hash" onclick="coverage_show_hide('coverage-$filename-$hash');">
|
||||
$filename Code coverage: $percent%
|
||||
</a>
|
||||
</h4>
|
||||
<div class="code-coverage-results" id="coverage-$filename" style="display:none;">
|
||||
<div class="code-coverage-results" id="coverage-$filename-$hash" style="display:none;">
|
||||
<pre>
|
||||
HTML;
|
||||
}
|
||||
|
|
|
@ -5,16 +5,17 @@
|
|||
* PHP5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.TestSuite.Coverage
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('BaseCoverageReport', 'TestSuite/Coverage');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue