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

  • CakeTestCase
  • CakeTestLoader
  • CakeTestRunner
  • CakeTestSuite
  • CakeTestSuiteCommand
  • CakeTestSuiteDispatcher
  • ControllerTestCase
  • ControllerTestDispatcher
  • InterceptContentHelper
  1: <?php
  2: /**
  3:  * TestRunner for CakePHP Test suite.
  4:  *
  5:  * PHP 5
  6:  *
  7:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  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 2.0
 17:  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 18:  */
 19: 
 20: require_once 'PHPUnit/TextUI/TestRunner.php';
 21: 
 22: App::uses('CakeFixtureManager', 'TestSuite/Fixture');
 23: 
 24: /**
 25:  * A custom test runner for Cake's use of PHPUnit.
 26:  *
 27:  * @package       Cake.TestSuite
 28:  */
 29: class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
 30: 
 31: /**
 32:  * Lets us pass in some options needed for cake's webrunner.
 33:  *
 34:  * @param mixed $loader
 35:  * @param array $params list of options to be used for this run
 36:  * @return void
 37:  */
 38:     public function __construct($loader, $params) {
 39:         parent::__construct($loader);
 40:         $this->_params = $params;
 41:     }
 42: 
 43: /**
 44:  * Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager
 45:  *
 46:  * @param PHPUnit_Framework_Test $suite
 47:  * @param array $arguments
 48:  * @return void
 49:  */
 50:     public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) {
 51:         if (isset($arguments['printer'])) {
 52:             self::$versionStringPrinted = true;
 53:         }
 54: 
 55:         $fixture = $this->_getFixtureManager($arguments);
 56:         foreach ($suite->getIterator() as $test) {
 57:             if ($test instanceof CakeTestCase) {
 58:                 $fixture->fixturize($test);
 59:                 $test->fixtureManager = $fixture;
 60:             }
 61:         }
 62: 
 63:         $return = parent::doRun($suite, $arguments);
 64:         $fixture->shutdown();
 65:         return $return;
 66:     }
 67: 
 68: // @codingStandardsIgnoreStart PHPUnit overrides don't match CakePHP
 69: /**
 70:  * Create the test result and splice on our code coverage reports.
 71:  *
 72:  * @return PHPUnit_Framework_TestResult
 73:  */
 74:     protected function createTestResult() {
 75:         $result = new PHPUnit_Framework_TestResult;
 76:         if (!empty($this->_params['codeCoverage'])) {
 77:             if (method_exists($result, 'collectCodeCoverageInformation')) {
 78:                 $result->collectCodeCoverageInformation(true);
 79:             }
 80:             if (method_exists($result, 'setCodeCoverage')) {
 81:                 $result->setCodeCoverage(new PHP_CodeCoverage());
 82:             }
 83:         }
 84:         return $result;
 85:     }
 86: // @codingStandardsIgnoreEnd
 87: 
 88: /**
 89:  * Get the fixture manager class specified or use the default one.
 90:  *
 91:  * @param array $arguments
 92:  * @return mixed instance of a fixture manager.
 93:  * @throws RuntimeException When fixture manager class cannot be loaded.
 94:  */
 95:     protected function _getFixtureManager($arguments) {
 96:         if (isset($arguments['fixtureManager'])) {
 97:             App::uses($arguments['fixtureManager'], 'TestSuite');
 98:             if (class_exists($arguments['fixtureManager'])) {
 99:                 return new $arguments['fixtureManager'];
100:             }
101:             throw new RuntimeException(__d('cake_dev', 'Could not find fixture manager %s.', $arguments['fixtureManager']));
102:         }
103:         App::uses('AppFixtureManager', 'TestSuite');
104:         if (class_exists('AppFixtureManager')) {
105:             return new AppFixtureManager();
106:         }
107:         return new CakeFixtureManager();
108:     }
109: 
110: }
111: 
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