Base for a static organization website

TimedBehaviorTest.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * DebugKit TimedBehavior Test Case
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright (c) 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 (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @since DebugKit 1.3
  16. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  17. */
  18. App::uses('DebugKitDebugger', 'DebugKit.Lib');
  19. /**
  20. * Class TimedBehaviorTestCase
  21. *
  22. * @since DebugKit 1.3
  23. */
  24. class TimedBehaviorTestCase extends CakeTestCase {
  25. /**
  26. * Fixtures
  27. *
  28. * @var array
  29. */
  30. public $fixtures = array('core.article');
  31. /**
  32. * Start Test callback
  33. *
  34. * @return void
  35. */
  36. public function setUp() {
  37. parent::setUp();
  38. $this->Article = ClassRegistry::init('Article');
  39. $this->Article->Behaviors->attach('DebugKit.Timed');
  40. }
  41. /**
  42. * End a test
  43. *
  44. * @return void
  45. */
  46. public function tearDown() {
  47. parent::tearDown();
  48. unset($this->Article);
  49. ClassRegistry::flush();
  50. DebugKitDebugger::clearTimers();
  51. }
  52. /**
  53. * Test find timers
  54. *
  55. * @return void
  56. */
  57. public function testFindTimers() {
  58. $timers = DebugKitDebugger::getTimers(false);
  59. $this->assertEquals(count($timers), 1);
  60. $this->Article->find('all');
  61. $result = DebugKitDebugger::getTimers(false);
  62. $this->assertEquals(count($result), 2);
  63. $this->Article->find('all');
  64. $result = DebugKitDebugger::getTimers(false);
  65. $this->assertEquals(count($result), 3);
  66. }
  67. /**
  68. * Test save timers
  69. *
  70. * @return void
  71. */
  72. public function testSaveTimers() {
  73. $timers = DebugKitDebugger::getTimers(false);
  74. $this->assertEquals(count($timers), 1);
  75. $this->Article->save(array('user_id' => 1, 'title' => 'test', 'body' => 'test'));
  76. $result = DebugKitDebugger::getTimers(false);
  77. $this->assertEquals(count($result), 2);
  78. }
  79. }