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

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