sugar_config = $sugar_config; $this->sugarView = new Bug45181TestSugarViewMock(); $this->sugarView->module = 'Contacts'; $this->sugarView->action = 'EditView'; if (is_file('memory_usage.log')) { unlink('memory_usage.log'); } } function tearDown() { global $sugar_config; if (is_file('memory_usage.log')) { unlink('memory_usage.log'); } $sugar_config = $this->sugar_config; unset($this->sugar_config); unset($GLOBALS['app_strings']); } /** * testLogMemoryUsageOn * This test asserts that when log_memory_usage is set to true we receive a log message from the function * call and the memory_usage.log file is created. * * @outputBuffering enabled */ function testLogMemoryUsageOn() { if(!function_exists('memory_get_usage') || !function_exists('memory_get_peak_usage')) { $this->markTestSkipped('Skipping test since memory_get_usage and memory_get_peak_usage function are unavailable'); return; } global $sugar_config; $sugar_config['log_memory_usage'] = true; $output = $this->sugarView->logMemoryStatisticsTest("\n"); $this->assertNotEmpty($output, "Failed to recognize log_memory_usage = true setting"); $this->assertFileExists('memory_usage.log', 'Unable to create memory_usage.log file'); } /** * testLogMemoryUsageOff * This test asserts that when log_memory_usage is set to false we do not receive a log message from the function * call nor is the memory_usage.log file created. * * @outputBuffering enabled * */ function testLogMemoryUsageOff() { if(!function_exists('memory_get_usage') || !function_exists('memory_get_peak_usage')) { $this->markTestSkipped('Skipping test since memory_get_usage and memory_get_peak_usage function are unavailable'); return; } global $sugar_config; $sugar_config['log_memory_usage'] = false; $output = $this->sugarView->logMemoryStatisticsTest("\n"); $this->assertEmpty($output, "Failed to recognize log_memory_usage = false setting"); $this->assertFileNotExists('memory_usage.log'); } } require_once('include/MVC/View/SugarView.php'); class Bug45181TestSugarViewMock extends SugarView { public function logMemoryStatisticsTest($newline) { return $this->logMemoryStatistics($newline); } }