Base for a static organization website

DebugMemoryTest.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * DebugKit Debug Memory Test Cases
  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. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  16. **/
  17. App::uses('DebugMemory', 'DebugKit.Lib');
  18. /**
  19. * Class DebugMemoryTest
  20. *
  21. */
  22. class DebugMemoryTest extends CakeTestCase {
  23. /**
  24. * test memory usage
  25. *
  26. * @return void
  27. */
  28. public function testMemoryUsage() {
  29. $result = DebugMemory::getCurrent();
  30. $this->assertTrue(is_int($result));
  31. $result = DebugMemory::getPeak();
  32. $this->assertTrue(is_int($result));
  33. }
  34. /**
  35. * test making memory use markers.
  36. *
  37. * @return void
  38. */
  39. public function testMemorySettingAndGetting() {
  40. DebugMemory::clear();
  41. $result = DebugMemory::record('test marker');
  42. $this->assertTrue($result);
  43. $result = DebugMemory::getAll(true);
  44. $this->assertEquals(count($result), 1);
  45. $this->assertTrue(isset($result['test marker']));
  46. $this->assertTrue(is_numeric($result['test marker']));
  47. $result = DebugMemory::getAll();
  48. $this->assertTrue(empty($result));
  49. DebugMemory::record('test marker');
  50. DebugMemory::record('test marker');
  51. $result = DebugMemory::getAll();
  52. $this->assertEquals(count($result), 2);
  53. $this->assertTrue(isset($result['test marker']));
  54. $this->assertTrue(isset($result['test marker #2']));
  55. }
  56. }