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

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.10
      • 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 (https://cakephp.org)
  6:  * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
 13:  * @link          https://cakephp.org CakePHP(tm) Project
 14:  * @since         CakePHP(tm) v 2.0
 15:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 16:  */
 17: 
 18: if (!class_exists('PHPUnit_TextUI_TestRunner')) {
 19:     require_once 'PHPUnit/TextUI/TestRunner.php';
 20: }
 21: if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
 22:     class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage');
 23:     class_alias('SebastianBergmann\CodeCoverage\Report\Text', 'PHP_CodeCoverage_Report_Text');
 24:     class_alias('SebastianBergmann\CodeCoverage\Report\PHP', 'PHP_CodeCoverage_Report_PHP');
 25:     class_alias('SebastianBergmann\CodeCoverage\Report\Clover', 'PHP_CodeCoverage_Report_Clover');
 26:     class_alias('SebastianBergmann\CodeCoverage\Report\Html\Facade', 'PHP_CodeCoverage_Report_HTML');
 27:     class_alias('SebastianBergmann\CodeCoverage\Exception', 'PHP_CodeCoverage_Exception');
 28: }
 29: 
 30: App::uses('CakeFixtureManager', 'TestSuite/Fixture');
 31: 
 32: /**
 33:  * A custom test runner for CakePHP's use of PHPUnit.
 34:  *
 35:  * @package       Cake.TestSuite
 36:  */
 37: class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
 38: 
 39: /**
 40:  * Lets us pass in some options needed for CakePHP's webrunner.
 41:  *
 42:  * @param mixed $loader The test suite loader
 43:  * @param array $params list of options to be used for this run
 44:  */
 45:     public function __construct($loader, $params) {
 46:         parent::__construct($loader);
 47:         $this->_params = $params;
 48:     }
 49: 
 50: /**
 51:  * Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager
 52:  *
 53:  * @param PHPUnit_Framework_Test $suite The test suite to run
 54:  * @param array $arguments The CLI arguments
 55:  * @param bool $exit Exits by default or returns the results
 56:  * This argument is ignored if >PHPUnit5.2.0
 57:  * @return void
 58:  */
 59:     public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array(), $exit = true) {
 60:         if (isset($arguments['printer'])) {
 61:             static::$versionStringPrinted = true;
 62:         }
 63: 
 64:         $fixture = $this->_getFixtureManager($arguments);
 65:         $iterator = $suite->getIterator();
 66:         if ($iterator instanceof RecursiveIterator) {
 67:             $iterator = new RecursiveIteratorIterator($iterator);
 68:         }
 69:         foreach ($iterator as $test) {
 70:             if ($test instanceof CakeTestCase) {
 71:                 $fixture->fixturize($test);
 72:                 $test->fixtureManager = $fixture;
 73:             }
 74:         }
 75: 
 76:         $return = parent::doRun($suite, $arguments, $exit);
 77:         $fixture->shutdown();
 78:         return $return;
 79:     }
 80: 
 81: // @codingStandardsIgnoreStart PHPUnit overrides don't match CakePHP
 82: /**
 83:  * Create the test result and splice on our code coverage reports.
 84:  *
 85:  * @return PHPUnit_Framework_TestResult
 86:  */
 87:     protected function createTestResult() {
 88:         $result = new PHPUnit_Framework_TestResult;
 89:         if (!empty($this->_params['codeCoverage'])) {
 90:             if (method_exists($result, 'collectCodeCoverageInformation')) {
 91:                 $result->collectCodeCoverageInformation(true);
 92:             }
 93:             if (method_exists($result, 'setCodeCoverage')) {
 94:                 $result->setCodeCoverage(new PHP_CodeCoverage());
 95:             }
 96:         }
 97:         return $result;
 98:     }
 99: // @codingStandardsIgnoreEnd
100: 
101: /**
102:  * Get the fixture manager class specified or use the default one.
103:  *
104:  * @param array $arguments The CLI arguments.
105:  * @return mixed instance of a fixture manager.
106:  * @throws RuntimeException When fixture manager class cannot be loaded.
107:  */
108:     protected function _getFixtureManager($arguments) {
109:         if (!empty($arguments['fixtureManager'])) {
110:             App::uses($arguments['fixtureManager'], 'TestSuite');
111:             if (class_exists($arguments['fixtureManager'])) {
112:                 return new $arguments['fixtureManager'];
113:             }
114:             throw new RuntimeException(__d('cake_dev', 'Could not find fixture manager %s.', $arguments['fixtureManager']));
115:         }
116:         App::uses('AppFixtureManager', 'TestSuite');
117:         if (class_exists('AppFixtureManager')) {
118:             return new AppFixtureManager();
119:         }
120:         return new CakeFixtureManager();
121:     }
122: 
123: }
124: 
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