Browse Source

Code Cleanup - Exception

Ensure files that use Exception have the appropriate use statement
Michael Pirouet 11 years ago
parent
commit
6261c5096d

+ 2 - 1
src/TestSuite/TestCase.php

@@ -19,6 +19,7 @@ use Cake\Datasource\ConnectionManager;
 use Cake\ORM\TableRegistry;
 use Cake\Routing\Router;
 use Cake\Utility\Inflector;
+use Exception;
 
 /**
  * Cake TestCase class
@@ -126,7 +127,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
     public function loadFixtures()
     {
         if (empty($this->fixtureManager)) {
-            throw new \Exception('No fixture manager to load the test fixture');
+            throw new Exception('No fixture manager to load the test fixture');
         }
         $args = func_get_args();
         foreach ($args as $class) {

+ 2 - 1
tests/Fixture/FixturizedTestCase.php

@@ -2,6 +2,7 @@
 namespace Cake\Test\Fixture;
 
 use Cake\TestSuite\TestCase;
+use Exception;
 
 /**
  * This class helps in testing the life-cycle of fixtures inside a CakeTestCase
@@ -64,6 +65,6 @@ class FixturizedTestCase extends TestCase
      */
     public function testThrowException()
     {
-        throw new \Exception();
+        throw new Exception();
     }
 }

+ 2 - 2
tests/TestCase/Controller/Component/FlashComponentTest.php

@@ -18,10 +18,10 @@ use Cake\Controller\ComponentRegistry;
 use Cake\Controller\Component\FlashComponent;
 use Cake\Controller\Controller;
 use Cake\Core\Configure;
-use Cake\Event\Event;
 use Cake\Network\Request;
 use Cake\Network\Session;
 use Cake\TestSuite\TestCase;
+use Exception;
 
 /**
  * FlashComponentTest class
@@ -116,7 +116,7 @@ class FlashComponentTest extends TestCase
     {
         $this->assertNull($this->Session->read('Flash.flash'));
 
-        $this->Flash->set(new \Exception('This is a test message', 404));
+        $this->Flash->set(new Exception('This is a test message', 404));
         $expected = [
             'message' => 'This is a test message',
             'key' => 'flash',

+ 2 - 1
tests/TestCase/Core/InstanceConfigTraitTest.php

@@ -16,6 +16,7 @@ namespace Cake\Test\TestCase\Core;
 
 use Cake\Core\InstanceConfigTrait;
 use Cake\TestSuite\TestCase;
+use Exception;
 
 /**
  * TestInstanceConfig
@@ -68,7 +69,7 @@ class ReadOnlyTestInstanceConfig
      */
     protected function _configWrite($key, $value = null)
     {
-        throw new \Exception('This Instance is readonly');
+        throw new Exception('This Instance is readonly');
     }
 }
 

+ 5 - 6
tests/TestCase/Error/ExceptionRendererTest.php

@@ -18,13 +18,11 @@ use Cake\Controller\Component;
 use Cake\Controller\Controller;
 use Cake\Controller\Exception\MissingActionException;
 use Cake\Controller\Exception\MissingComponentException;
-use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Exception\MissingPluginException;
 use Cake\Core\Plugin;
 use Cake\Datasource\Exception\MissingDatasourceConfigException;
 use Cake\Datasource\Exception\MissingDatasourceException;
-use Cake\Error;
 use Cake\Error\ExceptionRenderer;
 use Cake\Event\Event;
 use Cake\Event\EventManager;
@@ -40,6 +38,7 @@ use Cake\TestSuite\TestCase;
 use Cake\View\Exception\MissingHelperException;
 use Cake\View\Exception\MissingLayoutException;
 use Cake\View\Exception\MissingTemplateException;
+use Exception;
 
 /**
  * BlueberryComponent class
@@ -583,7 +582,7 @@ class ExceptionRendererTest extends TestCase
                 500
             ],
             [
-                new \Exception('boom'),
+                new Exception('boom'),
                 [
                     '/Internal Error/'
                 ],
@@ -597,7 +596,7 @@ class ExceptionRendererTest extends TestCase
                 500
             ],
             [
-                new \Cake\Core\Exception\Exception('base class'),
+                new \Cake\Core\ExceptionException('base class'),
                 ['/Internal Error/'],
                 500
             ]
@@ -806,7 +805,7 @@ class ExceptionRendererTest extends TestCase
         Router::reload();
         $this->assertNull(Router::getRequest(false));
 
-        $exception = new \Exception('Terrible');
+        $exception = new Exception('Terrible');
         $ExceptionRenderer = new ExceptionRenderer($exception);
         $result = $ExceptionRenderer->render();
 
@@ -829,7 +828,7 @@ class ExceptionRendererTest extends TestCase
         $events->attach($listener, 'Controller.shutdown');
         $events->attach($listener, 'Dispatcher.afterDispatch');
 
-        $exception = new \Exception('Terrible');
+        $exception = new Exception('Terrible');
         $renderer = new ExceptionRenderer($exception);
         $renderer->render();
 

+ 2 - 4
tests/TestCase/Network/Email/EmailTest.php

@@ -14,16 +14,14 @@
  */
 namespace Cake\Test\TestCase\Network\Email;
 
-use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
-use Cake\Filesystem\File;
 use Cake\Log\Log;
 use Cake\Network\Email\DebugTransport;
 use Cake\Network\Email\Email;
 use Cake\ORM\TableRegistry;
 use Cake\TestSuite\TestCase;
-use Cake\View\Exception\MissingTemplateException;
+use Exception;
 use SimpleXmlElement;
 
 /**
@@ -2623,7 +2621,7 @@ XML;
             ->viewVars([
                 'users' => TableRegistry::get('Users')->get(1, ['fields' => ['id', 'username']]),
                 'xml' => new SimpleXmlElement($xmlstr),
-                'exception' => new \Exception('test')
+                'exception' => new Exception('test')
             ])
             ->attachments([
                 'test.txt' => TEST_APP . 'config' . DS . 'empty.ini',

+ 3 - 3
tests/TestCase/ORM/TableTest.php

@@ -17,7 +17,7 @@ namespace Cake\Test\TestCase\ORM;
 use ArrayObject;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
-use Cake\Database\Expression\OrderByExpression;
+use Cake\Database\Exception;
 use Cake\Database\Expression\QueryExpression;
 use Cake\Database\TypeMap;
 use Cake\Datasource\ConnectionManager;
@@ -859,7 +859,7 @@ class TableTest extends TestCase
 
         $query->expects($this->once())
             ->method('execute')
-            ->will($this->throwException(new \Cake\Database\Exception('Not good')));
+            ->will($this->throwException(new Exception('Not good')));
 
         $table->updateAll(['username' => 'mark'], []);
     }
@@ -922,7 +922,7 @@ class TableTest extends TestCase
 
         $query->expects($this->once())
             ->method('execute')
-            ->will($this->throwException(new \Cake\Database\Exception('Not good')));
+            ->will($this->throwException(new Exception('Not good')));
 
         $table->deleteAll(['id >' => 4]);
     }

+ 2 - 4
tests/TestCase/TestSuite/TestFixtureTest.php

@@ -14,12 +14,10 @@
  */
 namespace Cake\Test\TestCase\TestSuite;
 
-use Cake\Core\Configure;
-use Cake\Datasource\ConnectionManager;
 use Cake\Log\Log;
 use Cake\TestSuite\Fixture\TestFixture;
 use Cake\TestSuite\TestCase;
-use Cake\Utility\ClassRegistry;
+use Exception;
 
 /**
  * ArticlesFixture class
@@ -251,7 +249,7 @@ class TestFixtureTest extends TestCase
         $table->expects($this->once())
             ->method('createSql')
             ->with($db)
-            ->will($this->throwException(new \Exception('oh noes')));
+            ->will($this->throwException(new Exception('oh noes')));
         $fixture->schema($table);
 
         $fixture->create($db);