diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index efc574aa4..0228c32ad 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -327,7 +327,7 @@ class ViewTask extends BakeTask { $this->hr(); $this->out(__d('cake_console', 'Controller Name: %s', $this->controllerName)); $this->out(__d('cake_console', 'Action Name: %s', $action)); - $this->out(__d('cake_console', 'Path: %s', $this->params['app'] . DS . 'View' . DS . $this->controllerName . DS . Inflector::underscore($action) . ".ctp")); + $this->out(__d('cake_console', 'Path: %s', $this->getPath() . $this->controllerName . DS . Inflector::underscore($action) . ".ctp")); $this->hr(); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y'); if (strtolower($looksGood) == 'y') { diff --git a/lib/Cake/Console/Command/UpgradeShell.php b/lib/Cake/Console/Command/UpgradeShell.php index b4cc4fe09..3c619da2d 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -102,7 +102,7 @@ class UpgradeShell extends Shell { public function tests() { $this->_paths = array(APP . 'tests' . DS); if (!empty($this->params['plugin'])) { - $this->_paths = App::pluginPath($this->params['plugin']) . 'tests' . DS; + $this->_paths = array(App::pluginPath($this->params['plugin']) . 'tests' . DS); } $patterns = array( array( @@ -225,6 +225,7 @@ class UpgradeShell extends Shell { } $helpers = array_merge($pluginHelpers, $helpers); foreach ($helpers as $helper) { + $helper = preg_replace('/Helper$/', '', $helper); $oldHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1); $patterns[] = array( "\${$oldHelper} to \$this->{$helper}", diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index c2234deba..dadb8f7bc 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -447,6 +447,9 @@ class App { if (empty($path)) { $path = self::path($type, $plugin); + if (empty($plugin)) { + $path = array_merge($path, App::core($type)); + } } foreach ((array)$path as $dir) { diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index e28e0a65d..2e8df40cb 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -39,9 +39,9 @@ if (function_exists('mb_internal_encoding')) { class I18n { /** - * Instance of the I10n class for localization + * Instance of the L10n class for localization * - * @var I10n + * @var L10n */ public $l10n = null; @@ -91,6 +91,15 @@ class I18n { 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES' ); +/** + * Constructor, use I18n::getInstance() to get the i18n translation object. + * + * @return void + */ + protected function __construct() { + $this->l10n = new L10n(); + } + /** * Return a static instance of the I18n class * @@ -100,7 +109,6 @@ class I18n { static $instance = array(); if (!$instance) { $instance[0] = new I18n(); - $instance[0]->l10n = new L10n(); } return $instance[0]; } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 35dc9bdc6..3442a54bb 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2244,26 +2244,28 @@ class Model extends Object { $savedAssociatons = $this->__backAssociation; $this->__backAssociation = array(); } - foreach (array_merge($this->hasMany, $this->hasOne) as $assoc => $data) { - if ($data['dependent'] === true && $cascade === true) { + if ($cascade === true) { + foreach (array_merge($this->hasMany, $this->hasOne) as $assoc => $data) { + if ($data['dependent'] === true) { - $model = $this->{$assoc}; - $conditions = array($model->escapeField($data['foreignKey']) => $id); - if ($data['conditions']) { - $conditions = array_merge((array)$data['conditions'], $conditions); - } - $model->recursive = -1; + $model = $this->{$assoc}; + $conditions = array($model->escapeField($data['foreignKey']) => $id); + if ($data['conditions']) { + $conditions = array_merge((array)$data['conditions'], $conditions); + } + $model->recursive = -1; - if (isset($data['exclusive']) && $data['exclusive']) { - $model->deleteAll($conditions); - } else { - $records = $model->find('all', array( - 'conditions' => $conditions, 'fields' => $model->primaryKey - )); + if (isset($data['exclusive']) && $data['exclusive']) { + $model->deleteAll($conditions); + } else { + $records = $model->find('all', array( + 'conditions' => $conditions, 'fields' => $model->primaryKey + )); - if (!empty($records)) { - foreach ($records as $record) { - $model->delete($record[$model->alias][$model->primaryKey]); + if (!empty($records)) { + foreach ($records as $record) { + $model->delete($record[$model->alias][$model->primaryKey]); + } } } } diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index 6d828e16c..71daef88a 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -129,11 +129,11 @@ class CacheTest extends CakeTestCase { /** * test that trying to configure classes that don't extend CacheEngine fail. * + * @expectedException CacheException * @return void */ public function testAttemptingToConfigureANonCacheEngineClass() { $this->getMock('StdClass', array(), array(), 'RubbishEngine'); - $this->expectException(); Cache::config('Garbage', array( 'engine' => 'Rubbish' )); diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 581615b46..1652b9267 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -431,7 +431,6 @@ class ViewTaskTest extends CakeTestCase { */ public function testCustomAction() { $this->Task->controllerName = 'ViewTaskComments'; - $this->Task->params['app'] = APP; $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('', 'my_action', 'y')); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php index ff726d8c1..25625bb65 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php @@ -56,7 +56,7 @@ class CrudAuthorizeTest extends CakeTestCase { /** * test authorize() without a mapped action, ensure an error is generated. * - * @expectedException Exception + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testAuthorizeNoMappedAction() { diff --git a/lib/Cake/Test/Case/Controller/Component/DbAclTest.php b/lib/Cake/Test/Case/Controller/Component/DbAclTest.php index 6d7546c76..48e5cb109 100644 --- a/lib/Cake/Test/Case/Controller/Component/DbAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/DbAclTest.php @@ -249,6 +249,7 @@ class DbAclTest extends CakeTestCase { /** * testDbAclAllow method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testAllow() { @@ -279,17 +280,16 @@ class DbAclTest extends CakeTestCase { // Samir should still have his tpsReports/view permissions, but does not $this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update')); - $this->expectError(); $this->assertFalse($this->Acl->allow('Lumbergh', 'ROOT/tpsReports/DoesNotExist', 'create')); } /** * testAllowInvalidNode method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testAllowInvalidNode() { - $this->expectError(); $this->Acl->allow('Homer', 'tpsReports', 'create'); } @@ -316,31 +316,31 @@ class DbAclTest extends CakeTestCase { /** * testCheckInvalidNode method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testCheckInvalidNode() { - $this->expectError(); $this->assertFalse($this->Acl->check('WRONG', 'tpsReports', 'read')); } /** * testCheckInvalidPermission method * + * @expectedException PHPUnit_Framework_Error_Notice * @return void */ public function testCheckInvalidPermission() { - $this->expectError(); - $this->assertFalse($this->Acl->check('Lumbergh', 'smash', 'foobar')); + $this->Acl->check('Lumbergh', 'smash', 'foobar'); } /** * testCheckMissingPermission method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testCheckMissingPermission() { - $this->expectError(); - $this->assertFalse($this->Acl->check('users', 'NonExistant', 'read')); + $this->Acl->check('users', 'NonExistant', 'read'); } /** @@ -363,6 +363,7 @@ class DbAclTest extends CakeTestCase { /** * testDbAclDeny method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testDeny() { @@ -385,7 +386,6 @@ class DbAclTest extends CakeTestCase { $expected = '-1'; $this->assertEqual($result[0]['PermissionTwoTest']['_delete'], $expected); - $this->expectError(); $this->assertFalse($this->Acl->deny('Lumbergh', 'ROOT/tpsReports/DoesNotExist', 'create')); } @@ -433,6 +433,7 @@ class DbAclTest extends CakeTestCase { /** * testDbGrant method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testGrant() { @@ -447,13 +448,13 @@ class DbAclTest extends CakeTestCase { $this->assertTrue($this->Acl->check('Micheal', 'view', 'update')); $this->assertFalse($this->Acl->check('Micheal', 'view', 'delete')); - $this->expectError(); $this->assertFalse($this->Acl->allow('Peter', 'ROOT/tpsReports/DoesNotExist', 'create')); } /** * testDbRevoke method * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testRevoke() { @@ -467,8 +468,7 @@ class DbAclTest extends CakeTestCase { $this->assertFalse($this->Acl->check('Samir', 'printers', 'read')); $this->assertFalse($this->Acl->check('Peter', 'printers', 'read')); - $this->expectError(); - $this->assertFalse($this->Acl->deny('Bobs', 'ROOT/printers/DoesNotExist', 'create')); + $this->Acl->deny('Bobs', 'ROOT/printers/DoesNotExist', 'create'); } /** * debug function - to help editing/creating test cases for the ACL component diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index 4aa2f98f6..0c1c49f95 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -629,7 +629,7 @@ class RequestHandlerComponentTest extends CakeTestCase { */ public function testAccepts() { $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'; - $this->assertEqual($this->RequestHandler->accepts(array('js', 'xml', 'html')), 'xml'); + $this->assertTrue($this->RequestHandler->accepts(array('js', 'xml', 'html'))); $this->assertFalse($this->RequestHandler->accepts(array('gif', 'jpeg', 'foo'))); $_SERVER['HTTP_ACCEPT'] = '*/*;q=0.5'; diff --git a/lib/Cake/Test/Case/Core/AppTest.php b/lib/Cake/Test/Case/Core/AppTest.php index 0a96e7378..c878edcf4 100644 --- a/lib/Cake/Test/Case/Core/AppTest.php +++ b/lib/Cake/Test/Case/Core/AppTest.php @@ -303,14 +303,6 @@ class AppTest extends CakeTestCase { $this->assertTrue(in_array('Dispatcher', $result)); $this->assertTrue(in_array('Router', $result)); - App::build(array( - 'Model/Behavior' => App::core('Model/Behavior'), - 'Controller' => App::core('Controller'), - 'Controller/Component' => App::core('Controller/Component'), - 'View' => App::core('View'), - 'Model' => App::core('Model'), - 'View/Helper' => App::core('View/Helper'), - ), App::RESET); $result = App::objects('behavior', null, false); $this->assertTrue(in_array('TreeBehavior', $result)); $result = App::objects('Model/Behavior', null, false); diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 8f79c5381..fdc8609e7 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -342,7 +342,7 @@ class ConfigureTest extends CakeTestCase { /** * test reader() throwing exceptions on missing interface. * - * @expectedException Exception + * @expectedException PHPUnit_Framework_Error * @return void */ public function testReaderExceptionOnIncorrectClass() { diff --git a/lib/Cake/Test/Case/Model/DbAclTest.php b/lib/Cake/Test/Case/Model/DbAclTest.php index 345f5864a..4f81aa7f2 100644 --- a/lib/Cake/Test/Case/Model/DbAclTest.php +++ b/lib/Cake/Test/Case/Model/DbAclTest.php @@ -241,6 +241,7 @@ class AclNodeTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); Configure::write('Acl.classname', 'TestDbAcl'); Configure::write('Acl.database', 'test'); } diff --git a/lib/Cake/Test/Case/Model/ModelTestBase.php b/lib/Cake/Test/Case/Model/ModelTestBase.php index 0f7109571..7124118a5 100644 --- a/lib/Cake/Test/Case/Model/ModelTestBase.php +++ b/lib/Cake/Test/Case/Model/ModelTestBase.php @@ -21,8 +21,6 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); require_once dirname(__FILE__) . DS . 'models.php'; -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * ModelBaseTest * diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index d46a632cc..d747196a3 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -19,8 +19,6 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * Test class * diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index af85f95ca..95a9c373b 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -20,6 +20,24 @@ App::uses('CakeResponse', 'Network'); class CakeResponseTest extends CakeTestCase { +/** + * Setup for tests + * + * @return void + */ + public function setUp() { + ob_start(); + } + +/** + * Cleanup after tests + * + * @return void + */ + public function tearDown() { + ob_end_clean(); + } + /** * Tests the request object constructor * diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 5da648766..fca4b0029 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -127,7 +127,7 @@ class SmtpTransportTest extends CakeTestCase { /** * testConnectFail method * - * @expectedException Exception + * @expectedException SocketException * @return void */ public function testConnectFail() { @@ -258,4 +258,4 @@ class SmtpTransportTest extends CakeTestCase { $this->SmtpTransport->disconnect(); } -} \ No newline at end of file +} diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 05ce608cd..f421e8e39 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -1298,12 +1298,6 @@ class DispatcherTest extends CakeTestCase { $expected = filesize(CakePlugin::path('TestPlugin') . 'webroot' . DS . 'css' . DS . 'unknown.extension'); $headers = $response->header(); $this->assertEqual($expected, $headers['Content-Length']); - - if (php_sapi_name() == 'cli') { - while (ob_get_level()) { - ob_get_clean(); - } - } } /** diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index f04fb4163..c9657dae9 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2225,10 +2225,10 @@ class RouterTest extends CakeTestCase { /** * test that route classes must extend CakeRoute * + * @expectedException RouterException * @return void */ public function testCustomRouteException() { - $this->expectException(); Router::connect('/:controller', array(), array('routeClass' => 'Object')); } diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index c5007f9ab..af9d932dd 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -471,6 +471,7 @@ class ControllerTestCaseTest extends CakeTestCase { * @return void */ public function testNoControllerReuse() { + $this->Case->autoMock = true; $result = $this->Case->testAction('/tests_apps/index', array( 'data' => array('var' => 'first call'), 'method' => 'get', @@ -496,4 +497,17 @@ class ControllerTestCaseTest extends CakeTestCase { $this->assertContains('third call', $result); } +/** + * Test that multiple calls to redirect in the same test method don't cause issues. + * + * @return void + */ + public function testTestActionWithMultipleRedirect() { + $Controller = $this->Case->generate('TestsApps'); + + $options = array('method' => 'get'); + $this->Case->testAction('/tests_apps/redirect_to', $options); + $this->Case->testAction('/tests_apps/redirect_to', $options); + } + } diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php index 5bd7f2440..39cba4ae5 100644 --- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php +++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php @@ -189,30 +189,6 @@ class ObjectCollectionTest extends CakeTestCase { $this->assertTrue($this->Objects->trigger('callback')); } -/** - * test that the initalize callback is triggered on all components even those that are disabled. - * - * @return void - */ - public function testTriggerWithTriggerDisabledObjects() { - $this->_makeMockClasses(); - $this->Objects->load('TriggerMockFirst', array(), false); - $this->Objects->load('TriggerMockSecond'); - - $this->mockObjects[] = $this->Objects->TriggerMockFirst; - $this->mockObjects[] = $this->Objects->TriggerMockSecond; - - $this->Objects->TriggerMockFirst->expects($this->once()) - ->method('callback') - ->will($this->returnValue(true)); - $this->Objects->TriggerMockSecond->expects($this->once()) - ->method('callback') - ->will($this->returnValue(true)); - - $result = $this->Objects->trigger('callback', array(), array('triggerDisabled' => true)); - $this->assertTrue($result); - } - /** * test trigger and disabled objects * diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index e693975c6..3402fed2b 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -167,7 +167,6 @@ class XmlTest extends CakeTestCase { array(null), array(false), array(''), - array('') ); } @@ -175,13 +174,27 @@ class XmlTest extends CakeTestCase { * testBuildInvalidData * * @dataProvider invalidDataProvider - * @expectedException Exception + * @expectedException XmlException * return void */ public function testBuildInvalidData($value) { Xml::build($value); } +/** + * test build with a single empty tag + * + * return void + */ + public function testBuildEmptyTag() { + try { + Xml::build(''); + $this->fail('No exception'); + } catch (Exception $e) { + $this->assertTrue(true, 'An exception was raised'); + } + } + /** * testFromArray method * @@ -356,10 +369,14 @@ class XmlTest extends CakeTestCase { * testFromArrayFail method * * @dataProvider invalidArrayDataProvider - * @expectedException Exception */ public function testFromArrayFail($value) { - Xml::fromArray($value); + try { + Xml::fromArray($value); + $this->fail('No exception.'); + } catch (Exception $e) { + $this->assertTrue(true, 'Caught exception.'); + } } /** @@ -821,7 +838,7 @@ class XmlTest extends CakeTestCase { * testToArrayFail method * * @dataProvider invalidToArrayDataProvider - * @expectedException Exception + * @expectedException XmlException */ public function testToArrayFail($value) { Xml::toArray($value); diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php index 131661284..d6de45598 100644 --- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php @@ -169,6 +169,7 @@ class JsHelperTest extends CakeTestCase { /** * test that methods dispatch internally and to the engine class * + * @expectedException PHPUnit_Framework_Error_Warning * @return void */ public function testMethodDispatching() { @@ -182,7 +183,6 @@ class JsHelperTest extends CakeTestCase { $this->Js->event('click', 'callback'); $this->Js->TestJsEngine = new StdClass(); - $this->expectError(); $this->Js->someMethodThatSurelyDoesntExist(); } diff --git a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php index d57d3f435..ea96367c7 100644 --- a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php @@ -2175,6 +2175,7 @@ class PaginatorHelperTest extends CakeTestCase { /** * test that mock classes injected into paginatorHelper are called when using link() * + * @expectedException CakeException * @return void */ public function testMockAjaxProviderClassInjection() { @@ -2196,7 +2197,6 @@ class PaginatorHelperTest extends CakeTestCase { $Paginator->PaginatorMockJs->expects($this->once())->method('link'); $result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content')); - $this->expectException(); $Paginator = new PaginatorHelper($this->View, array('ajax' => 'Form')); } diff --git a/lib/Cake/Test/Fixture/AssertTagsTestCase.php b/lib/Cake/Test/Fixture/AssertTagsTestCase.php index 5052cc422..3ef251578 100644 --- a/lib/Cake/Test/Fixture/AssertTagsTestCase.php +++ b/lib/Cake/Test/Fixture/AssertTagsTestCase.php @@ -1,7 +1,4 @@ addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * This class helpes in indirectly testing the functionaliteies of CakeTestCase::assertTags * @@ -118,4 +115,4 @@ class AssertTagsTestCase extends CakeTestCase { ); $this->assertTags($input, $pattern); } -} \ No newline at end of file +} diff --git a/lib/Cake/Test/Fixture/FixturizedTestCase.php b/lib/Cake/Test/Fixture/FixturizedTestCase.php index fc2436ac1..b34ad155f 100644 --- a/lib/Cake/Test/Fixture/FixturizedTestCase.php +++ b/lib/Cake/Test/Fixture/FixturizedTestCase.php @@ -1,7 +1,4 @@ addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * This class helps in testing the life-cycle of fixtures inside a CakeTestCase * @@ -59,4 +56,4 @@ class FixturizedTestCase extends CakeTestCase { public function testThrowException() { throw new Exception(); } -} \ No newline at end of file +} diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 0a5db7b55..5db4a00a2 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -16,9 +16,6 @@ * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - App::uses('CakeFixtureManager', 'TestSuite/Fixture'); App::uses('CakeTestFixture', 'TestSuite/Fixture'); diff --git a/lib/Cake/TestSuite/CakeTestRunner.php b/lib/Cake/TestSuite/CakeTestRunner.php index d4dc0e14b..7c8b2c27f 100644 --- a/lib/Cake/TestSuite/CakeTestRunner.php +++ b/lib/Cake/TestSuite/CakeTestRunner.php @@ -17,8 +17,6 @@ */ require_once 'PHPUnit/TextUI/TestRunner.php'; -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * A custom test runner for Cake's use of PHPUnit. * @@ -67,8 +65,13 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { */ protected function createTestResult() { $result = new PHPUnit_Framework_TestResult; - if (isset($this->_params['codeCoverage'])) { - $result->collectCodeCoverageInformation(true); + if (!empty($this->_params['codeCoverage'])) { + if (method_exists($result, 'collectCodeCoverageInformation')) { + $result->collectCodeCoverageInformation(true); + } + if (method_exists($result, 'setCodeCoverage')) { + $result->setCodeCoverage(new PHP_CodeCoverage()); + } } return $result; } @@ -92,4 +95,4 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { } return new CakeFixtureManager(); } -} \ No newline at end of file +} diff --git a/lib/Cake/TestSuite/CakeTestSuite.php b/lib/Cake/TestSuite/CakeTestSuite.php index c21452271..ef8b068b2 100644 --- a/lib/Cake/TestSuite/CakeTestSuite.php +++ b/lib/Cake/TestSuite/CakeTestSuite.php @@ -16,8 +16,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - App::uses('Folder', 'Utility'); class CakeTestSuite extends PHPUnit_Framework_TestSuite { diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 25ec1df7d..cc463b72b 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -26,8 +26,6 @@ App::uses('CakeTestCase', 'TestSuite'); App::uses('ControllerTestCase', 'TestSuite'); App::uses('CakeTestModel', 'TestSuite/Fixture'); -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * Class to customize loading of test suites from CLI * @@ -70,8 +68,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } else { $suite = $runner->getTest( $this->arguments['test'], - $this->arguments['testFile'], - $this->arguments['syntaxCheck'] + $this->arguments['testFile'] ); } @@ -175,4 +172,4 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } return $this->arguments['printer'] = $object; } -} \ No newline at end of file +} diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 5a5989edc..029486b2a 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -151,9 +151,6 @@ class CakeTestSuiteDispatcher { $found = include 'PHPUnit' . DS . 'Autoload.php'; } } - if ($found) { - PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - } return $found; } diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index a015b1728..1557958fa 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -17,8 +17,6 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - App::uses('Dispatcher', 'Routing'); App::uses('CakeTestCase', 'TestSuite'); App::uses('Router', 'Routing'); @@ -121,7 +119,7 @@ abstract class ControllerTestCase extends CakeTestCase { * * @var boolean */ - public $autoMock = false; + public $autoMock = true; /** * Use custom routes during tests diff --git a/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php index bf2da87ed..e12a06faa 100644 --- a/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php +++ b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php @@ -17,9 +17,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - abstract class BaseCoverageReport { /** diff --git a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php index 5cc24a5d2..f85d13d1f 100644 --- a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php +++ b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php @@ -16,9 +16,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - App::uses('BaseCoverageReport', 'TestSuite/Coverage'); class HtmlCoverageReport extends BaseCoverageReport { diff --git a/lib/Cake/TestSuite/Coverage/TextCoverageReport.php b/lib/Cake/TestSuite/Coverage/TextCoverageReport.php index 1739ef020..0e2c2bc67 100644 --- a/lib/Cake/TestSuite/Coverage/TextCoverageReport.php +++ b/lib/Cake/TestSuite/Coverage/TextCoverageReport.php @@ -18,8 +18,6 @@ */ App::uses('BaseCoverageReport', 'TestSuite/Coverage'); -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - class TextCoverageReport extends BaseCoverageReport { /** diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index cec443500..59638986b 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -16,8 +16,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - App::uses('ConnectionManager', 'Model'); App::uses('ClassRegistry', 'Utility'); diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index e2756ad4b..11fe4b236 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -16,9 +16,6 @@ * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - App::uses('CakeSchema', 'Model'); /** diff --git a/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php b/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php index b73fd2d2a..c7f610391 100644 --- a/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php @@ -17,8 +17,6 @@ */ require_once 'PHPUnit/TextUI/ResultPrinter.php'; -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * CakeBaseReporter contains common reporting features used in the CakePHP Test suite * @@ -214,4 +212,4 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { $this->paintPass($test, $time); } -} \ No newline at end of file +} diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index ef744dba2..a24a22dce 100644 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -17,8 +17,6 @@ */ App::uses('CakeBaseReporter', 'TestSuite/Reporter'); -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * CakeHtmlReporter Reports Results of TestSuites and Test Cases * in an HTML format / context. @@ -143,8 +141,15 @@ class CakeHtmlReporter extends CakeBaseReporter { echo $this->_paintLinks(); echo ''; if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { - $coverage = $result->getCodeCoverage()->getSummary(); - echo $this->paintCoverage($coverage); + $coverage = $result->getCodeCoverage(); + if (method_exists($coverage, 'getSummary')) { + $report = $coverage->getSummary(); + echo $this->paintCoverage($report); + } + if (method_exists($coverage, 'getData')) { + $report = $coverage->getData(); + echo '
' . __('Coverage generation is not supported with PHPUnit 3.6 at this time.') . '
'; + } } $this->paintDocumentEnd(); } diff --git a/lib/Cake/TestSuite/Reporter/CakeTextReporter.php b/lib/Cake/TestSuite/Reporter/CakeTextReporter.php index 8de7269dc..543b9f014 100644 --- a/lib/Cake/TestSuite/Reporter/CakeTextReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeTextReporter.php @@ -15,12 +15,9 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ - App::uses('CakeBaseReporter', 'TestSuite/Reporter'); App::uses('TextCoverageReport', 'TestSuite/Coverage'); -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); - /** * CakeTextReporter contains reporting features used for plain text based output * diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php index 9406b76c6..c3fdeed6b 100644 --- a/lib/Cake/Utility/ObjectCollection.php +++ b/lib/Cake/Utility/ObjectCollection.php @@ -42,7 +42,7 @@ abstract class ObjectCollection { /** * Loads a new object onto the collection. Can throw a variety of exceptions * - * Implementations of this class support a `$options['callbacks']` flag which enables/disables + * Implementations of this class support a `$options['enabled']` flag which enables/disables * a loaded object. * * @param string $name Name of object to load. @@ -68,9 +68,6 @@ abstract class ObjectCollection { * - `collectReturn` Set to true to collect the return of each object into an array. * This array of return values will be returned from the trigger() call. Defaults to `false`. * - * - `triggerDisabled` Will trigger the callback on all objects in the collection even the non-enabled - * objects. Defaults to false. - * * - `modParams` Allows each object the callback gets called on to modify the parameters to the next object. * Setting modParams to an integer value will allow you to modify the parameter with that index. * Any non-null value will modify the parameter index indicated. @@ -93,16 +90,12 @@ abstract class ObjectCollection { 'break' => false, 'breakOn' => false, 'collectReturn' => false, - 'triggerDisabled' => false, 'modParams' => false ), $options ); $collected = array(); $list = $this->_enabled; - if ($options['triggerDisabled'] === true) { - $list = array_keys($this->_loaded); - } if ($options['modParams'] !== false && !isset($params[$options['modParams']])) { throw new CakeException(__d('cake_dev', 'Cannot use modParams with indexes that do not exist.')); }