CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • CakeBaseReporter
  • CakeHtmlReporter
  • CakeTextReporter
  1: <?php
  2: /**
  3:  * CakeBaseReporter contains common functionality to all cake test suite reporters.
  4:  *
  5:  * PHP 5
  6:  *
  7:  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  8:  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9:  *
 10:  * Licensed under The MIT License
 11:  * For full copyright and license information, please see the LICENSE.txt
 12:  * Redistributions of files must retain the above copyright notice
 13:  *
 14:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 15:  * @link          http://cakephp.org CakePHP(tm) Project
 16:  * @since         CakePHP(tm) v 1.3
 17:  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 18:  */
 19: 
 20: require_once 'PHPUnit/TextUI/ResultPrinter.php';
 21: 
 22: /**
 23:  * CakeBaseReporter contains common reporting features used in the CakePHP Test suite
 24:  *
 25:  * @package       Cake.TestSuite.Reporter
 26:  */
 27: class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
 28: 
 29: /**
 30:  * Headers sent
 31:  *
 32:  * @var boolean
 33:  */
 34:     protected $_headerSent = false;
 35: 
 36: /**
 37:  * Array of request parameters. Usually parsed GET params.
 38:  *
 39:  * @var array
 40:  */
 41:     public $params = array();
 42: 
 43: /**
 44:  * Character set for the output of test reporting.
 45:  *
 46:  * @var string
 47:  */
 48:     protected $_characterSet;
 49: 
 50: /**
 51:  * Does nothing yet. The first output will
 52:  * be sent on the first test start.
 53:  *
 54:  * ### Params
 55:  *
 56:  * - show_passes - Should passes be shown
 57:  * - plugin - Plugin test being run?
 58:  * - core - Core test being run.
 59:  * - case - The case being run
 60:  * - codeCoverage - Whether the case/group being run is being code covered.
 61:  *
 62:  * @param string $charset The character set to output with. Defaults to UTF-8
 63:  * @param array $params Array of request parameters the reporter should use. See above.
 64:  */
 65:     public function __construct($charset = 'utf-8', $params = array()) {
 66:         if (!$charset) {
 67:             $charset = 'utf-8';
 68:         }
 69:         $this->_characterSet = $charset;
 70:         $this->params = $params;
 71:     }
 72: 
 73: /**
 74:  * Retrieves a list of test cases from the active Manager class,
 75:  * displaying it in the correct format for the reporter subclass
 76:  *
 77:  * @return mixed
 78:  */
 79:     public function testCaseList() {
 80:         $testList = CakeTestLoader::generateTestList($this->params);
 81:         return $testList;
 82:     }
 83: 
 84: /**
 85:  * Paints the start of the response from the test suite.
 86:  * Used to paint things like head elements in an html page.
 87:  *
 88:  * @return void
 89:  */
 90:     public function paintDocumentStart() {
 91:     }
 92: 
 93: /**
 94:  * Paints the end of the response from the test suite.
 95:  * Used to paint things like </body> in an html page.
 96:  *
 97:  * @return void
 98:  */
 99:     public function paintDocumentEnd() {
100:     }
101: 
102: /**
103:  * Paint a list of test sets, core, app, and plugin test sets
104:  * available.
105:  *
106:  * @return void
107:  */
108:     public function paintTestMenu() {
109:     }
110: 
111: /**
112:  * Get the baseUrl if one is available.
113:  *
114:  * @return string The base url for the request.
115:  */
116:     public function baseUrl() {
117:         if (!empty($_SERVER['PHP_SELF'])) {
118:             return $_SERVER['PHP_SELF'];
119:         }
120:         return '';
121:     }
122: 
123: /**
124:  * Print result
125:  *
126:  * @param PHPUnit_Framework_TestResult $result
127:  */
128:     public function printResult(PHPUnit_Framework_TestResult $result) {
129:         $this->paintFooter($result);
130:     }
131: 
132: /**
133:  * Paint result
134:  *
135:  * @param PHPUnit_Framework_TestResult $result
136:  */
137:     public function paintResult(PHPUnit_Framework_TestResult $result) {
138:         $this->paintFooter($result);
139:     }
140: 
141: /**
142:  * An error occurred.
143:  *
144:  * @param  PHPUnit_Framework_Test $test
145:  * @param  Exception              $e
146:  * @param  float                  $time
147:  */
148:     public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
149:         $this->paintException($e, $test);
150:     }
151: 
152: /**
153:  * A failure occurred.
154:  *
155:  * @param  PHPUnit_Framework_Test $test
156:  * @param  PHPUnit_Framework_AssertionFailedError $e
157:  * @param  float $time
158:  */
159:     public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
160:         $this->paintFail($e, $test);
161:     }
162: 
163: /**
164:  * Incomplete test.
165:  *
166:  * @param  PHPUnit_Framework_Test $test
167:  * @param  Exception $e
168:  * @param  float $time
169:  */
170:     public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
171:         $this->paintSkip($e, $test);
172:     }
173: 
174: /**
175:  * Skipped test.
176:  *
177:  * @param  PHPUnit_Framework_Test $test
178:  * @param  Exception $e
179:  * @param  float $time
180:  */
181:     public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
182:         $this->paintSkip($e, $test);
183:     }
184: 
185: /**
186:  * A test suite started.
187:  *
188:  * @param  PHPUnit_Framework_TestSuite $suite
189:  */
190:     public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
191:         if (!$this->_headerSent) {
192:             echo $this->paintHeader();
193:         }
194:         echo __d('cake_dev', 'Running  %s', $suite->getName()) . "\n";
195:     }
196: 
197: /**
198:  * A test suite ended.
199:  *
200:  * @param  PHPUnit_Framework_TestSuite $suite
201:  */
202:     public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
203:     }
204: 
205: /**
206:  * A test started.
207:  *
208:  * @param  PHPUnit_Framework_Test $test
209:  */
210:     public function startTest(PHPUnit_Framework_Test $test) {
211:     }
212: 
213: /**
214:  * A test ended.
215:  *
216:  * @param  PHPUnit_Framework_Test $test
217:  * @param  float $time
218:  */
219:     public function endTest(PHPUnit_Framework_Test $test, $time) {
220:         $this->numAssertions += $test->getNumAssertions();
221:         if ($test->hasFailed()) {
222:             return;
223:         }
224:         $this->paintPass($test, $time);
225:     }
226: 
227: }
228: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs