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.9 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.9
      • 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
  • None

Classes

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