Browse Source

Merge pull request #6432 from cakephp/master-integrationtestcase-test

Add tests for exception bubble up.
José Lorenzo Rodríguez 11 years ago
parent
commit
3d64adfffd

+ 23 - 0
tests/TestCase/TestSuite/IntegrationTestCaseTest.php

@@ -142,6 +142,29 @@ class IntegrationTestCaseTest extends IntegrationTestCase
     }
 
     /**
+     * Test that exceptions being thrown are handled correctly.
+     *
+     * @return void
+     */
+    public function testWithExpectedException()
+    {
+        $this->get('/tests_apps/throw_exception');
+        $this->assertResponseCode(500);
+    }
+
+    /**
+     * Test that exceptions being thrown are handled correctly.
+     *
+     * @expectedException PHPUnit_Framework_AssertionFailedError
+     * @return void
+     */
+    public function testWithUnexpectedException()
+    {
+        $this->get('/tests_apps/throw_exception');
+        $this->assertResponseCode(501);
+    }
+
+    /**
      * Test redirecting and integration tests.
      *
      * @return void

+ 5 - 0
tests/test_app/TestApp/Controller/TestsAppsController.php

@@ -61,4 +61,9 @@ class TestsAppsController extends AppController
         $this->response->type('json');
         return $this->response;
     }
+
+    public function throw_exception()
+    {
+        throw new \RuntimeException('Foo');
+    }
 }