Skip to content

Instantly share code, notes, and snippets.

@tareko
Created May 24, 2012 03:31
Show Gist options
  • Select an option

  • Save tareko/2779261 to your computer and use it in GitHub Desktop.

Select an option

Save tareko/2779261 to your computer and use it in GitHub Desktop.
Broken function re: Testing the Calendar controller
Function:
public function view($id = null) {
$this->Calendar->id = $id;
if (!$this->Calendar->exists()) {
throw new NotFoundException(__('Invalid calendar'));
}
$this->set('calendar', $this->Calendar->read(null, $id));
}
Test:
public function testViewNoId() {
$result = $this->testAction('/calendars/view');
$this->setExpectedException('NotFoundException');
}
Result:
NotFoundException
Invalid calendar
Test case: CalendarsControllerTestCase(testViewNoId)
Stack trace:
CalendarsController::view
/var/www/kitab/lib/Cake/Controller/Controller.php : 485
/var/www/kitab/lib/Cake/Routing/Dispatcher.php : 103
/var/www/kitab/lib/Cake/Routing/Dispatcher.php : 85
/var/www/kitab/lib/Cake/TestSuite/ControllerTestCase.php : 266
ControllerTestCase::_testAction
/var/www/kitab/lib/Cake/TestSuite/ControllerTestCase.php : 187
/var/www/kitab/app/Test/Case/Controller/CalendarsControllerTest.php : 60
/var/www/kitab/app/Test/Case/Controller/CalendarsControllerTest.php : 60
CalendarsControllerTestCase::testViewNoId
/usr/share/php/PHPUnit/Framework/TestCase.php : 942
/usr/share/php/PHPUnit/Framework/TestCase.php : 804
/usr/share/php/PHPUnit/Framework/TestResult.php : 649
/usr/share/php/PHPUnit/Framework/TestCase.php : 751
/var/www/kitab/lib/Cake/TestSuite/CakeTestCase.php : 78
/usr/share/php/PHPUnit/Framework/TestSuite.php : 772
/usr/share/php/PHPUnit/Framework/TestSuite.php : 745
/usr/share/php/PHPUnit/TextUI/TestRunner.php : 325
/var/www/kitab/lib/Cake/TestSuite/CakeTestRunner.php : 57
/var/www/kitab/lib/Cake/TestSuite/CakeTestSuiteCommand.php : 111
/var/www/kitab/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php : 251
/var/www/kitab/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php : 99
/var/www/kitab/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php : 116
/var/www/kitab/app/webroot/test.php : 92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment